Я пытаюсь настроить чванство, но я сталкиваюсь с ошибкой
Resolver error at paths./projects.post.parameters.0.schema.$ref
Could not resolve reference: #/models/Projects
Ниже приведен код моего проекта routs / projects.js const Projects = require ("../ models") .Projects;
module.exports = (app) => {
/**
* @swagger
* /projects:
* post:
* tags:
* - Projects
* name: Create Project
* summary: Create Project
* consumes:
* - application/json
* parameters:
* - name: body
* in: body
* schema:
* $ref: '#/models/Projects'
* type: object
* properties:
* authorFirstName:
* type: string
* authorLastName:
* type: string
* responses:
* 200:
* description: Project add successfully
*/
app.post("/projects", (req, res) => {});
};
models / Projects.js
"use strict";
module.exports = (sequelize, DataTypes) => {
const Projects = sequelize.define("Projects", {
authorFirstName: DataTypes.STRING,
authorLastName: DataTypes.STRING
});
return Projects;
};
Это тестовый проект для настройки чванства.Я использую node.js express и sequelize
Вот чванство
var swaggerDefinition = {
info: {
title: "TETS MySQL api",
version: "1.0.0",
description: "Endpotions"
},
host: "localhost:4000",
basePath: "/",
securityDefinitions: {
bearerAuth: {
type: "apiKey",
name: "Authorization",
schema: "bearer",
in: "header"
}
}
};
const options = {
swaggerDefinition,
apis: ["./routes/*.js"]
};
const swaggerSpec = swaggerJSDoc(options);
app.get("/swagger.json", function(req, res) {
res.setHeader("Content-Type", "application/json");
res.send(swaggerSpec);
});
app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(swaggerSpec));