Reusable Headers for swagger documentation using swaggerjsdoc.
Hi, I need to document my apis written in node js and I am using swaggerjsdoc and swagger express ui. I have about 11 different headers like deviceID, location etc and they will be used in 40,50 different requests, so instead of duplicating them in different request I want to use components section for reusability and want to use $ref for once so that it can get all the headers from components section. although it works but it returns one header object where I can put values Instead I want swaggerUi to show different string values for headers like shown in figure
Below is my code snippet
/**
* @swagger
* components:
* parameters:
* headersArray:
* in: header
* name: headers
* description: Array of headers
* required: true
* schema:
* type: object
* properties:
* ipaddress:
* type: string
* description: Client IP Address
* example: 192.168.0.1
* location:
* type: string
* description: User location
* example: New York
*/
/**
* @swagger
* tags:
* name: Posts
* description: posts of users
*/
/**
* @swagger
* paths:
* /your-endpoint:
* post:
* summary: Example POST endpoint
* description: Example endpoint that requires headers
* requestBody:
* required: true
* content:
* application/json:
* schema:
* type: object
* properties:
* exampleProperty:
* type: string
* responses:
* '200':
* description: Success response
* parameters:
* - $ref: '#/components/parameters/headersArray'
*/