Skip to content

Commit 140b508

Browse files
Smaug123claude
andcommitted
Parse inline endpoint response schemas
Endpoint responses fed the whole Response Object to Definition.Parse, so an inline {description, schema} response has neither $ref nor a top-level type and degraded to Definition.Unspecified, generating Task<unit> clients that discard the body. Responses now go through Response.Parse (moved above SwaggerEndpoint) and use its schema; $ref responses are handled as before. Inline endpoint schemas (both responses and parameters) are also now seeded into type generation, so anonymous inline object schemas get generated types instead of crashing renderType; previously, inline parameter types only rendered when they happened to collide with a named definition in the cache. Gitea's /users/search, /orgs/{org}/teams/search and the two signing-key.gpg endpoints now return real types. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 039eb3b commit 140b508

5 files changed

Lines changed: 411 additions & 49 deletions

File tree

ConsumePlugin/Generated2SwaggerGitea.fs

Lines changed: 290 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27373,6 +27373,138 @@ module LanguageStatisticsJsonSerializeExtension =
2737327373
)
2737427374

2737527375
node :> _
27376+
namespace Gitea
27377+
27378+
open WoofWare.Myriad.Plugins
27379+
27380+
/// Module containing JSON serializing extension members for the Type9 type
27381+
[<AutoOpen>]
27382+
module Type9JsonSerializeExtension =
27383+
/// Extension methods for JSON parsing
27384+
type Type9 with
27385+
27386+
/// Serialize to a JSON node
27387+
static member toJsonNode (input : Type9) : System.Text.Json.Nodes.JsonNode =
27388+
let node = System.Text.Json.Nodes.JsonObject ()
27389+
27390+
do
27391+
for KeyValue (key, value) in input.AdditionalProperties do
27392+
node.Add (key, id value)
27393+
27394+
node.Add (
27395+
"data",
27396+
(input.Data
27397+
|> (fun field ->
27398+
match field with
27399+
| None -> None
27400+
| Some field ->
27401+
(field
27402+
|> (fun field ->
27403+
let arr = System.Text.Json.Nodes.JsonArray ()
27404+
27405+
for mem in field do
27406+
arr.Add (Team.toJsonNode mem)
27407+
27408+
arr
27409+
))
27410+
:> System.Text.Json.Nodes.JsonNode
27411+
|> Some
27412+
)
27413+
|> Option.toObj)
27414+
)
27415+
27416+
node.Add (
27417+
"ok",
27418+
(input.Ok
27419+
|> (fun field ->
27420+
match field with
27421+
| None -> None
27422+
| Some field ->
27423+
(field
27424+
|> (fun field ->
27425+
let field = System.Text.Json.Nodes.JsonValue.Create<bool> field
27426+
27427+
(match field with
27428+
| null ->
27429+
raise (
27430+
System.ArgumentNullException
27431+
"Expected type bool to be non-null, but received a null value when serialising"
27432+
)
27433+
| field -> field)
27434+
))
27435+
:> System.Text.Json.Nodes.JsonNode
27436+
|> Some
27437+
)
27438+
|> Option.toObj)
27439+
)
27440+
27441+
node :> _
27442+
namespace Gitea
27443+
27444+
open WoofWare.Myriad.Plugins
27445+
27446+
/// Module containing JSON serializing extension members for the Type10 type
27447+
[<AutoOpen>]
27448+
module Type10JsonSerializeExtension =
27449+
/// Extension methods for JSON parsing
27450+
type Type10 with
27451+
27452+
/// Serialize to a JSON node
27453+
static member toJsonNode (input : Type10) : System.Text.Json.Nodes.JsonNode =
27454+
let node = System.Text.Json.Nodes.JsonObject ()
27455+
27456+
do
27457+
for KeyValue (key, value) in input.AdditionalProperties do
27458+
node.Add (key, id value)
27459+
27460+
node.Add (
27461+
"data",
27462+
(input.Data
27463+
|> (fun field ->
27464+
match field with
27465+
| None -> None
27466+
| Some field ->
27467+
(field
27468+
|> (fun field ->
27469+
let arr = System.Text.Json.Nodes.JsonArray ()
27470+
27471+
for mem in field do
27472+
arr.Add (User.toJsonNode mem)
27473+
27474+
arr
27475+
))
27476+
:> System.Text.Json.Nodes.JsonNode
27477+
|> Some
27478+
)
27479+
|> Option.toObj)
27480+
)
27481+
27482+
node.Add (
27483+
"ok",
27484+
(input.Ok
27485+
|> (fun field ->
27486+
match field with
27487+
| None -> None
27488+
| Some field ->
27489+
(field
27490+
|> (fun field ->
27491+
let field = System.Text.Json.Nodes.JsonValue.Create<bool> field
27492+
27493+
(match field with
27494+
| null ->
27495+
raise (
27496+
System.ArgumentNullException
27497+
"Expected type bool to be non-null, but received a null value when serialising"
27498+
)
27499+
| field -> field)
27500+
))
27501+
:> System.Text.Json.Nodes.JsonNode
27502+
|> Some
27503+
)
27504+
|> Option.toObj)
27505+
)
27506+
27507+
node :> _
2737627508

