swagger-api / swagger-core

Examples and server integrations for generating the Swagger API Specification, which enables easy access to your REST API
http://swagger.io
Apache License 2.0
7.37k stars 2.17k forks source link

URL Encode #3460

Open timpamungkas opened 4 years ago

timpamungkas commented 4 years ago

$ref attributes is not url encoded, so validating springdoc josn at editor.swagger.io gives error:

Semantic error at paths./ping.get.responses.500.content.*/*.schema.$ref
$ref values must be RFC3986-compliant percent-encoded URIs
Jump to line 46
Structural error at paths./ping.get.responses.503.content.*/*.schema.$ref
should match format "uri-reference"
format: uri-reference
Jump to line 52

The resulting openapi spec is

'500':
          description: default response
          content:
            '*/*':
              schema:
                $ref: '#/components/schemas/Json base response.'
        '503':
          description: default response
          content:
            '*/*':
              schema:
                $ref: '#/components/schemas/Json base response.'
  '/api/v1/lead/{bfi_lead_id}':

Notice the $ref attribute.Character space should be encoded as %20. This is result from @Schema annotation as follows: @Schema(name = "Json base response.")

Original issue on springdoc

hkosova commented 4 years ago

Please note that OpenAPI 3.0 does not allow spaces in schema names. Schema names (and other component names in the components section) can only contain A-Z a-z 0-9 - . _

webron commented 4 years ago

What is the source to generate those references?