feat(swagger-plugin): add skipDefaultValues option to omit unspecified default fields and corresponding test #3423
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
When using @ApiProperty({ enum: SubjectEnum, enumName: 'Subject' }) readonly caslSubjectType: SubjectEnum = this.constructor.name as SubjectEnum;, the generated OpenAPI schema always includes:
There is no built-in way to omit that default unless you explicitly set default: null.
Issue Number: #3338
What is the new behavior?
Introduce a skipDefaultValues option on the Swagger plugin.
Default: skipDefaultValues: false (existing behavior)
When enabled: any property without an explicit default initializer will not have a default field in the schema.
Example – with skipDefaultValues: true:
Does this PR introduce a breaking change?
Other information
Docs will be added upon positive review and merge of this PR.