summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCyborus <cyborus@noreply.codeberg.org>2024-07-14 22:10:55 +0200
committerCyborus <cyborus@noreply.codeberg.org>2024-07-14 22:10:55 +0200
commit80b9047d9c3a1fd94d5a53f9f75af795b6f44f72 (patch)
tree73e6b5c80e39f3d2b6dbdede74993bc6869d36db
parentMerge pull request 'sign integers by default' (#66) from signed-int-default i... (diff)
parentfix: correct body parsing for each status code (diff)
downloadforgejo-api-80b9047d9c3a1fd94d5a53f9f75af795b6f44f72.tar.xz
forgejo-api-80b9047d9c3a1fd94d5a53f9f75af795b6f44f72.zip
Merge pull request 'correct body parsing for each status code' (#67) from status-code-returns into main
Reviewed-on: https://codeberg.org/Cyborus/forgejo-api/pulls/67
-rw-r--r--generator/src/methods.rs3
-rw-r--r--src/generated/methods.rs6
2 files changed, 5 insertions, 4 deletions
diff --git a/generator/src/methods.rs b/generator/src/methods.rs
index 75bb7db..8039f96 100644
--- a/generator/src/methods.rs
+++ b/generator/src/methods.rs
@@ -462,6 +462,7 @@ fn create_method_response(spec: &OpenApiV2, op: &Operation) -> eyre::Result<Stri
out.push_str("let response = self.execute(request).await?;\n");
out.push_str("match response.status().as_u16() {\n");
for (code, res) in &op.responses.http_codes {
+ let branch_ret = response_ref_type_name(spec, res, op)?;
let res = res.deref(spec)?;
if !code.starts_with("2") {
continue;
@@ -491,7 +492,7 @@ fn create_method_response(spec: &OpenApiV2, op: &Operation) -> eyre::Result<Stri
}
};
handlers.extend(header_handler);
- let body_handler = match fn_ret.kind {
+ let body_handler = match branch_ret.kind {
Some(ResponseKind::Text) => {
if optional {
Some("Some(response.text().await?)")
diff --git a/src/generated/methods.rs b/src/generated/methods.rs
index 621b3c9..7eeb1b0 100644
--- a/src/generated/methods.rs
+++ b/src/generated/methods.rs
@@ -2799,7 +2799,7 @@ impl crate::Forgejo {
let response = self.execute(request).await?;
match response.status().as_u16() {
200 => Ok(Some(response.json().await?)),
- 204 => Ok(Some(response.json().await?)),
+ 204 => Ok(None),
_ => Err(ForgejoError::UnexpectedStatusCode(response.status())),
}
}
@@ -2845,7 +2845,7 @@ impl crate::Forgejo {
let response = self.execute(request).await?;
match response.status().as_u16() {
200 => Ok(Some(response.json().await?)),
- 204 => Ok(Some(response.json().await?)),
+ 204 => Ok(None),
_ => Err(ForgejoError::UnexpectedStatusCode(response.status())),
}
}
@@ -3448,7 +3448,7 @@ impl crate::Forgejo {
let response = self.execute(request).await?;
match response.status().as_u16() {
200 => Ok(Some(response.json().await?)),
- 204 => Ok(Some(response.json().await?)),
+ 204 => Ok(None),
_ => Err(ForgejoError::UnexpectedStatusCode(response.status())),
}
}