Closed am-burban closed 3 weeks ago
Would you like to create a PR for this issue?
@am-burban I tried updating to new version and found below things which you need to update.
Let's take example that you shared: https://gist.github.com/am-burban/5de53ea95c327896d297a26371fa7940
In this, to get example mentioned in addGlobalParameters
in generated specs, you need to use it like below:
schema
in globalParameter
then remove this object and use example
only as below.const config = new DocumentBuilder()
.setTitle('API Gateway')
.setVersion(API_SPEC_VERSION)
.addGlobalParameters(
{
in: 'header',
required: false,
name: REQUEST_ID_HEADER_NAME,
description: 'Request ID used for debugging and tracing.',
example: '5997c5f0-f9a6-4fdc-a4c3-53b850acca28',
}
)
.build();
schema
, then remove example
property from parent and use it under schema
object, like below:const config = new DocumentBuilder()
.setTitle('API Gateway')
.setVersion(API_SPEC_VERSION)
.addGlobalParameters(
{
in: 'header',
required: false,
name: REQUEST_ID_HEADER_NAME,
description: 'Request ID used for debugging and tracing.',
schema: { type: 'string', minLength: 1, maxLength: 100, example: '5997c5f0-f9a6-4fdc-a4c3-53b850acca28' },
}
)
.build();
Please try this, hope it solves your issue. I tried and both ways its working.
Is there an existing issue for this?
Current behavior
When adding a global parameter with an example, the example is not carried over to the generated spec (see Gist).
Probably related to #3031
Minimum reproduction code
https://gist.github.com/am-burban/5de53ea95c327896d297a26371fa7940
Steps to reproduce
No response
Expected behavior
Example is added to the generated spec
Package version
7.4.2
NestJS version
10.4.3
Node.js version
18.20.2
In which operating systems have you tested?
Other
No response