Forum Discussion

Yesman77's avatar
Yesman77
Occasional Visitor
4 years ago

Failed to execute 'fetch' on 'Window': Invalid name

I'm facing a problem with using a colon ':' in Swagger as a name for a parameter.  I need to use a colon as if it was changed then current clients will have a problem with our API. When I use the pa...
  • HKosova's avatar
    4 years ago

    Hi Yesman77,

     

    Colons aren't allowed in HTTP header names because they separate the header name and value.

     

    Moreover, since you're using OpenAPI 3.0, the Authorization header must be defined as a security scheme instead of a header parameter. (If defined as a parameter, it will be ignored.)

     

    You need to change your definition as follows. When testing the requests in SwaggerHub, click the "Authorize" button and enter the authorization token there.

    components:
      securitySchemes:
        Authorization:
          type: apiKey
          in: header
          name: Authorization
          description: Specify the token with the `Token` prefix, for example, `Token abcde12345`.
    
    # Require the "Authorization" header globally...
    security:
      - Authorization: []
    
    paths:
      /something:
        get:
          # ... or with individual operations
          security:
            - Authorization: []