Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion docparser/datatest/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,21 @@ type AnonymousArray struct {
} `json:"data"`
}

// @openapi:schema
type animal struct {
species string
}

// Dog struct
// @openapi:schema
type Dog struct {
Pet
animal
otherpackage.Data

Name string `json:"name"`
Name string `json:"name"`
weight int
friends []animal
}

// Foo struct
Expand Down
3 changes: 3 additions & 0 deletions docparser/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,9 @@ func (spec *openAPI) parseStructs(f *ast.File, tpe *ast.StructType) (interface{}
e.Type = "object"

for _, fld := range tpe.Fields.List {
if len(fld.Names) > 0 && fld.Names[0] != nil && !fld.Names[0].IsExported() {
continue
}
if len(fld.Names) > 0 && fld.Names[0] != nil && fld.Names[0].IsExported() {
j, err := parseJSONTag(fld)
if j.ignore {
Expand Down
4 changes: 3 additions & 1 deletion openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ components:
Dog:
allOf:
- $ref: '#/components/schemas/Pet'
- $ref: '#/components/schemas/animal'
- $ref: '#/components/schemas/WeirdCustomName'
- type: object
properties:
Expand Down Expand Up @@ -151,7 +152,6 @@ components:
nullable: true
type: string
pointerOfStruct:
nullable: true
$ref: '#/components/schemas/Foo'
pointerOfTime:
nullable: true
Expand Down Expand Up @@ -201,4 +201,6 @@ components:
type: string
WeirdInt:
type: integer
animal:
type: object
x-tagGroups: []