Closed martincostello closed 1 month ago
Having tests things out with another app, I think actually this is more of a general issue with how arrays are handled.
I've tried out the latest bits with an internal app, and seeing a similar effect with objects that contain an array of objects. The schemas are included below.
Essentially, instead of each schema containing a property that is an array of another schema, instead each schema contains a property containing another schema, which is an array of an inlined schema.
It might be that actually this has some overlap #56990.
Having worked around #56975 I got the result I expected without this issue for my snapshot test, but then when run with other tests, the schema started adding the Arrayofstring*
schemas, causing the snapshot test to fail.
However with this app, the same wasn't true: https://github.com/dotnet/aspnetcore/issues/56919#issuecomment-2242692828
@martincostello I assume this doesn't repro following https://github.com/dotnet/aspnetcore/pull/56980?
I'll manually update something to RC1 and check it out - my automated process targets the next preview due, so it won't be pulling in any fixes that haven't been backported until after preview 7 ships.
@captainsafia Yep, looks good now!
Here's the diff for the snapshot from preview 6: https://github.com/martincostello/alexa-london-travel-site/commit/c5706031a183ea991265e709b51d90913d9f907a
Is there an existing issue for this?
Describe the bug
Using the latest bits out for Microsoft.AspNetCore.OpenApi (
9.0.0-preview.7.24369.10
), there's some odd looking behaviour for array properties of schemas when their property has an associated description that causes them to be created as their own schemas when they are otherwise only used once and could (should?) in inlined to the schema they are present in.For comparison, below is a diff of the existing NSwag schema and the OpenAPI version for the
components
of the document (I've hand edited for the sake of clarity to remove unimportant differences):The two array properties are essentially the same (a simple array of strings), but because they have different descriptions, they've been lifted out to an inline array. This behaviour seems strange to me, it seems more intuitive for them to have instead be left defined inline in their associated schemas.
Expected Behavior
Either:
ArrayOfstring
schema that is reused, with the descriptions left next to the references (I'm not sure if this is valid OpenAPI v3 though).Steps To Reproduce
https://localhost:50001/openapi/api.json
Exceptions (if any)
None.
.NET Version
9.0.100-preview.7.24371.2
Anything else?
No response