OpenAPITools / OpenAPITools/openapi-generator
[BUG] [Generator] release v7.11.0 breaks referenced shema's properties
Open
Nobody has claimed this yet.
Issue: Bug
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
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
When a schema's field is defined by using a $ref schema; referenced schema properties (e.g. description) are not added
openapi-generator version
- Working with .7.10.0 ✅
- Break with 7.11.0 🔴
OpenAPI declaration file content or url
openapi: 3.0.3
info:
title: API Overview
version: "v1"
description: description
paths:
"/path":
post:
operationId: post
requestBody:
$ref: '#/components/requestBodies/requestBody'
responses:
"200":
description: no response
components:
requestBodies:
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/requestSchema'
schemas:
requestSchema:
type: object
properties:
directField:
type: string
description: value field description from 'requestSchema' schema
deferencedField:
$ref: '#/components/schemas/deferencedSchema'
deferencedSchema:
type: object
allOf:
- $ref: '#/components/schemas/lowLevelSchema'
description: Description from 'deferencedSchema' schema
lowLevelSchema:
type: string
description: Description from 'lowLevelSchema' schema
Generation Details
- v7.10.0 generation
Note thedescriptioncontent is correctly extracted fromdeferencedSchemawithin java comments :
* Description from 'deferencedSchema' schema
/**
* Description from 'deferencedSchema' schema
* @return deferencedField
*/
@javax.annotation.Nullable
@JsonProperty(JSON_PROPERTY_DEFERENCED_FIELD)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public String getDeferencedField() {
return deferencedField;
}
- v7.11.0 generation
Note thedescriptioncontent no longer contains the description (defaulted to field name):
* Get deferencedField
/**
* Get deferencedField
* @return deferencedField
*/
@javax.annotation.Nullable
@JsonProperty(JSON_PROPERTY_DEFERENCED_FIELD)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public Object getDeferencedField() {
return deferencedField;
}
Steps to reproduce
java -jar openapi-generator-cli-7.11.0.jar generate -i /fooAllOfDescriptionAndRef.yaml -g java -o output --additional-properties=library=apache-httpclient
Related issues/PRs
- Issue appeared with this revert commit: https://github.com/OpenAPITools/openapi-generator/commit/066a840dd8d626e10c449f551a8cb3b99b7e0f23
Suggest a fix
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the supplied OpenAPI YAML and the Java generator command, comparing output from v7.10.0 and v7.11.0. Inspect revert commit 066a840dd8d626e10c449f551a8cb3b99b7e0f23 and trace how referenced schema descriptions are handled; done means the generated getter again includes the dereferenced schema description and retains the expected type.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100