-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds support for nested and deeply complex struct types (#26)
* adds a test for a deeply complex type with arrays objects and pointers * fix array at top level
- Loading branch information
Showing
4 changed files
with
167 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package models | ||
|
||
type Object struct { | ||
Name string `json:"name" example:"John Smith"` | ||
} | ||
|
||
type Nested struct { | ||
Objects *[]Object `json:"objects,omitempty"` | ||
Strings *[]string `json:"strings,omitempty"` | ||
} | ||
|
||
type Deeply struct { | ||
Nested Nested `json:"nested"` | ||
} | ||
|
||
type ComplexSuccessfulResponse struct { | ||
Data *Deeply `json:"deeply"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
{ | ||
"swagger": "2.0", | ||
"info": { | ||
"title": "Testing API", | ||
"version": "v1.0.0" | ||
}, | ||
"paths": { | ||
"/deeplynested": { | ||
"get": { | ||
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed id malesuada lorem, et fermentum sapien. Vivamus non pharetra risus, in efficitur leo. Suspendisse sed metus sit amet mi laoreet imperdiet. Donec aliquam eros eu blandit feugiat. Quisque scelerisque justo ac vehicula bibendum. Fusce suscipit arcu nisl, eu maximus odio consequat quis. Curabitur fermentum eleifend tellus, lobortis hendrerit velit varius vitae.", | ||
"consumes": ["application/json"], | ||
"produces": ["application/json", "application/xml"], | ||
"tags": [], | ||
"summary": "this is a test summary", | ||
"operationId": "get-/deeplynested", | ||
"parameters": [], | ||
"responses": { | ||
"200": { | ||
"description": "OK", | ||
"schema": { | ||
"$ref": "#/definitions/models.ComplexSuccessfulResponse" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"/arraydeeplynested": { | ||
"get": { | ||
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed id malesuada lorem, et fermentum sapien. Vivamus non pharetra risus, in efficitur leo. Suspendisse sed metus sit amet mi laoreet imperdiet. Donec aliquam eros eu blandit feugiat. Quisque scelerisque justo ac vehicula bibendum. Fusce suscipit arcu nisl, eu maximus odio consequat quis. Curabitur fermentum eleifend tellus, lobortis hendrerit velit varius vitae.", | ||
"consumes": ["application/json"], | ||
"produces": ["application/json", "application/xml"], | ||
"tags": [], | ||
"summary": "this is a test summary", | ||
"operationId": "get-/arraydeeplynested", | ||
"parameters": [], | ||
"responses": { | ||
"200": { | ||
"description": "OK", | ||
"schema": { | ||
"type": "array", | ||
"items": { | ||
"$ref": "#/definitions/models.ComplexSuccessfulResponse" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"basePath": "/", | ||
"host": "localhost", | ||
"definitions": { | ||
"models.ComplexSuccessfulResponse": { | ||
"type": "object", | ||
"properties": { | ||
"deeply": { | ||
"$ref": "#/definitions/models.Deeply" | ||
} | ||
} | ||
}, | ||
"models.Deeply": { | ||
"type": "object", | ||
"properties": { | ||
"nested": { | ||
"$ref": "#/definitions/models.Nested" | ||
} | ||
} | ||
}, | ||
"models.Nested": { | ||
"type": "object", | ||
"properties": { | ||
"objects": { | ||
"type": "array", | ||
"items": { | ||
"$ref": "#/definitions/models.Object" | ||
} | ||
}, | ||
"strings": { | ||
"type": "array", | ||
"items": { | ||
"type": "string" | ||
} | ||
} | ||
} | ||
}, | ||
"models.Object": { | ||
"type": "object", | ||
"properties": { | ||
"name": { | ||
"type": "string", | ||
"example": "John Smith" | ||
} | ||
} | ||
} | ||
}, | ||
"schemes": ["http", "https"] | ||
} |