swagger-api / swagger-api/swagger-codegen

Escaped $ref values result in funky names

Open
#8,405 2 comments 1 reaction 1 assignee View on GitHub

@HugoMario is already working on this.

Since Jul 11, 2018.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

Referenced schemas that have percent-encodings in their pointer are serialized inconsistently.

Swagger-codegen version

Whatever is on generator.swagger.io and generator3.swagger.io 😄

Swagger declaration file content or url

Swagger 2.0:

swagger: "2.0"
info:
  title: Escaped $ref bug
  description: Generate a server or client to see the problem
  version: "1.0"
paths:
  /:
    get:
      responses:
        200:
          description: ok
          schema:
            $ref: '#/definitions/My%21Strange%21Name%21'
definitions:
  My!Strange!Name!:
    type: string

OpenAPI 3.0:

openapi: "3.0.0"
info:
  title: Escaped $ref bug
  description: Generate a server or client to see the problem
  version: "1.0"
paths:
  /:
    get:
      responses:
        200:
          description: ok
          content:
            application/json:
              schema:
                $ref: '#/definitions/My%21Strange%21Name%21'
definitions:
  My!Strange!Name!:
    type: string
Command line used for generation

n/a

Steps to reproduce

Generate a client from the definition (I used JavaScript, but others will reproduce this as well).

For Swagger 2: observe that MyStrangeName and My21Strange21Name21 are used inconsistently, which results in a broken client.

For OpenAPI 3: observe a 500 Internal Server Error.

Related issues/PRs

Previously discussed in https://github.com/swagger-api/swagger-editor/issues/1766.

Suggest a fix/enhancement

Percent-encodings should be consistently stripped from generated names.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.