Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #471
Closed
Open
Issue created Jul 05, 2018 by Administrator@rootContributor

[JAVA] Problem with duplicate schema names when using external references

Created by: emreakca

Description

The external reference from child to ../openapi.yaml#/components/schemas/Parent doesn't resolve correctly. It creates a empty Parent2.java class and references to Parent2. The code works just fine with the Swagger UI and parsing/validating is also not a problem.

openapi-generator version

3.1.0 / 4.0.x

OpenAPI declaration file content or url

openapi.yaml

components:
  schemas:
    Parent:
      $ref: './components/parent.yaml#/Parent'
    Child:
      $ref: './components/child.yaml#/Child'

parent.yaml

Parent:
  title: parent
  type: object
  properties:
    id:
      type: string
      description: ID of the resource

child.yaml

Child:
  title: Child
  allOf:
  - $ref: '../openapi.yaml#/components/schemas/Parent'
  type: object
  properties:
    name:
      type: string
      description: Name of the child

Complete Upload --> https://gist.github.com/emreakca/7291275cfba475d3f6384b92cdfb4554

Command line used for generation
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -i ./openapi.yaml -g java -o ./out/java-family-api
Steps to reproduce

Generate client.

Suggest a fix/enhancement

The openapi-generator should generate the code correctly.

Assignee
Assign to
Time tracking