Replies: 1 comment
-
|
You could implement a filter to post-process the schema to make the edits you require. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have a DTO class defined as follows:
My goal is to maintain both the [Required] validation attribute (per project requirements) and the nullable property types in the generated OpenAPI/Swagger schema using Swashbuckle.
Currently, Swashbuckle produces the following output for this class:
However, I need the schema to reflect the fact that these properties are nullable (for example, to indicate nullable: true), while retaining the required attribute for validation.
I understand that [Required] is typically not recommended with nullable types, but due to project constraints, I cannot change this approach.
Is there an option or workaround in Swashbuckle to generate a schema that marks properties as both required and nullable, or otherwise accurately represents this scenario?
I have tried reviewing the schema generation options and experimenting with custom schema filters, but haven’t found a suitable solution so far.
Any insight or recommended approach would be greatly appreciated!
Beta Was this translation helpful? Give feedback.
All reactions