Closed bhargavtenali closed 1 year ago
Hi,
I was migrating from swagger-express-mw to express-openapi in Express Node js based backend Application
Previously we are using swagger 2.0 doc
swagger.yml file:
/publications/latest: x-swagger-router-controller: publication get: security: - JWScopeSecurity: ['user'] summary: Get latest publications operationId: getLatestPublications tags: - publication parameters: - in: query name: size default: 10 minimum: 0 maximum: 3000 required: true description: Number of results. type: number - in: query name: product required: false description: Use to filter on a specific product. Expecting product id type: array items: type: string collectionFormat: csv responses: 403: *response403 404: *response404 500: *response500 200: description: OK schema: type: array items: $ref: '#/definitions/Publication'
app.js file:
initialize({ app: app, apiDoc: "./api/swagger/swagger.yaml", securityHandlers: { securityHandlers }, operations: { ...allOperations as key value pairs } });
Operation definition:
const getLatestPublications = async (req, res) => { try { let product = req.swagger.params.product?.value const size = req.swagger.params.size?.value // some opertion code
Here in above code how can i access the query params correctly as per swagger.yml I tried accessing them with req.query but they were coming as string instead of array (as mentioned in yml file)
Thanks in advance
Duplicate to #886 By mistake issue got posted twice
Duplicate to https://github.com/kogosoftwarellc/open-api/issues/886 By mistake issue got posted twice
Hi,
I was migrating from swagger-express-mw to express-openapi in Express Node js based backend Application
Previously we are using swagger 2.0 doc
swagger.yml file:
app.js file:
Operation definition:
Here in above code how can i access the query params correctly as per swagger.yml I tried accessing them with req.query but they were coming as string instead of array (as mentioned in yml file)
Thanks in advance