We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
default
schema.$ref
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
I have gone through #2898 and #1041
My code looks like this
export enum LogsSearchOperatorType { EQUAL = 'equal', NOT_EQUAL = 'not_equal', } export class GetApplicationLogsQuery { ... @ApiPropertyOptional({ enum: LogsSearchOperatorType, enumName: 'LogsSearchOperatorType', default: LogsSearchOperatorType.EQUAL, enumSchema: { description: 'Comparison operator logs search', }, description: 'Comparison operator for filter. `equal` or `not_equal`', }) @IsOptional() searchOperator?: LogsSearchOperatorType = LogsSearchOperatorType.EQUAL; }
GetApplicationLogsQuery is used as query params in a route.
GetApplicationLogsQuery
My goal is to have a default on this enum in this specific context.
While enumSchema has a field default, I do not want to declare the default there because this enum is shared across multiple places.
enumSchema
OAS 3.1.0 now allows default in schema as sibling of $ref
schema
$ref
but nestjs/swagger removes all such fields in here:
swagger/lib/services/swagger-types-mapper.ts
Line 44 in f2444df
And I get
{ "name": "searchOperator", "required": false, "in": "query", "description": "Comparison operator for filter. `equal` or `not_equal`", "schema": { "$ref": "#/components/schemas/LogsSearchOperatorType" } }
Example OAS 3.1 spec that can be tried at https://editor-next.swagger.io/
openapi: "3.1.0" info: title: Enum default version: '0.1.0' paths: /products: get: parameters: - in: query name: color required: false schema: $ref: "#/components/schemas/Color" default: "black" responses: "200": description: OK components: schemas: Color: type: string enum: - black - white - red - green - blue
Take the default from @ApiProperty and place it in schema
@ApiProperty
No response
Correct defaults for downstream docs and SDK generation
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Is there an existing issue that is already proposing this?
Is your feature request related to a problem? Please describe it
I have gone through #2898 and #1041
My code looks like this
GetApplicationLogsQuery
is used as query params in a route.My goal is to have a default on this enum in this specific context.
While
enumSchema
has a fielddefault
, I do not want to declare the default there because this enum is shared across multiple places.OAS 3.1.0 now allows
default
inschema
as sibling of$ref
but nestjs/swagger removes all such fields in here:
swagger/lib/services/swagger-types-mapper.ts
Line 44 in f2444df
And I get
Example OAS 3.1 spec that can be tried at https://editor-next.swagger.io/
Describe the solution you'd like
Take the
default
from@ApiProperty
and place it inschema
Teachability, documentation, adoption, migration strategy
No response
What is the motivation / use case for changing the behavior?
Correct defaults for downstream docs and SDK generation
The text was updated successfully, but these errors were encountered: