Forum Discussion

MenschenToaster's avatar
MenschenToaster
New Member
5 years ago

request operation openapi3

Does anyone know how to do req.swagger.operation in openapi 3?
i generated the server in nodejs with editor.swagger.io
  • Hi MenschenToaster 

     

    The openapi3 code generated for nodejs is not longer using swagger-tool lib (the one that set swagger object into a req object), because the project does not support OAS3. So, the nodejs code is actually working with https://github.com/cdimascio/express-openapi-validator

     

    and you can retrieve info from request object calling an openapi object, something like: req.openapi

    Here is an example of the openapi object inside a request object:

     

     

    openapi: {
        expressRoute: '/pet/findByStatus',
        openApiRoute: '/pet/findByStatus',
        pathParams: {},
        schema: {
            tags: [Array],
            summary: 'Finds Pets by status',
            description: 'Multiple status values can be provided with comma separated strings',
            operationId: 'findPetsByStatus',
            parameters: [Array],
            responses: [Object],
            security: [Array],
            'x-swagger-router-controller': 'Pet'
        }
    }