cancel
Showing results for 
Search instead for 
Did you mean: 

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

SOLVED
Yesman77
Occasional Visitor

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

 

1 ACCEPTED SOLUTION

Accepted Solutions
HKosova
Moderator

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

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

Helen Kosova
SmartBear Documentation Team Lead
________________________
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️

View solution in original post

1 REPLY 1
HKosova
Moderator

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

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

Helen Kosova
SmartBear Documentation Team Lead
________________________
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️

View solution in original post

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors