summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCyborus <cyborus@cyborus.xyz>2024-07-01 19:03:00 +0200
committerCyborus <cyborus@cyborus.xyz>2024-07-30 18:00:42 +0200
commitb2886d9c9e567e10362a68e5bf42d1cd8267d5ca (patch)
treee9bd8148a7ea30aced1f109bd3e16867b695e638
parentchore: pull swagger file from `v8.next.forgejo.org` (diff)
downloadforgejo-api-b2886d9c9e567e10362a68e5bf42d1cd8267d5ca.tar.xz
forgejo-api-b2886d9c9e567e10362a68e5bf42d1cd8267d5ca.zip
fix: only wrap return values in `Option` once
-rw-r--r--generator/src/methods.rs12
1 files changed, 8 insertions, 4 deletions
diff --git a/generator/src/methods.rs b/generator/src/methods.rs
index 8039f96..93d5f57 100644
--- a/generator/src/methods.rs
+++ b/generator/src/methods.rs
@@ -555,14 +555,18 @@ impl ResponseType {
fn merge(self, other: Self) -> eyre::Result<Self> {
let headers = match (self.headers, other.headers) {
(Some(a), Some(b)) if a != b => eyre::bail!("incompatible header types in response"),
- (Some(a), None) => Some(format!("Option<{a}>")),
- (None, Some(b)) => Some(format!("Option<{b}>")),
+ (Some(a), None) if !a.starts_with("Option<") => Some(format!("Option<{a}>")),
+ (None, Some(b)) if !b.starts_with("Option<") => Some(format!("Option<{b}>")),
(a, b) => a.or(b),
};
let body = match (self.body.as_deref(), other.body.as_deref()) {
(Some(a), Some(b)) if a != b => eyre::bail!("incompatible header types in response"),
- (Some(a), Some("()") | None) => Some(format!("Option<{a}>")),
- (Some("()") | None, Some(b)) => Some(format!("Option<{b}>")),
+ (Some(a), Some("()") | None) if !a.starts_with("Option<") => {
+ Some(format!("Option<{a}>"))
+ }
+ (Some("()") | None, Some(b)) if !b.starts_with("Option<") => {
+ Some(format!("Option<{b}>"))
+ }
(_, _) => self.body.or(other.body),
};
use ResponseKind::*;