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

Openapi big model hierarchy defect #3437

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

mhodovaniuk
Copy link

@mhodovaniuk mhodovaniuk commented Mar 28, 2025

This PR aim to fix #3361 by making sure that Schema.Transform are not ignored.

This also fixes an issue where a reference was used instead of component details. See the components are generated for model with abstract big model field test. Before these changes, the result lacked ConcreteBigModel details.
Open API spec that generated without this change:

{
   "openapi":"3.1.0",
   "info":{
      "title":"",
      "version":""
   },
   "paths":{
      "/api/v1/endpoint":{
         "get":{
            "responses":{
               "200":{
                  "content":{
                     "application/json":{
                        "schema":{
                           "$ref":"#/components/schemas/WithGenericPayload"
                        }
                     }
                  }
               }
            }
         }
      }
   },
   "components":{
      "schemas":{
         "AbstractBigModel":{
            "oneOf":[
               {
                  "$ref":"#/components/schemas/ConcreteBigModel"
               }
            ],
            "discriminator":{
               "propertyName":"type",
               "mapping":{
                  "ConcreteBigModel":"#/components/schemas/ConcreteBigModel"
               }
            }
         },
         "ConcreteBigModel":{
            "$ref":"#/components/schemas/ConcreteBigModel"
         },
         "WithGenericPayload":{
            "type":"object",
            "properties":{
               "a":{
                  "$ref":"#/components/schemas/AbstractBigModel"
               }
            },
            "required":[
               "a"
            ]
         }
      }
   }
}

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