2737727509
namespace Gitea
2737827510

@@ -41543,6 +41675,128 @@ module LanguageStatisticsJsonParseExtension =
4154341675
{
4154441676
AdditionalProperties = arg_0
4154541677
}
41678+
namespace Gitea
41679+
41680+
/// Module containing JSON parsing extension members for the Type9 type
41681+
[<AutoOpen>]
41682+
module Type9JsonParseExtension =
41683+
/// Extension methods for JSON parsing
41684+
type Type9 with
41685+
41686+
/// Parse from a JSON node.
41687+
static member jsonParse (node : System.Text.Json.Nodes.JsonNode) : Type9 =
41688+
let arg_2 =
41689+
match node.["ok"] |> Option.ofObj with
41690+
| None -> None
41691+
| Some v -> v.AsValue().GetValue<System.Boolean> () |> Some
41692+
41693+
let arg_1 =
41694+
match node.["data"] |> Option.ofObj with
41695+
| None -> None
41696+
| Some v ->
41697+
v.AsArray ()
41698+
|> Seq.map (fun elt ->
41699+
(match elt with
41700+
| null ->
41701+
raise (
41702+
System.ArgumentNullException
41703+
"Expected element of array (element type Team) to be non-null, but found a null element"
41704+
)
41705+
| elt -> Team.jsonParse elt)
41706+
)
41707+
|> List.ofSeq
41708+
|> Some
41709+
41710+
let arg_0 =
41711+
let result =
41712+
System.Collections.Generic.Dictionary<string, System.Text.Json.Nodes.JsonNode> ()
41713+
41714+
let node = node.AsObject ()
41715+
41716+
for KeyValue (key, value) in node do
41717+
if key = "data" || key = "ok" then
41718+
()
41719+
else
41720+
result.Add (
41721+
key,
41722+
match node.[key] |> Option.ofObj with
41723+
| None ->
41724+
raise (
41725+
System.Collections.Generic.KeyNotFoundException (
41726+
sprintf "Required key '%s' not found on JSON object" (key)
41727+
)
41728+
)
41729+
| Some node -> node
41730+
)
41731+
41732+
result
41733+
41734+
{
41735+
AdditionalProperties = arg_0
41736+
Data = arg_1
41737+
Ok = arg_2
41738+
}
41739+
namespace Gitea
41740+
41741+
/// Module containing JSON parsing extension members for the Type10 type
41742+
[<AutoOpen>]
41743+
module Type10JsonParseExtension =
41744+
/// Extension methods for JSON parsing
41745+
type Type10 with
41746+
41747+
/// Parse from a JSON node.
41748+
static member jsonParse (node : System.Text.Json.Nodes.JsonNode) : Type10 =
41749+
let arg_2 =
41750+
match node.["ok"] |> Option.ofObj with
41751+
| None -> None
41752+
| Some v -> v.AsValue().GetValue<System.Boolean> () |> Some
41753+
41754+
let arg_1 =
41755+
match node.["data"] |> Option.ofObj with
41756+
| None -> None
41757+
| Some v ->
41758+
v.AsArray ()
41759+
|> Seq.map (fun elt ->
41760+
(match elt with
41761+
| null ->
41762+
raise (
41763+
System.ArgumentNullException
41764+
"Expected element of array (element type User) to be non-null, but found a null element"
41765+
)
41766+
| elt -> User.jsonParse elt)
41767+
)
41768+
|> List.ofSeq
41769+
|> Some
41770+
41771+
let arg_0 =
41772+
let result =
41773+
System.Collections.Generic.Dictionary<string, System.Text.Json.Nodes.JsonNode> ()
41774+
41775+
let node = node.AsObject ()
41776+
41777+
for KeyValue (key, value) in node do
41778+
if key = "data" || key = "ok" then
41779+
()
41780+
else
41781+
result.Add (
41782+
key,
41783+
match node.[key] |> Option.ofObj with
41784+
| None ->
41785+
raise (
41786+
System.Collections.Generic.KeyNotFoundException (
41787+
sprintf "Required key '%s' not found on JSON object" (key)
41788+
)
41789+
)
41790+
| Some node -> node
41791+
)
41792+
41793+
result
41794+
41795+
{
41796+
AdditionalProperties = arg_0
41797+
Data = arg_1
41798+
Ok = arg_2
41799+
}
4154641800

