-
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
Add support for CreateSchemaReferenceId option #56753
Conversation
Co-authored-by: Martin Costello <martin@martincostello.com>
schema.ApplyPrimitiveTypesAndFormats(context); | ||
schema.ApplySchemaReferenceId(context); | ||
schema.ApplyPolymorphismOptions(context); | ||
var createSchemaReferenceId = optionsMonitor.Get(documentName).CreateSchemaReferenceId; |
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.
Use _openApiOptions
?
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.
_openApiOptions
is an instance field so we can't use it in the initializer for _confguration
. I could switch to standard constructors instead of primary constructors and initialize everything there but.... 😅 🤪
Closes #56305.
This PR adds support for a
CreateSchemaReferenceId
property in theOpenApiOptions
to support customizing how reference IDs are generated for schemas assocaited with a given type. Because of the behavior of the reference ID implementation, this function also serves as a mechanism for being able to determine whther or not a schema should be inline or referenced:CreateSchemaReferenceId
delegate that returnsnull
for a given type will mean that schemas associated with that type are always inlineCreateSchemaReferenceId
delegate that returns a value for a given type will mean that schemas assocaited with that type will always be referencedChanges in this PR include:
CreateSchemaReferenceId
property to options object andCreateDefaultSchemaReferenceId
static to provide users with access to the default implementationCreateSchemaReferenceId
from options in all codepaths where it is currently relevant