swagger-jsdoc
을 사용 중입니다. 모든게 잘 보입니다. 그리고 라이브 URL을 사용할 때 localhost
을 사용할 때까지 json을 얻고 있습니다. 즉, 경로 키에 아무 것도주지 못합니다.배포 할 때 비어있는 경로를 키로 가져옵니다. 로컬 작동 중
{
"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":[]
}
이것이 내가 생방송으로 얻는 것입니다. 동일한 코드 config.swaggerDefinition
에서 호스트 옵션에 문제가있을 수 있습니다 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);
});
localhost에'/ etc/hosts' 항목을 추가하고 새 항목을 사용하여 액세스하려고해도이 경우입니까? – swapnilsm
심지어 나는 똑같은 문제에 직면하고있다. 지역의 모든 것이 괜찮지 만, 벌거 벗은 골격 인 json을 살 때 갈 것이다. 희망이 문제를 해결할 수 있습니다. 그렇다면 도움을주십시오. –