-
Notifications
You must be signed in to change notification settings - Fork 10.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix up nullability and primitive type handing in schema generation #56372
Conversation
@@ -11,6 +11,21 @@ namespace Microsoft.AspNetCore.OpenApi; | |||
|
|||
internal static class JsonTypeInfoExtensions | |||
{ | |||
private static readonly List<Type> _exemptPrimitives = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these from an OpenAPI spec? Otherwise there are probably other primitives, e.g. nint
, byte
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added these and a few more other primitive types. Lemme know what you think of the list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any of Guid
, Uri
, TimeSpan
, DateOnly
and TimeOnly
? Just comparing to the list we have in Swashbuckle and they're the only ones that are different to this set. They basically end up as a string
with a format
of some kind in the schema.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, yes! I recall you sharing this in the other PR. I've updated this set so it's consistent between the two. I wasn't able to find the logic in NSwag for this but this probably a set that we should be consist with throughout the implementations. 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd forgotten about Version
😄
Did you want TimeSpan
too, or was there a reason to skip that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yet another reason to make this public 😓 Added that as well. Let me know if there is anything else I missed. I'd like to get this PR in soon to ease some of the build failures it is causing but happy to add things in a follow-up PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new set seems to cover all the common primitives/cases I'm aware of 👍
cc14932
to
d596b7a
Compare
d596b7a
to
ca073bf
Compare
IsGetNullable
andIsSetNullable
properties to set nullability status for propertiesNullabilityInfoContext
instead of shared static instance?
character in reference ID for nullable schemasobject
schemas to close object property causes build crash when generating OpenAPI document at build time #56351Addresses feedback from #56330 (comment) and #56318