OpenAPITools / OpenAPITools/openapi-generator

[BUG] Schema generation fails when lowercase schema (item) is aliased to PascalCase (Item)

Open
#22,464 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Bug Report Checklist
  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator? (The spec is valid OAS 3.0)
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output? (See Description below)
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

When generating a client, the model is not correctly created if the primary schema definition is in lowercase (item) but is referenced via a PascalCase alias (Item) which is then used in a path operation.

The generator fails to resolve the properties from the lowercase definition and skips the final Item model entirely, leading to TypeScript compilation errors when using TypeScript as a generator.

openapi-generator version

7.17.0

OpenAPI declaration file content or url
openapi: 3.0.0
info:
  title: "Case-Sensitive Alias Bug"
  version: 1.0.0

paths:
  /items:
    get:
      summary: Get an Item
      responses:
        '200':
          description: A single item object
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Item" # <-- References the PascalCase alias

components:
  schemas:
    # 1. Primary model definition (lowercase)
    item:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
          
    # 2. Explicit alias (PascalCase) referencing the lowercase model
    Item:
      $ref: "#/components/schemas/item"
Generation Details
openapi-generator-cli generate -i schema.yaml -g typescript-axios
Steps to reproduce
  1. Save the minimal OpenAPI specification above as schema.yaml.
  2. Run the generation command using the typescript-axios generator.
  3. Examine the generated model file for the Item interface.
Image
Related issues/PRs

N/A

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 by running the minimal schema.yaml with the typescript-axios generator and inspect how the lowercase item definition and PascalCase Item alias are resolved. Compare the generated Item model and TypeScript compilation with the expected id and name properties; done means the aliased model is generated successfully without compilation errors.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.