Hello I am creating API doc for my node API using swagger but my screen doesn't show any end point my code is as below:
in app.js:
const swaggerJsonDoc = require('swagger-jsdoc')
const swaggerUI = require('swagger-ui-express')
const apiDoc = require('./swagger-doc/api-doc.json')
const swaggerOptions = {
swaggerDefinition: {
info: {
title: "API's Document",
version: "1.0.0.1",
description: "This document will walk you through all the API end points in swagger",
},
servers: [{
url: "http://localhost:3000"
}]
},
apis: ['./swagger-doc/api-doc.json']
}
const swaggerDocs = swaggerJsonDoc(swaggerOptions)
app.use('/api-docs', swaggerUI.serve, swaggerUI.setup(swaggerDocs))
And my api-doc.json is as below:
{
"swagger": "2.0",
"host": "localhost:3000",
"basePath": "/api",
"schemes": [
"http"
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"paths": {
"/login": {
"post": {
"summary": "Login",
"tags": [
"Misc"
],
"operationId": "Login",
"deprecated": false,
"produces": [
"application/json"
],
"parameters": [
{
"name": "Body",
"in": "body",
"required": true,
"description": "",
"schema": {
"$ref": "#/definitions/LoginRequest"
}
}
],
"responses": {
"200": {
"description": "",
"headers": {}
}
}
}
}
},
"definitions": {
"LoginRequest": {
"title": "LoginRequest",
"example": {
"Email": "abc@xyz.com",
"Password": "abc@123"
},
"type": "object",
"properties": {
"Email": {
"type": "string"
},
"Password": {
"type": "string"
}
},
"required": [
"Email",
"Password"
]
}
},
"tags": [
{
"name": "Misc",
"description": ""
}
]
}
I am getting output as : blank with Swagger info only with
No operations defined in spec!
Please help me to find out what exactly I am missing here or should I process with something else.