在部署时获得空path的关键。 本地正在工作

我正在使用swagger-jsdoc 。 一切似乎都很好,我得到的JSON,直到我使用localhost ,当我使用实时url,它没有给我什么path键即。

 { "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":[] } 

这就是我现场直播的内容。 相同的代码在localhost/swagger.json上工作,但不在https://something.com/swagger.json

 var swaggerJSDoc = require('swagger-jsdoc'); var swaggerOptions = { swaggerDefinition: config.swaggerDefinition || { info: { // API informations (required) title: 'Hello World', // Title (required) version: '1.0.0', // Version (required) description: 'A sample API', // Description (optional) }, host: 'localhost:3000', // Host (optional) basePath: '/', // Base path (optional) }, apis: ['./routes/*.js'], // Path to the API docs }; var swaggerSpec = swaggerJSDoc(swaggerOptions); router.get('/swagger.json', function(req, res) { res.setHeader('Content-Type', 'application/json'); res.send(swaggerSpec); }); 

config.swaggerDefinition ,您的主机选项可能会出现问题。 它是否设置为正确的域?