OpenAPI 3 Custom type in Authorization header

前端 未结 2 635
迷失自我
迷失自我 2020-12-12 01:32

I am looking for the proper way to specify an Authorization header with a custom type like ApiKey in openAPI 3.

The custom Authorization header should look like

相关标签:
2条回答
  • 2020-12-12 01:51

    Please try this:

      securitySchemes:
        ApiKeyAuth:
           type: apiKey
           in: header
           name: ApiKey
      security
        - ApiKeyAuth: []
    

    Please have a look at the documentation:

    -> Step 2. Applying security

    Authentication and Authorization

    0 讨论(0)
  • 2020-12-12 02:01

    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: []
    

    This does at least produce the correct header in curl (if applied correctly).

    0 讨论(0)
提交回复
热议问题