You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In this, to get example mentioned in addGlobalParameters in generated specs, you need to use it like below:
Option-1
If you do not want schema in globalParameter then remove this object and use example only as below.
constconfig=newDocumentBuilder().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();
Option-2
If you wish to use schema, then remove example property from parent and use it under schema object, like below:
constconfig=newDocumentBuilder().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
The text was updated successfully, but these errors were encountered: