Skip to content
This repository has been archived by the owner on Mar 21, 2023. It is now read-only.

Commit

Permalink
keep both siblings and $ref if siblings are defined (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
Raymond Ho authored Mar 25, 2021
1 parent c57c71e commit fb772d2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions example/foo.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type FooResponse struct {
DoubleAlias DoubleAlias `json:"doubleAlias"`
InterfaceBlah InterfaceResponse `json:"interfaceBlah"`
Instruction Instruction `json:"instruction"`
BsonPtr *BsonID `json:"bsonPtr,omitempty" example:"blah blah blah"`
}

type Environment struct {
Expand Down
4 changes: 0 additions & 4 deletions parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -1464,10 +1464,6 @@ func parseStructTags(astField *ast.Field, structSchema *SchemaObject, fieldSchem
default:
fieldSchema.Example = tag
}

if fieldSchema.Example != nil && len(fieldSchema.Ref) != 0 {
fieldSchema.Ref = ""
}
}

if _, ok := astFieldTag.Lookup("required"); ok || isRequired {
Expand Down
4 changes: 4 additions & 0 deletions parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,10 @@ func TestExample(t *testing.T) {
},
"instruction": {
"$ref": "#/components/schemas/Instruction"
},
"bsonPtr": {
"example": "blah blah blah",
"$ref": "#/components/schemas/BsonID"
}
}
},
Expand Down

0 comments on commit fb772d2

Please sign in to comment.