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
  • #12838
Closed
Open
Issue created Jul 11, 2022 by Administrator@rootContributor5 of 5 checklist items completed5/5 checklist items

[BUG] [Engine] InlineModelResolver creates weird named duplicate inline models and there is no way to turn it off

Created by: C0deZLee

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • 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?
  • [] [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

InlineModelResolver introduced a critical regression bug for nullable objects in OpenAPI schema

openapi-generator version

6.0.1

OpenAPI declaration file content or URL

https://github.com/OpenAPITools/openapi-generator/pull/12237

modules/openapi-generator/src/main/java/org/openapitools/codegen/InlineModelResolver.java

Generation Details

Let's say we have an object defined in my OpenAPI 3.0.3 schema

    LoginPasswordlessResponse:
      type: object
      properties:
        user:
          allOf:
          - $ref: '#/components/schemas/BaseUser'
          nullable: true
        token:
          type: string
          nullable: true

Before this PR, the OpenAPI generator will link LoginPasswordlessResponse.user to BaseUser without creating a redundant inline model.

But now it will create a new model called LoginPasswordlessResponse_user

[main] INFO  o.o.codegen.InlineModelResolver - Inline schema created as LoginPasswordlessResponse_user. To have complete control of the model name, set the `title` field or use the inlineSchemaNameMapping option (--inline-schema-name-mapping in CLI).

And I cannot overwrite it with --inline-schema-name-mappings option because if I overwrite LoginPasswordlessResponse_user with BaseUser the whole openapi generator will just break due to duplicate model names.

(and by the way you missed the ending "s" in the log output, which is very misleading. I spend hours on figuring out why --inline-schema-name-mapping is an invalid option, turns out it should be --inline-schema-name-mappings)

Steps to reproduce

Shown above

Related issues/PRs

https://github.com/OpenAPITools/openapi-generator/pull/12237

Suggest a fix
Assignee
Assign to
Time tracking