[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