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 parameter below I get an error called: TypeError: Failed to execute 'fetch' on 'Window': Invalid name
parameters:
- in: header
name: "Authorization: Token "
schema:
type: string
format: byte
required: true
Any help/advice will be appreciated
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: []