Parse inline endpoint response schemas - #542
Conversation
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>
Anonymous inline schemas were named Type1, Type2, ... without checking
the names already taken by the spec's definitions and responses, so a
valid spec defining a type called "Type1" alongside an inline object
schema generated two `type Type1` declarations and failed to compile
with FS0037. The anonymous-name counter now starts past any sanitised
definition/response name of the form Type{N}.
Verified at the level the repo's generators are tested at: the new
swagger-anonymous-types.json in ConsumePlugin defines "Type1" plus an
inline object response, so a regression here fails the build. (An
in-process generate test isn't currently possible: WoofWare.Expect
forces Fantomas.FCS 7.0.3 in the test project, which is binary-
incompatible with the Fantomas.FCS 6.1.1 that WoofWare.Whippet.Fantomas
0.7.3 was compiled against, so calling the generator's AST construction
from the test host throws MissingMethodException.)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Fixed in 57a533c. The anonymous-name counter now starts past any sanitised definition/response name of the form Verified at the level this repo tests generators: The fix has been merged forward through the rest of the stack (#543–#546); each branch rebuilt and passed its full suite. |
Seeding the anonymous-name counter to the largest spec-defined Type{N}
overflows on a valid schema named Type2147483647: the next
Interlocked.Increment wraps to Int32.MinValue and produces a type
declared (sanitised) as Type2147483648 but referenced as
Type-2147483648, failing with FS0010. Instead of seeding, the allocator
now skips over a set of taken (sanitised) definition/response names, so
no name can push the counter anywhere near overflow.
The ConsumePlugin regression spec now also defines Type2147483647
(structurally distinct from Type1, since identical shapes are collapsed
into one generated type), so both the collision and the overflow fail
the build if reintroduced.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Fixed in a196b18. Confirmed the overflow: a definition named As suggested, the seeding scheme is gone:
|
Splits out the first of six fixes from #540 (stack: this ← #543 ← #544 ← #545 ← #546; see also the independent capturing-mock fix).
Endpoint responses fed the whole Response Object to
Definition.Parse, so an inline{description, schema}response has neither$refnor a top-leveltypeand degraded toDefinition.Unspecified, generatingTask<unit>clients that silently discard the body. Responses now go throughResponse.Parse(moved aboveSwaggerEndpoint) and use its schema;$refresponses are handled as before.Making those schemas parse exposed a second gap: inline schemas under
pathswere never fed throughdefnToType, sorenderTypecrashed on anonymous inline objects. Endpoint response and parameter schemas are now seeded into type generation (with no handle name); previously, inline parameter types only rendered when they happened to collide with an identically-shaped named definition in the cache.Gitea's
/users/search,/orgs/{org}/teams/search, and the twosigning-key.gpgendpoints now return real types (Type9/Type10/string) instead ofTask<unit>.Test was written first and observed failing: the inline 200 response parsed as
Unspecified.🤖 Generated with Claude Code