kin-openapi icon indicating copy to clipboard operation
kin-openapi copied to clipboard

openapi3gen: inline golang struct creates incorrect schema

Open EnriqueL8 opened this issue 11 months ago • 0 comments

In the case where you have defined two structs as follows:

type NestedStruct struct {
     Field1 string `json:"field1,omitempty"`
}

type TopLevelStruct struct {
    *NestedStruct `json:",omitempty"`
    Field2 string `json:"field2,omitempty"`
}

The current behaviour is to create a separate nested object schema for NestedStruct so you end up with:

schema:
  properties:
     NestedStruct:
          type: object:
          properties: 
              Field1: 
                 type: string
     Field2:
         type: string 
    

but what you actually want is:

schema:
  properties:
     Field1: 
         type: string
     Field2:
         type: string 

@fenollp thoughts on this? Am I missing something?

EnriqueL8 avatar Mar 15 '24 12:03 EnriqueL8