I use swagger-jsdoc. Everything seems fine, and I get json until I use it localhost, when I use a live URL, it gives me nothing in the path keys, i.e.
{
"info": {
"title": "App API",
"version":"0.0.0",
"description":"Server API documentation"
},
"host":"something.com",
"basePath":"/",
"schemes":["https"],
"swagger":"2.0",
"paths":{},
"definitions":{},
"responses":{},
"parameters":{},
"securityDefinitions":{},
"tags":[]
}
This is what I get live. The same code works with localhost/swagger.json, but not withhttps://something.com/swagger.json
var swaggerJSDoc = require('swagger-jsdoc');
var swaggerOptions = {
swaggerDefinition: config.swaggerDefinition || {
info: {
title: 'Hello World',
version: '1.0.0',
description: 'A sample API',
},
host: 'localhost:3000',
basePath: '/',
},
apis: ['./routes/*.js'],
};
var swaggerSpec = swaggerJSDoc(swaggerOptions);
router.get('/swagger.json', function(req, res) {
res.setHeader('Content-Type', 'application/json');
res.send(swaggerSpec);
});