授权标头中的OpenAPI 3自定义类型 [英] OpenAPI 3 Custom type in Authorization header
问题描述
我正在寻找正确的方法来指定带有自定义类型(例如openAPI 3中的ApiKey)的Authorization标头.
I am looking for the proper way to specify an Authorization header with a custom type like ApiKey in openAPI 3.
自定义的Authorization标头应为
The custom Authorization header should look like
授权:ApiKey myAPIKeyHere
Authorization: ApiKey myAPIKeyHere
我所有尝试使用apiKey类型指定securitySchemes条目的尝试都似乎 产生其他结果...
All my attempts to specify the securitySchemes entry with type apiKey seems to produce other results...
离我最近的东西是这样的:
The closest I got is something like:
securitySchemes:
ApiKeyAuth:
type: apiKey
in: header
name: ApiKey
...但是,密钥不在Authorization标头中.
... but then, the key is not in the Authorization header.
如何规定这样的要求?
推荐答案
我认为我已经找到了一种似乎可以接受的方法-尽管并不完美.希望以后看到更好的东西...
I think I have found a way that seems acceptable - although not perfect. Would like to see something better in the future...
除了将自定义类型添加到值中(似乎通过以下说明进行辅助)外,似乎没有其他方法.
It seems that there is no other way than to add the custom type to the value (aided by a description like below).
components:
securitySchemes:
ApiKey:
type: apiKey
name: Authorization
in: header
description: 'Prefix the value with \"ApiKey\" to indicate the custom authorization type'
security:
- ApiKey: []
这至少会在curl中产生正确的标题(如果正确应用).
This does at least produce the correct header in curl (if applied correctly).
这篇关于授权标头中的OpenAPI 3自定义类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!