规范中未定义任何操作! ---无法定义定义--- node.ts,swaggerUI

问题描述 投票:0回答:1

Below is code for setting up my swagger which is in main.ts file

const swaggerOptions={
    swaggerDefinition:{
        info:{
            title:'Data Api',
            version:'1.0.1',
            description:'ToDo API',

            host:'localhost:7000',
            basePath:'/'
        }
    },
    apis:['./routes/product.route.ts'][enter image description here][1]
};
const swaggerdocs=swaggerjsdoc(swaggerOptions);
app.get('/swagger.json',(req:Request,res:Response)=>{
    res.setHeader('Content-Type','application/json');
    res.send(swaggerdocs);
});

app.use('/api-docs',swaggeruiexpress.serve,swaggeruiexpress.setup(swaggerdocs));

并且我正在'./routes/product.route.ts'文件中定义以下定义,该文件必须显示在swagger UI中,但问题仍然存在,我所能看到的是“规范中未定义任何操作“。

/**
 * @swagger
 * /getAllItems:
 *   get:
 *     summary: List all the Objects
 *     description: Returns a list of all the user names
 *     tags:
 *       - Values
 *     parameters:
 *      name: 
 *             type:string
 *         _id: 
 *              type:string
 *     produces:
 *       - application/json
 *     responses:
 *       200:
 *         description: Successful
 *          400:
 *          description: Bad Request..Try again later
 *          _id:
 *                 type: string
 *          name:
 *              type:string
 */
node.js rest swagger swagger-ui openapi
1个回答
0
投票
它起作用了...!由于API附近的命名约定不明显:'./ routes / products.route.ts'
© www.soinside.com 2019 - 2024. All rights reserved.