我开始使用 swagger 和swagger-ui-express和swagger-jsdoc来自动记录我现有的 API,它是用nodejs和 express编写的(就像这里描述的一样 -示例)。
当我尝试在我的注释上添加一个$ref现有的JSON 模式文件(它与我的所有 js 文件位于我的项目中的同一目录中)时遇到了一个问题。
我尝试编写本地路径 ( ./schema.json) 和绝对路径,尝试使用#,使用了许多语法,但没有任何效果。
我的注释是这样的:
/**
 * @swagger
 * /testing:
 *    get:
 *      description: This should show the json schema
 *      responses:
 *          200:
 *              description: "successful operation"
 *              schema:
 *                 $ref: "./schema.json"
 */
我希望 swagger ui 在我的请求部分向我显示 JSON 模式。我收到以下错误 -
Resolver error at paths./testing.get.responses.200.schema.$ref
Could not resolve reference: Tried to resolve a relative …