将查询对象转换为多查询参数 Swagger

Convert a query object into multi query parameter Swagger

提问人:Az Emna 提问时间:10/10/2023 更新时间:10/10/2023 访问量:20

问:

我正在使用 joi-to-swagger 包为我的 api 生成文档,并且我正在尝试将查询对象中的查询参数显示为单个查询参数。

这是我的 Joi 对象

export const leaveEstimatedBalance = {
params: Joi.object({
    uuidSalarie: Joi.string().required(),
    uuidSociete: Joi.string().required(),
}),
query: Joi.object({
    limitByEstimationMonth: Joi.boolean().required(),
    month: Joi.number().integer().max(11).required(),
    newRequestedCurrentLeaves: Joi.number(),
    newRequestedEarnedLeaves: Joi.number(),
    year: Joi.number().required()
})

};

这就是我在 Swagger 模式中使用它的方式:

   '/leave-request/{uuidSalarie}/{uuidSociete}/estimatedBalance': {
        get: {

            "parameters": [{
                description: "Employee uuid",
                in: "path",
                name: "uuidSalarie",
                required: true,
                type: 'string'
            },
            {
                description: "Employer uuid",
                in: "path",
                name: "uuidSociete",
                required: true,
                type: 'string'
            },
            {
                "in": "query",
                "name": "query",
                "schema":j2s(leaveEstimatedBalance.query).swagger;,     

            }
            ],
           
            summary: "get leave summary for an employee within a specific employer",
            tags: ["Leave request"],
        },
    }

但我得到的只是我在 JSON 对象中的架构示例

enter image description here

请提供任何帮助

节点 .js 快速 招摇 openapi joi

评论


答: 暂无答案