私は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":[]
}
これは私がライブで取得しているものです。同じコードが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);
});
localhostに '/ etc/hosts'エントリを追加して新しいエントリを使ってアクセスしようとした場合でもそうでしょうか? – swapnilsm
私は同じ問題に直面していても、ローカルのものはすべて問題ありません。この問題を解決したいと考えています。はいの場合は、助けてください。 –