We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
需求:为了符合 REST 风格的资源路径,需要同时用到路径参数与 request body,故没有将所有参数放到 request body 中
swagger 接口数据结构: post: { tags: ['RegisteredClient'], summary: '给登录用户在指定客户端下实行授权', operationId: 'grant', parameters: [ { name: 'userName', in: 'path', description: '用户名称', required: true, schema: { type: 'string' } }, { name: 'clientId', in: 'path', description: '客户端编号', required: true, schema: { type: 'string' } }, ], requestBody: { content: { 'application/json': { schema: { type: 'array', description: "授予权限,格式['menu.button']", items: { type: 'string' } }, }, }, required: true, }, responses: { '400': { description: 'Bad Request', content: { '/': { schema: { $ref: '#/components/schemas/GlobalError' } } }, }, '403': { description: 'Forbidden', content: { '/': { schema: { $ref: '#/components/schemas/GlobalError' } } }, }, '500': { description: 'Internal Server Error', content: { '/': { schema: { $ref: '#/components/schemas/GlobalError' } } }, }, '200': { description: 'OK' }, }, }, },
api-lock.json 数据: { "description": "给登录用户在指定客户端下实行授权", "name": "grant", "method": "post", "path": "/users/{userName}/clients/{clientId}/seletedpermissions", "response": { "typeArgs": [], "typeName": "", "isDefsType": false, "templateIndex": -1, "compileTemplateKeyword": "#/definitions/", "enum": [], "typeProperties": [] }, "parameters": [ { "required": true, "in": "body", "name": "requestBody", "dataType": { "typeArgs": [ { "typeArgs": [], "typeName": "string", "isDefsType": false, "templateIndex": -1, "compileTemplateKeyword": "#/definitions/", "enum": [], "typeProperties": [] } ], "typeName": "Array", "isDefsType": false, "templateIndex": -1, "compileTemplateKeyword": "#/definitions/", "enum": [], "typeProperties": [] } } ] }
看了一下源码,parseSwaggerV3Mods() 方法中 有 requestBody 时,进入 if (inter.requestBody) 里边直接覆盖了 inter.parameters = [] 这里是否应该用 inter.parameters.push() 的方式
The text was updated successfully, but these errors were encountered:
+1
Sorry, something went wrong.
d987552
Merge pull request #406 from alibaba/fix/mx/332
9906159
fix: #332 OpenAPI 下,POST 请求,同时存在路径参数与请求体参数时,路径参数丢失
No branches or pull requests
OpenAPI 下,POST 请求,同时存在路径参数与请求体参数时,路径参数丢失
需求:为了符合 REST 风格的资源路径,需要同时用到路径参数与 request body,故没有将所有参数放到 request body 中
swagger 接口数据结构:
post: {
tags: ['RegisteredClient'],
summary: '给登录用户在指定客户端下实行授权',
operationId: 'grant',
parameters: [
{ name: 'userName', in: 'path', description: '用户名称', required: true, schema: { type: 'string' } },
{ name: 'clientId', in: 'path', description: '客户端编号', required: true, schema: { type: 'string' } },
],
requestBody: {
content: {
'application/json': {
schema: { type: 'array', description: "授予权限,格式['menu.button']", items: { type: 'string' } },
},
},
required: true,
},
responses: {
'400': {
description: 'Bad Request',
content: { '/': { schema: { $ref: '#/components/schemas/GlobalError' } } },
},
'403': {
description: 'Forbidden',
content: { '/': { schema: { $ref: '#/components/schemas/GlobalError' } } },
},
'500': {
description: 'Internal Server Error',
content: { '/': { schema: { $ref: '#/components/schemas/GlobalError' } } },
},
'200': { description: 'OK' },
},
},
},
api-lock.json 数据:
{
"description": "给登录用户在指定客户端下实行授权",
"name": "grant",
"method": "post",
"path": "/users/{userName}/clients/{clientId}/seletedpermissions",
"response": {
"typeArgs": [],
"typeName": "",
"isDefsType": false,
"templateIndex": -1,
"compileTemplateKeyword": "#/definitions/",
"enum": [],
"typeProperties": []
},
"parameters": [
{
"required": true,
"in": "body",
"name": "requestBody",
"dataType": {
"typeArgs": [
{
"typeArgs": [],
"typeName": "string",
"isDefsType": false,
"templateIndex": -1,
"compileTemplateKeyword": "#/definitions/",
"enum": [],
"typeProperties": []
}
],
"typeName": "Array",
"isDefsType": false,
"templateIndex": -1,
"compileTemplateKeyword": "#/definitions/",
"enum": [],
"typeProperties": []
}
}
]
}
看了一下源码,parseSwaggerV3Mods() 方法中
有 requestBody 时,进入 if (inter.requestBody)
里边直接覆盖了 inter.parameters = []
这里是否应该用 inter.parameters.push() 的方式
Context(上下文)
The text was updated successfully, but these errors were encountered: