Skip to content

Commit

Permalink
feat: omit sub items if not existent
Browse files Browse the repository at this point in the history
  • Loading branch information
vinyguedess committed Jun 20, 2022
1 parent b00fe25 commit 604c3c2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
24 changes: 12 additions & 12 deletions documentation.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,21 @@ type DocEndpoint struct {

type DocEndpointResponse struct {
Description string `json:"description"`
Schema DocEndpointSchema `json:"schema,omitempty"`
Schema *DocEndpointSchema `json:"schema,omitempty"`
Headers map[string]DocEndpointParameter `json:"headers,omitempty"`
}

type DocEndpointParameter struct {
In DocEndpointParameterIn `json:"in,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Required bool `json:"required,omitempty"`
Type DocEndpointType `json:"type,omitempty"`
Enum []string `json:"enum,omitempty"`
Format string `json:"format,omitempty"`
Items DocEndpointParameterItem `json:"items,omitempty"`
Schema DocEndpointSchema `json:"schema,omitempty"`
Example string `json:"example,omitempty"`
In DocEndpointParameterIn `json:"in,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Required bool `json:"required,omitempty"`
Type DocEndpointType `json:"type,omitempty"`
Enum []string `json:"enum,omitempty"`
Format string `json:"format,omitempty"`
Items *DocEndpointParameterItem `json:"items,omitempty"`
Schema *DocEndpointSchema `json:"schema,omitempty"`
Example string `json:"example,omitempty"`
}

type DocEndpointDefinition struct {
Expand All @@ -88,7 +88,7 @@ type DocEndpointDefinition struct {
}

type DocEndpointParameterItem struct {
Type DocEndpointType `json:"type,omitempty"`
Type DocEndpointType `json:"type"`
Enum []string `json:"enum,omitempty"`
Format string `json:"format,omitempty"`
Ref string `json:"$ref,omitempty"`
Expand Down
4 changes: 2 additions & 2 deletions documentation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func Test_AddEndpointToDocs_EndpointDefinitions(t *testing.T) {
{
In: DocEndpointParameterInBody,
Name: "body",
Schema: DocEndpointSchema{
Schema: &DocEndpointSchema{
Ref: "#/definitions/TestObject",
},
},
Expand Down Expand Up @@ -161,7 +161,7 @@ func Test_AddEndpointToDocs_EndpointDefinitions(t *testing.T) {
{
In: DocEndpointParameterInBody,
Name: "body",
Schema: DocEndpointSchema{
Schema: &DocEndpointSchema{
Ref: "#/definitions/TestObject",
},
},
Expand Down
2 changes: 1 addition & 1 deletion examples/swagger.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func main() {
{
Name: "body",
In: geh.DocEndpointParameterInBody,
Schema: geh.DocEndpointSchema{
Schema: &geh.DocEndpointSchema{
Ref: "#/definitions/TestObject",
},
},
Expand Down

0 comments on commit 604c3c2

Please sign in to comment.