我有一个HTTP302(重定向),它实现了一个新的状态参数,它将附加到RedirectURL中,因此可以显示如下所示的消息
如果调用URL作为
GET http://localhost:8080/info/status?redirectUrl=http://localhost:8080/redirect然后它将重定向为
http://localhost:8080/redirect?status=success它是对应的
http://localhost:8080/redirect?status=error但是如何在OpenAPI规范中描述这一点呢?我似乎无法在响应中使用parameters,并且找到了一些使用responseParameters的代码,但是我没有运气让它工作。甚至不知道这是否是受支持的东西,至少我没有发现用这两个命令编译的错误
/info/setup:
get:
summary: Setup Url
description: Setup Url to create new setup. Should be retrieved from api
apps endpoint and redirect to, not called directly by the url defined
here
parameters:
- in: query
name: installationId
description: The installation id
required: true
schema:
type: string
- in: query
name: redirectUrl
description: Url to redirect back to upon finished installation
required: true
schema:
type: string
responses:
"302":
description: Redirect
responseParameters:
- in: query
name: status
description: the status of the instalation
schema:
oneOf:
- type: string
example: success
description: When the installation was successful
- type: string
example: error
description: When the installation was erroneous
headers:
location:
description: Setup state based redirect
schema:
oneOf:
- type: string
description: If setup is done and valid for installation id, will
redirect to given redirect url
- type: string
description: If no setup exist for installation id, will redirect to
SumUp oauth page
- type: string
description: If error during authorization with SumUpl, e.g. non
matching editions, will redirect to a setup page for
further user action发生这种情况的共同方式是什么?
我们应该有两个重定向的URL,比如
GET http://localhost:8080/info/status
?redirectUrl=http://localhost:8080/redirect
&errorUrl=http://localhost:8080/redirect_error我对这个简单的困境有点不知所措,也许有人能帮上忙
发布于 2021-12-23 14:24:11
是的,这对OpenAPI来说是个恼人的问题。不能真正显式地指定重定向。
您所能做的最好是在3xx重定向范围(301、302、303、307、308)中指定状态代码的响应,该响应具有"string“类型的"location”标头参数。
然后,你应该添加一个描述和总结--基本上是你已经做过的事情。
OpenAPI规范github:https://github.com/OAI/OpenAPI-Specification/issues/2512中存在这个问题
希望很快就能做点什么。
https://stackoverflow.com/questions/63792987
复制相似问题