Bug Report Checklist
Description
Starting with OpenAPI 3.1, it is allowed for $ref-objects to have sibling properties and those sibling properties should not be lost. A simple example would be:
components:
schemas:
ModelWithTitledProperties:
properties:
refProperty:
type: string
title: Ref-Property-Title
$ref: '#/components/schemas/RefObject'
type: object
RefObject:
type: string
Expected: when generating code, I have access to refProperty's title field.
Reality: The value of title (and other fields, such as description) are lost.
For example, if I try to generate TypeScript code that includes a model's title using a custom template (but the issue is not TypeScript-specific):
export const {{classname}}Meta = {
{{#vars}}
{{name}}: {
title: `{{{title}}}`,
description: `{{{description}}}`
},
{{/vars}}
} as const;
this works for regular properties, but title and description are always empty for properties that include a $ref.
openapi-generator version
7.10.0 (actually latest master, d29196a).
As far as I understand, this is not a regression, but just a yet undetected bug for OpenAPI 3.1 schemas.
Steps to reproduce
I opened a complimentary pull request that adds a test case showcasing the problem: #20303
Suggest a fix
Best lead I found while debugging was that ModelUtils#unaliasSchema seems to just 100% forward the $ref'ed schema if it detects a ref that doesn't fall into one of the special cases like isObjectSchema(...).
Bug Report Checklist
Have you validated the input using an OpenAPI validator (example)?The correctness of the snippets I'm trying to parse were discussed in Parser ignore readOnly/writeOnly on property with $ref swagger-api/swagger-parser#2036Description
Starting with OpenAPI 3.1, it is allowed for $ref-objects to have sibling properties and those sibling properties should not be lost. A simple example would be:
Expected: when generating code, I have access to
refProperty'stitlefield.Reality: The value of
title(and other fields, such asdescription) are lost.For example, if I try to generate TypeScript code that includes a model's title using a custom template (but the issue is not TypeScript-specific):
this works for regular properties, but
titleanddescriptionare always empty for properties that include a$ref.openapi-generator version
7.10.0 (actually latest master, d29196a).
As far as I understand, this is not a regression, but just a yet undetected bug for OpenAPI 3.1 schemas.
Steps to reproduce
I opened a complimentary pull request that adds a test case showcasing the problem: #20303
Suggest a fix
Best lead I found while debugging was that
ModelUtils#unaliasSchemaseems to just 100% forward the $ref'ed schema if it detects a ref that doesn't fall into one of the special cases likeisObjectSchema(...).