Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not deserialize empty response body #63

Merged
merged 2 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions codegen/java/github/RustServerCodegen.java
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,9 @@ public String apiFileFolder() {
public String toModelName(String name) {
// camelize the model name
// phone_number => PhoneNumber
if (name != null && name.contains("chrono")) {
return name;
}
String camelizedName = camelize(toModelFilename(name));

// model name cannot use reserved keyword, e.g. return
Expand Down
4 changes: 2 additions & 2 deletions codegen/templates/api.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ impl<'api, C: Client> {{classname}}<'api, C> where AdapterError: From<<C as Clie
// --

if github_response.is_success() {
Ok(github_response.to_json_async().await?)
Ok({{#vendorExtensions.x-codegen-response-empty-default}}(){{/vendorExtensions.x-codegen-response-empty-default}}{{^vendorExtensions.x-codegen-response-empty-default}}github_response.to_json_async().await?{{/vendorExtensions.x-codegen-response-empty-default}})
} else {
match github_response.status_code() {
{{#responses}}{{#vendorExtensions}}{{^x-is-default}}
Expand Down Expand Up @@ -209,7 +209,7 @@ impl<'api, C: Client> {{classname}}<'api, C> where AdapterError: From<<C as Clie
// --

if github_response.is_success() {
Ok(github_response.to_json()?)
Ok({{#vendorExtensions.x-codegen-response-empty-default}}(){{/vendorExtensions.x-codegen-response-empty-default}}{{^vendorExtensions.x-codegen-response-empty-default}}github_response.to_json()?{{/vendorExtensions.x-codegen-response-empty-default}})
} else {
match github_response.status_code() {
{{#responses}}{{#vendorExtensions}}{{^x-is-default}}
Expand Down
184 changes: 92 additions & 92 deletions src/endpoints/actions.rs

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions src/endpoints/activity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1752,7 +1752,7 @@ impl<'api, C: Client> Activity<'api, C> where AdapterError: From<<C as Client>::
// --

if github_response.is_success() {
Ok(github_response.to_json_async().await?)
Ok(())
} else {
match github_response.status_code() {
404 => Err(ActivityCheckRepoIsStarredByAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()),
Expand Down Expand Up @@ -1795,7 +1795,7 @@ impl<'api, C: Client> Activity<'api, C> where AdapterError: From<<C as Client>::
// --

if github_response.is_success() {
Ok(github_response.to_json()?)
Ok(())
} else {
match github_response.status_code() {
404 => Err(ActivityCheckRepoIsStarredByAuthenticatedUserError::Status404(github_response.to_json()?).into()),
Expand Down Expand Up @@ -1837,7 +1837,7 @@ impl<'api, C: Client> Activity<'api, C> where AdapterError: From<<C as Client>::
// --

if github_response.is_success() {
Ok(github_response.to_json_async().await?)
Ok(())
} else {
match github_response.status_code() {
code => Err(ActivityDeleteRepoSubscriptionError::Generic { code }.into()),
Expand Down Expand Up @@ -1876,7 +1876,7 @@ impl<'api, C: Client> Activity<'api, C> where AdapterError: From<<C as Client>::
// --

if github_response.is_success() {
Ok(github_response.to_json()?)
Ok(())
} else {
match github_response.status_code() {
code => Err(ActivityDeleteRepoSubscriptionError::Generic { code }.into()),
Expand Down Expand Up @@ -1914,7 +1914,7 @@ impl<'api, C: Client> Activity<'api, C> where AdapterError: From<<C as Client>::
// --

if github_response.is_success() {
Ok(github_response.to_json_async().await?)
Ok(())
} else {
match github_response.status_code() {
304 => Err(ActivityDeleteThreadSubscriptionError::Status304.into()),
Expand Down Expand Up @@ -1956,7 +1956,7 @@ impl<'api, C: Client> Activity<'api, C> where AdapterError: From<<C as Client>::
// --

if github_response.is_success() {
Ok(github_response.to_json()?)
Ok(())
} else {
match github_response.status_code() {
304 => Err(ActivityDeleteThreadSubscriptionError::Status304.into()),
Expand Down Expand Up @@ -2325,7 +2325,7 @@ impl<'api, C: Client> Activity<'api, C> where AdapterError: From<<C as Client>::
///
/// # List events for the authenticated user
///
/// If you are authenticated as the given user, you will see your private events. Otherwise, you'll only see public events.
/// If you are authenticated as the given user, you will see your private events. Otherwise, you'll only see public events. _Optional_: use the fine-grained token with following permission set to view private events: "Events" user permissions (read).
///
/// > [!NOTE]
/// > This API is not built to serve real-time use cases. Depending on the time of day, event latency can be anywhere from 30s to 6h.
Expand Down Expand Up @@ -2370,7 +2370,7 @@ impl<'api, C: Client> Activity<'api, C> where AdapterError: From<<C as Client>::
///
/// # List events for the authenticated user
///
/// If you are authenticated as the given user, you will see your private events. Otherwise, you'll only see public events.
/// If you are authenticated as the given user, you will see your private events. Otherwise, you'll only see public events. _Optional_: use the fine-grained token with following permission set to view private events: "Events" user permissions (read).
///
/// > [!NOTE]
/// > This API is not built to serve real-time use cases. Depending on the time of day, event latency can be anywhere from 30s to 6h.
Expand Down Expand Up @@ -4069,7 +4069,7 @@ impl<'api, C: Client> Activity<'api, C> where AdapterError: From<<C as Client>::
// --

if github_response.is_success() {
Ok(github_response.to_json_async().await?)
Ok(())
} else {
match github_response.status_code() {
code => Err(ActivityMarkThreadAsDoneError::Generic { code }.into()),
Expand Down Expand Up @@ -4108,7 +4108,7 @@ impl<'api, C: Client> Activity<'api, C> where AdapterError: From<<C as Client>::
// --

if github_response.is_success() {
Ok(github_response.to_json()?)
Ok(())
} else {
match github_response.status_code() {
code => Err(ActivityMarkThreadAsDoneError::Generic { code }.into()),
Expand Down Expand Up @@ -4146,7 +4146,7 @@ impl<'api, C: Client> Activity<'api, C> where AdapterError: From<<C as Client>::
// --

if github_response.is_success() {
Ok(github_response.to_json_async().await?)
Ok(())
} else {
match github_response.status_code() {
304 => Err(ActivityMarkThreadAsReadError::Status304.into()),
Expand Down Expand Up @@ -4187,7 +4187,7 @@ impl<'api, C: Client> Activity<'api, C> where AdapterError: From<<C as Client>::
// --

if github_response.is_success() {
Ok(github_response.to_json()?)
Ok(())
} else {
match github_response.status_code() {
304 => Err(ActivityMarkThreadAsReadError::Status304.into()),
Expand Down Expand Up @@ -4395,7 +4395,7 @@ impl<'api, C: Client> Activity<'api, C> where AdapterError: From<<C as Client>::
// --

if github_response.is_success() {
Ok(github_response.to_json_async().await?)
Ok(())
} else {
match github_response.status_code() {
403 => Err(ActivityStarRepoForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()),
Expand Down Expand Up @@ -4438,7 +4438,7 @@ impl<'api, C: Client> Activity<'api, C> where AdapterError: From<<C as Client>::
// --

if github_response.is_success() {
Ok(github_response.to_json()?)
Ok(())
} else {
match github_response.status_code() {
403 => Err(ActivityStarRepoForAuthenticatedUserError::Status403(github_response.to_json()?).into()),
Expand Down Expand Up @@ -4480,7 +4480,7 @@ impl<'api, C: Client> Activity<'api, C> where AdapterError: From<<C as Client>::
// --

if github_response.is_success() {
Ok(github_response.to_json_async().await?)
Ok(())
} else {
match github_response.status_code() {
404 => Err(ActivityUnstarRepoForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()),
Expand Down Expand Up @@ -4523,7 +4523,7 @@ impl<'api, C: Client> Activity<'api, C> where AdapterError: From<<C as Client>::
// --

if github_response.is_success() {
Ok(github_response.to_json()?)
Ok(())
} else {
match github_response.status_code() {
404 => Err(ActivityUnstarRepoForAuthenticatedUserError::Status404(github_response.to_json()?).into()),
Expand Down
47 changes: 17 additions & 30 deletions src/endpoints/apps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1527,9 +1527,7 @@ pub struct AppsListWebhookDeliveriesParams<'req> {
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
per_page: Option<u16>,
/// Used for pagination: the starting delivery from which the page of deliveries is fetched. Refer to the `link` header for the next and previous page cursors.
cursor: Option<&'req str>,

redelivery: Option<bool>
cursor: Option<&'req str>
}

impl<'req> AppsListWebhookDeliveriesParams<'req> {
Expand All @@ -1542,7 +1540,6 @@ impl<'req> AppsListWebhookDeliveriesParams<'req> {
Self {
per_page: Some(per_page),
cursor: self.cursor,
redelivery: self.redelivery,
}
}

Expand All @@ -1551,16 +1548,6 @@ impl<'req> AppsListWebhookDeliveriesParams<'req> {
Self {
per_page: self.per_page,
cursor: Some(cursor),
redelivery: self.redelivery,
}
}


pub fn redelivery(self, redelivery: bool) -> Self {
Self {
per_page: self.per_page,
cursor: self.cursor,
redelivery: Some(redelivery),
}
}
}
Expand Down Expand Up @@ -1599,7 +1586,7 @@ impl<'api, C: Client> Apps<'api, C> where AdapterError: From<<C as Client>::Err>
// --

if github_response.is_success() {
Ok(github_response.to_json_async().await?)
Ok(())
} else {
match github_response.status_code() {
403 => Err(AppsAddRepoToInstallationForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()),
Expand Down Expand Up @@ -1643,7 +1630,7 @@ impl<'api, C: Client> Apps<'api, C> where AdapterError: From<<C as Client>::Err>
// --

if github_response.is_success() {
Ok(github_response.to_json()?)
Ok(())
} else {
match github_response.status_code() {
403 => Err(AppsAddRepoToInstallationForAuthenticatedUserError::Status403(github_response.to_json()?).into()),
Expand Down Expand Up @@ -1948,7 +1935,7 @@ impl<'api, C: Client> Apps<'api, C> where AdapterError: From<<C as Client>::Err>
// --

if github_response.is_success() {
Ok(github_response.to_json_async().await?)
Ok(())
} else {
match github_response.status_code() {
422 => Err(AppsDeleteAuthorizationError::Status422(github_response.to_json_async().await?).into()),
Expand Down Expand Up @@ -1989,7 +1976,7 @@ impl<'api, C: Client> Apps<'api, C> where AdapterError: From<<C as Client>::Err>
// --

if github_response.is_success() {
Ok(github_response.to_json()?)
Ok(())
} else {
match github_response.status_code() {
422 => Err(AppsDeleteAuthorizationError::Status422(github_response.to_json()?).into()),
Expand Down Expand Up @@ -2030,7 +2017,7 @@ impl<'api, C: Client> Apps<'api, C> where AdapterError: From<<C as Client>::Err>
// --

if github_response.is_success() {
Ok(github_response.to_json_async().await?)
Ok(())
} else {
match github_response.status_code() {
404 => Err(AppsDeleteInstallationError::Status404(github_response.to_json_async().await?).into()),
Expand Down Expand Up @@ -2072,7 +2059,7 @@ impl<'api, C: Client> Apps<'api, C> where AdapterError: From<<C as Client>::Err>
// --

if github_response.is_success() {
Ok(github_response.to_json()?)
Ok(())
} else {
match github_response.status_code() {
404 => Err(AppsDeleteInstallationError::Status404(github_response.to_json()?).into()),
Expand Down Expand Up @@ -2111,7 +2098,7 @@ impl<'api, C: Client> Apps<'api, C> where AdapterError: From<<C as Client>::Err>
// --

if github_response.is_success() {
Ok(github_response.to_json_async().await?)
Ok(())
} else {
match github_response.status_code() {
422 => Err(AppsDeleteTokenError::Status422(github_response.to_json_async().await?).into()),
Expand Down Expand Up @@ -2151,7 +2138,7 @@ impl<'api, C: Client> Apps<'api, C> where AdapterError: From<<C as Client>::Err>
// --

if github_response.is_success() {
Ok(github_response.to_json()?)
Ok(())
} else {
match github_response.status_code() {
422 => Err(AppsDeleteTokenError::Status422(github_response.to_json()?).into()),
Expand Down Expand Up @@ -4229,7 +4216,7 @@ impl<'api, C: Client> Apps<'api, C> where AdapterError: From<<C as Client>::Err>
// --

if github_response.is_success() {
Ok(github_response.to_json_async().await?)
Ok(())
} else {
match github_response.status_code() {
403 => Err(AppsRemoveRepoFromInstallationForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()),
Expand Down Expand Up @@ -4274,7 +4261,7 @@ impl<'api, C: Client> Apps<'api, C> where AdapterError: From<<C as Client>::Err>
// --

if github_response.is_success() {
Ok(github_response.to_json()?)
Ok(())
} else {
match github_response.status_code() {
403 => Err(AppsRemoveRepoFromInstallationForAuthenticatedUserError::Status403(github_response.to_json()?).into()),
Expand Down Expand Up @@ -4397,7 +4384,7 @@ impl<'api, C: Client> Apps<'api, C> where AdapterError: From<<C as Client>::Err>
// --

if github_response.is_success() {
Ok(github_response.to_json_async().await?)
Ok(())
} else {
match github_response.status_code() {
code => Err(AppsRevokeInstallationAccessTokenError::Generic { code }.into()),
Expand Down Expand Up @@ -4438,7 +4425,7 @@ impl<'api, C: Client> Apps<'api, C> where AdapterError: From<<C as Client>::Err>
// --

if github_response.is_success() {
Ok(github_response.to_json()?)
Ok(())
} else {
match github_response.status_code() {
code => Err(AppsRevokeInstallationAccessTokenError::Generic { code }.into()),
Expand Down Expand Up @@ -4571,7 +4558,7 @@ impl<'api, C: Client> Apps<'api, C> where AdapterError: From<<C as Client>::Err>
// --

if github_response.is_success() {
Ok(github_response.to_json_async().await?)
Ok(())
} else {
match github_response.status_code() {
404 => Err(AppsSuspendInstallationError::Status404(github_response.to_json_async().await?).into()),
Expand Down Expand Up @@ -4613,7 +4600,7 @@ impl<'api, C: Client> Apps<'api, C> where AdapterError: From<<C as Client>::Err>
// --

if github_response.is_success() {
Ok(github_response.to_json()?)
Ok(())
} else {
match github_response.status_code() {
404 => Err(AppsSuspendInstallationError::Status404(github_response.to_json()?).into()),
Expand Down Expand Up @@ -4654,7 +4641,7 @@ impl<'api, C: Client> Apps<'api, C> where AdapterError: From<<C as Client>::Err>
// --

if github_response.is_success() {
Ok(github_response.to_json_async().await?)
Ok(())
} else {
match github_response.status_code() {
404 => Err(AppsUnsuspendInstallationError::Status404(github_response.to_json_async().await?).into()),
Expand Down Expand Up @@ -4696,7 +4683,7 @@ impl<'api, C: Client> Apps<'api, C> where AdapterError: From<<C as Client>::Err>
// --

if github_response.is_success() {
Ok(github_response.to_json()?)
Ok(())
} else {
match github_response.status_code() {
404 => Err(AppsUnsuspendInstallationError::Status404(github_response.to_json()?).into()),
Expand Down
Loading
Loading