Repository navigation
Description
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
OpenApi description generated just one model file in 5.4.0. In 6+ (tested with 6.0.0 and 6.4.0) every property (of the same schema) is generating one file per property, and all these files are pointing to the one (same) model/type.
openapi-generator version
5.4.0 ok, but generating with 6.0.0 and 6.4.0 causes issue described above.
OpenAPI declaration file content or url
There is sample of problematic part (in schemas)
PaginationOffsetType:
type: object
properties:
offset:
type: integer
minimum: 0
required:
- offset
OffsetsObjectType:
type: object
properties:
_offsets:
type: object
properties:
self:
allOf:
- description: |
desc 1
- $ref: '#/components/schemas/PaginationOffsetType'
first:
allOf:
- description: |
desc 2
- $ref: '#/components/schemas/PaginationOffsetType'
previous:
allOf:
- description: >
desc 3
- $ref: '#/components/schemas/PaginationOffsetType'
next:
allOf:
- description: >
desc 4
- $ref: '#/components/schemas/PaginationOffsetType'
required:
- first
- self
required:
- _offsetsGeneration Details
"npx openapi-generator-cli generate --generator-key ${yaml-filename}"
I tried "--openapi-normalizer REF_AS_PARENT_IN_ALLOF=true" but no effect
Steps to reproduce
simply run generate sample above ... it will create (useless?) four (suffixed) models:

You can see propertyName suffix ... with contents:
offsets-object-type-offsets.ts:
export interface OffsetsObjectTypeOffsets {
'self': OffsetsObjectTypeOffsetsSelf;
'first': OffsetsObjectTypeOffsetsFirst;
'previous'?: OffsetsObjectTypeOffsetsPrevious;
'next'?: OffsetsObjectTypeOffsetsNext;
}
offsets-object-type-offsets-first.ts:
export type OffsetsObjectTypeOffsetsFirst = PaginationOffsetType;
offsets-object-type-offsets-next..ts:
export type OffsetsObjectTypeOffsetsNext = PaginationOffsetType;
offsets-object-type-offsets-previous.ts:
export type OffsetsObjectTypeOffsetsPrevious= PaginationOffsetType;
offsets-object-type-offsets-self.ts:
export type OffsetsObjectTypeOffsetsSelf= PaginationOffsetType;
pagination-offset-type.ts:
export interface PaginationOffsetType {
'offset': number;
}
offsets-object-type.ts:
export interface OffsetsObjectType {
'_offsets': OffsetsObjectTypeOffsets;
}
offsets-object-type-offsets.ts:
export interface OffsetsObjectTypeOffsets {
'self': PaginationOffsetType ;
'first': PaginationOffsetType ;
'previous'?: PaginationOffsetType ;
'next'?: PaginationOffsetType ;
}
pagination-offset-type.ts:
export interface PaginationOffsetType {
'offset': number;
}
I would exepect the same result, optimized, not reduntant files/types (with "equal" content)
Related issues/PRs
I have not found any related issue
Suggest a fix
No idea

Activity
ReneZeidler commentedon Apr 19, 2023
I'm having the same problem, and it seems to be caused by having a description in combination with allOf.
My declaration looks like this:
Using OpenAPI Generator 6.5.0 with
REF_AS_PARENT_IN_ALLOF=truealready enabled, I get this output (using thetypescript-angulargenerator):It creates a new model for each property with a description, which in reality are many more than just one. The new models extend the base model (because of
REF_AS_PARENT_IN_ALLOF), but this is still suboptimal. WithoutREF_AS_PARENT_IN_ALLOF, the new models would be copies of the base model.The property description is retained in some form, but as the description of the new model instead of the property on the main model. Therefore it won't be shown by IDEs when autocompleting the property name.
Of course I can remove the description, which gets rid of the additional models:
However, especially in a case like this, where the model of the property is something general (like
NumberRangehere), having a description would be really helpful.The output I really want is this, which is what OpenAPI Generator 5.4.0 generated:
This issue is realted to #12838, where special case handling of
allOfin combination withnullableandreadOnlyhas already been added, howeverdescriptionwas missed.The temporary workaround was supposed to be replaced by a Normalizer ruleset, but as far as I can tell none of the currently available rulesets solve this issue.
MartinNovak1991 commentedon Jun 19, 2023
Any update?
I tried v6.6.0 ... same result > It generates 4 same type (OffsetsObjectTypeOffsetsSUFFIX.ts files). I noticed this in console:
I mean this: WARN o.o.codegen.InlineModelResolver - allOf schema "null" containing multiple types (not model) is not supported at the moment.
What to do?
This is part of YAMLfile:
What is wrong? What command can it do correctly without redundancy? Im lost with this :/
ok ... there is problematic location:


this:
generates this:
and this:


generates these redundant types:
ReneZeidler commentedon Jun 17, 2024
This was partially fixed by #16096, however the issue still persists if
readOnlyand/ornullableare used together with any other property (likedescription).Never create inline model for allOf with single $ref
Never create inline model for allOf with single $ref
Never create inline model for allOf with single $ref
Never create inline model for allOf with single $ref (#18945)