4154741801
namespace Gitea
4154841802

@@ -44765,7 +45019,22 @@ module Gitea =
4476545019
let! response = client.SendAsync (httpMessage, ct) |> Async.AwaitTask
4476645020
let response = response.EnsureSuccessStatusCode ()
4476745021
use response = response
44768-
return ()
45022+
let! responseStream = response.Content.ReadAsStreamAsync ct |> Async.AwaitTask
45023+
45024+
let! jsonNode =
45025+
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
45026+
|> Async.AwaitTask
45027+
45028+
let jsonNode =
45029+
(match jsonNode with
45030+
| null ->
45031+
raise (
45032+
System.ArgumentNullException
45033+
"Response from server was the JSON null object; expected a non-nullable type Type9"
45034+
)
45035+
| jsonNode -> jsonNode)
45036+
45037+
return Type9.jsonParse jsonNode
4476945038
}
4477045039
|> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct))
4477145040

@@ -54663,7 +54932,8 @@ module Gitea =
5466354932
let! response = client.SendAsync (httpMessage, ct) |> Async.AwaitTask
5466454933
let response = response.EnsureSuccessStatusCode ()
5466554934
use response = response
54666-
return ()
54935+
let! responseString = response.Content.ReadAsStringAsync ct |> Async.AwaitTask
54936+
return responseString
5466754937
}
5466854938
|> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct))
5466954939

@@ -56846,7 +57116,8 @@ module Gitea =
5684657116
let! response = client.SendAsync (httpMessage, ct) |> Async.AwaitTask
5684757117
let response = response.EnsureSuccessStatusCode ()
5684857118
use response = response
56849-
return ()
57119+
let! responseString = response.Content.ReadAsStringAsync ct |> Async.AwaitTask
57120+
return responseString
5685057121
}
5685157122
|> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct))
5685257123

@@ -59389,7 +59660,22 @@ module Gitea =
5938959660
let! response = client.SendAsync (httpMessage, ct) |> Async.AwaitTask
5939059661
let response = response.EnsureSuccessStatusCode ()
5939159662
use response = response
59392-
return ()
59663+
let! responseStream = response.Content.ReadAsStreamAsync ct |> Async.AwaitTask
59664+
59665+
let! jsonNode =
59666+
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
59667+
|> Async.AwaitTask
59668+
59669+
let jsonNode =
59670+
(match jsonNode with
59671+
| null ->
59672+
raise (
59673+
System.ArgumentNullException
59674+
"Response from server was the JSON null object; expected a non-nullable type Type10"
59675+
)
59676+
| jsonNode -> jsonNode)
59677+
59678+
return Type10.jsonParse jsonNode
5939359679
}
5939459680
|> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct))
5939559681

0 commit comments

Comments
 (0)