Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] [Generator] release v7.11.0 breaks referenced shema's properties #20529

Open
5 of 6 tasks
JPPortier opened this issue Jan 23, 2025 · 1 comment
Open
5 of 6 tasks

Comments

@JPPortier
Copy link
Contributor

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 the description content is correctly extracted from deferencedSchema within 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 the description content 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: 066a840
Suggest a fix
@wing328
Copy link
Member

wing328 commented Jan 23, 2025

thanks for reporting the issue

please revert to v7.10.0 for the time being

i will try to come up with a better fix to cater both use cases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants