Skip to content
New issue

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

parameters from Swagger 2.0 (openapi 2.0) YAML file are not caught by express-openapi #886

Open
bhargavtenali opened this issue Sep 20, 2023 · 0 comments

Comments

@bhargavtenali
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant