olivierlsc / swagger-express-ts

Generate and serve swagger.json
MIT License
147 stars 60 forks source link

Headers #60

Open Ankit1995-appinventiv opened 4 years ago

Ankit1995-appinventiv commented 4 years ago

How can i accept headers like device token.

thinkingmik commented 3 years ago

With swagger-express-ts:v1.1.0 you can now specify headers params

  @ApiOperationGet({
        path: `/mypath/{name}`,
        summary: 'Execute a custom view',
        parameters: {
            header: {
                'x-device-token': {
                    description: 'The device token',
                    type: SwaggerDefinitionConstant.Parameter.Type.STRING,
                    required: true,
                },
            },
            path: {
                name: {
                    description: 'The view name',
                    type: SwaggerDefinitionConstant.Parameter.Type.STRING,
                    required: true,
                },
            },
        },
        responses: {
            200: {
                description: 'Success',
                type: SwaggerDefinitionConstant.Response.Type.OBJECT,
            }
        }
    })