Reputation: 814
Chrome gets a 200 response with the expect data. But swagger is not displaying the result.
Swagger Options:
swaggerOptions = {
openapi: '3.0.0',
swaggerDefinition : {
info: {
title: 'Admin API',
description: 'Admin API integration',
version: "1.0",
contact: {
name: 'Vinicius A. Da Silva'
},
servers: [
'http://localhost:3000'
]
},
produces: ["application/json"],
securityDefinitions: {
bearerAuth: {
type: 'apiKey',
name: 'Authorization',
scheme: 'bearer',
in: 'header',
bearerFormat: 'JWT',
},
},
security: [ { bearerAuth: [] } ],
},
apis: [__dirname+'/controller/*.js']
}
Jsdoc comment:
/**
* @swagger
* /api/list?mdl={mdl}:
* security:
* - Bearer: []
* get:
* description: Returns all users
* responses:
* '200':
* description: Successfully returned paginated records
* '403':
* description: Not enough permissions read_modelName
* parameters:
* - name: mdl
* in: query
* description: Model name
* required: true
* schema:
* type: string
* format: string
* responses:
* '200':
* description: Successfully inserted a user
* content:
* 'application/json':
* schema:
* type: object
* description: test response
* '403':
* description: Not enough permissions
*/
Image:
The response ui part of it, is not displaying. Even though Chrome is getting 200 http response and the response data.
SOLUTION:
The responses property must be within the http related method.
/**
* @swagger
* /api/list?mdl={mdl}:
* security:
* - Bearer: []
* get:
* description: Returns all users
* responses:
* '200':
* description: Successfully returned paginated records
* '403':
* description: Not enough permissions read_modelName
* parameters:
* - name: mdl
* in: query
* description: Model name
* required: true
* schema:
* type: string
* format: string
*/
Upvotes: 1
Views: 2563
Reputation: 2565
That is happening because the format of your JSdoc comment is wrong. There should be a tab space in the next line after responses
key that you declared first so it should be like this.
/**
* @swagger
* /api/list?mdl={mdl}:
* security:
* - Bearer: []
* get:
* description: Returns all users
* responses:
* '200':
* description: Successfully returned paginated records
* '403':
* description: Not enough permissions read_modelName
* parameters:
* - name: mdl
* in: query
* description: Model name
* required: true
* schema:
* type: string
* format: string
* responses:
* '200':
* description: Successfully inserted a user
* content:
* 'application/json':
* schema:
* type: object
* description: test response
* '403':
* description: Not enough permissions
*/
Upvotes: 4