Skip to content

(Regression from 2.6 to 2.8) Class used in "implementation" attribute is not rendered in Schemas #3097

@arungitan

Description

@arungitan

Describe the bug
in one of our apis, we have an alternate implementation class to be used to document the schema for a nested array of objects. This class is not used directly as an argument in any api; it is only used in the @Schema annotation.
In 2.6, the class is rendered correctly in schemas. But in 2.8, it is completely skipped from rendering in schemas although the refs for it are generated in the referencing schema. Hence we get errors such as "could not resolve reference: JSON pointer evaluation failed while evaluating token "ThingAssignment" against an ObjectElement."

Would like to know if this is a known issue that is already fixed (pls advise min version of springdoc having fix) or if this is a new issue?

To Reproduce
Steps to reproduce the behavior:

  • What version of spring-boot you are using?

    3.5.0

  • What modules and versions of springdoc-openapi are you using?

    2.8.9

  • What is the actual and the expected result using OpenAPI Description (yml or json)?

    In 2.6, both Thing and ThingAssignment schema are rendered in the schemas list of the json.
    However, in 2.8, 'Thing' is rendered but 'ThingAssignment' is NOT rendered.

  • Provide with a sample code (HelloController) or Test that reproduces the problem

    Hopefully this snippet is enough to understand and reproduce the problem. If not, pls let me know.
    DTO classes:

  @Schema(description = "User resource") 
  class User  {
         // ... other attributes ...
 
         @ArraySchema(
               arraySchema = @Schema(description = "List of Things assigned to the user", requiredMode =  RequiredMode.REQUIRED), 
                schema = @Schema(implementation = Thing.ThingAssignment.class)
          )
           public List<Thing> getThings() {
               return things;
            }
    }  
    
    @Schema(description = "Thing resource")
    class Thing  {
           // ... various attributes ... 

           @Schema(description = "Thing to be assigned to user")
            static class ThingAssignment extends Thing {
                 // same as Thing but uses different @Schema annotations 
                 // more suited for a nested object...  
             }
     }

Expected behavior

  • A clear and concise description of what you expected to happen.

  • What is the expected result using OpenAPI Description (yml or json)?

    As in 2.6, both Thing and ThingAssignment schema should be rendered in the schemas list of the json.

Screenshots
If applicable, add screenshots to help explain your problem.

N/A

Additional context

Just to be clear, I am not looking for suggestion to redesign the api/use a different dto etc. That is out-of-scope for this. Just want a fix for what regressed between 2.6 and 2.8.
For now we have used the workaround of overriding the default openapi 3.1 version to 3.0
springdoc.api-docs.version=openapi_3_0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions