cancel
Showing results for 
Search instead for 
Did you mean: 

Swagger Tools does not allow Schemas with non ASCII characters even if URI-encoded

SOLVED
Highlighted
New Contributor

Swagger Tools does not allow Schemas with non ASCII characters even if URI-encoded

According to the open api specification on $ref https://swagger.io/specification/#referenceObject -  a Schema should honor the URI format defined https://tools.ietf.org/html/rfc3986#section-4.1 - and can use extended characters as long as they are properly URI encoded.

 

However when defining a schema that uses non ASCII characters, i get a lot of validation errors - even if non ASCII characters are properly URI encoded (pct encoded)

 

Is this a shortcoming in the tooling, or am i reading the standards wrong?

 

Kind regards

 

Morten

1 ACCEPTED SOLUTION

Accepted Solutions
Moderator

Re: Swagger Tools does not allow Schemas with non ASCII characters even if URI-encoded

While there may still be an issue with the reference resolution, your definition is invalid for another reason. The name you've given the schema doesn't conform with the restrictions in the spec.

 

From https://swagger.io/specification/#componentsObject:

All the fixed fields declared above are objects that MUST use keys that match the regular expression: ^[a-zA-Z0-9\.\-_]+$.
4 REPLIES 4
Moderator

Re: Swagger Tools does not allow Schemas with non ASCII characters even if URI-encoded

In which tools do you experience the issue?

Can you share an example to reproduce it?

New Contributor

Re: Swagger Tools does not allow Schemas with non ASCII characters even if URI-encoded

Hi Ron

 

The tools in question are Swagger-Editor, Swagger-Hub, and i guess that swagger UI is a part of both

 

The behaviour can be reproduced using the following API specification: 

openapi: "3.0.0"
info:
  version: 1.0.3
  title: Somespec
paths:
  /somepath:
    get:
      responses:
        '200':
          description: Somedescription
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/%C3%85rsopg%C3%B8erelse"
components:
  schemas:
    %C3%85rsopg%C3%B8erelse:
      properties:
        someproperty:
          type: string

 

Moderator

Re: Swagger Tools does not allow Schemas with non ASCII characters even if URI-encoded

While there may still be an issue with the reference resolution, your definition is invalid for another reason. The name you've given the schema doesn't conform with the restrictions in the spec.

 

From https://swagger.io/specification/#componentsObject:

All the fixed fields declared above are objects that MUST use keys that match the regular expression: ^[a-zA-Z0-9\.\-_]+$.
New Contributor

Re: Swagger Tools does not allow Schemas with non ASCII characters even if URI-encoded

Thank you, i was reading the specification wrong

New Here?
Join us and watch the welcome video:
Watch the New Interview
7Mistakes
Join our online event
SeptemberHubBub
Join the September Hub-bub to show off, learn and win