admin管理员组文章数量:1225018
I have an Open API document that I have as the basis of an API that I am exposing through Azure API Management (APIM).
The following shows a snippet of the document that is used when the API is deployed through a terraform devops pipeline:
openapi: 3.0.0
info:
title: my-api
description:
version: "1.0"
...
...
paths:
/my-api/{some_id}:
get:
......
operationId: get-stuff
parameters:
- name: scope
in: query
description: The scope that the request for details is being made in
required: true
style: form
explode: true
schema:
type: string
example: owner
enum:
- owner
...
responses:
...
"400":
description: Bad Request
The important bit I am wanting to highlight is that scope
querystring parameter.
The API is deployed successfully, and is working, but I have noted that if I omit this querystring parameter, that APIM returns a 404 - Not found
.
There has been debate on other questions on SO (e.g. What HTTP status response code should I use if the request is missing a required parameter?), but most are really clear that 400 Bad request
is the correct response here (.5.1)
I can easily return a 400 instead (I make the param optional, and let the back-end handle it), but it my view is that this is an incorrect implementation, and that APIM is actually incorrect in doing.
Is this a correct assumption, and if not, why not?
I have an Open API document that I have as the basis of an API that I am exposing through Azure API Management (APIM).
The following shows a snippet of the document that is used when the API is deployed through a terraform devops pipeline:
openapi: 3.0.0
info:
title: my-api
description:
version: "1.0"
...
...
paths:
/my-api/{some_id}:
get:
......
operationId: get-stuff
parameters:
- name: scope
in: query
description: The scope that the request for details is being made in
required: true
style: form
explode: true
schema:
type: string
example: owner
enum:
- owner
...
responses:
...
"400":
description: Bad Request
The important bit I am wanting to highlight is that scope
querystring parameter.
The API is deployed successfully, and is working, but I have noted that if I omit this querystring parameter, that APIM returns a 404 - Not found
.
There has been debate on other questions on SO (e.g. What HTTP status response code should I use if the request is missing a required parameter?), but most are really clear that 400 Bad request
is the correct response here (https://www.rfc-editor.org/rfc/rfc7231#section-6.5.1)
I can easily return a 400 instead (I make the param optional, and let the back-end handle it), but it my view is that this is an incorrect implementation, and that APIM is actually incorrect in doing.
Is this a correct assumption, and if not, why not?
Share Improve this question edited Feb 7 at 10:07 qkfang 1,7141 silver badge20 bronze badges asked Feb 6 at 13:50 Mutation PersonMutation Person 30.5k18 gold badges100 silver badges165 bronze badges1 Answer
Reset to default 1That is by design as the query parameter is set to be required, the Apim service will import it as a template Parmeter not a query parameter which is considered as part of the routing path.
本文标签:
版权声明:本文标题:Azure APIM is returning the incorrect HTTP response error when call is missing mandatory querystring parameter - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1739387942a2161025.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论