OpenAPITools / OpenAPITools/openapi-generator

[BUG] [jaxrs-spec] Invalid class name is genereated when there is a number in the name

Open
#15,350 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Description

When type name has a number in it for example A2ZPet the generated class name is A2zPet while in a file named A2ZPet also the refs created are A2ZPet.

openapi-generator version
openapi-generator-cli 6.5.0
  commit : 7417432
  built  : 2023-04-01T07:15:47Z
  source : https://github.com/openapitools/openapi-generator
  docs   : https://openapi-generator.tech/
OpenAPI declaration file content or url

openapi: 3.0.2
info:
  title: PetManager
  version: '2022-01-01'
paths:
  /data/pets:
    get:
      operationId: GetPets
      responses:
        '200':
          description: GetPets 200 response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetPetsResponseContent'
components:
  schemas:
    APet:
      type: object
      properties:
        id:
          type: number
    GetPetsResponseContent:
      type: object
      properties:
        error:
          type: string
        result:
          $ref: '#/components/schemas/PetsResult'
    A2ZPet:
      type: object
      properties:
        id:
          type: number
    PetListItem:
      oneOf:
        - type: object
          title: aPet
          properties:
            aPet:
              $ref: '#/components/schemas/APet'
          required:
            - aPet
        - type: object
          title: a2zPet
          properties:
            a2zPet:
              $ref: '#/components/schemas/A2ZPet'
          required:
            - a2zPet
    PetsResult:
      type: object
      properties:
        type:
          type: string
        pets:
          type: array
          items:
            $ref: '#/components/schemas/PetListItem'


Command line used for generation
openapi-generator generate -i spec.yaml -g jaxrs-spec -o .
Steps to reproduce

Save the above spec in spec.yaml and run the above command.

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.

Research direction

Start with spec.yaml and run the documented openapi-generator command using the jaxrs-spec generator. Compare the generated A2ZPet-related class, file, and references; done means the generated class name matches the schema and referenced names consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi
Domain
api, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.