aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/go-openapi/loads
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/go-openapi/loads')
-rw-r--r--vendor/github.com/go-openapi/loads/spec.go2
-rw-r--r--vendor/github.com/go-openapi/loads/spec_test.go142
2 files changed, 143 insertions, 1 deletions
diff --git a/vendor/github.com/go-openapi/loads/spec.go b/vendor/github.com/go-openapi/loads/spec.go
index 6d967389b..2db5cb558 100644
--- a/vendor/github.com/go-openapi/loads/spec.go
+++ b/vendor/github.com/go-openapi/loads/spec.go
@@ -186,7 +186,7 @@ func (d *Document) Expanded(options ...*spec.ExpandOptions) (*Document, error) {
var expandOptions *spec.ExpandOptions
if len(options) > 0 {
- expandOptions = options[1]
+ expandOptions = options[0]
} else {
expandOptions = &spec.ExpandOptions{
RelativeBase: filepath.Dir(d.specFilePath),
diff --git a/vendor/github.com/go-openapi/loads/spec_test.go b/vendor/github.com/go-openapi/loads/spec_test.go
index 5c5e7ca4e..a3b241d95 100644
--- a/vendor/github.com/go-openapi/loads/spec_test.go
+++ b/vendor/github.com/go-openapi/loads/spec_test.go
@@ -32,6 +32,19 @@ func TestLoadsYAMLContent(t *testing.T) {
}
}
+// for issue 11
+func TestRegressionExpand(t *testing.T) {
+ swaggerFile := "fixtures/yaml/swagger/1/2/3/4/swagger.yaml"
+ document, err := Spec(swaggerFile)
+ assert.NoError(t, err)
+ assert.NotNil(t, document)
+ d, err := document.Expanded()
+ assert.NoError(t, err)
+ assert.NotNil(t, d)
+ b, _ := d.Spec().MarshalJSON()
+ assert.JSONEq(t, expectedExpanded, string(b))
+}
+
func TestFailsInvalidJSON(t *testing.T) {
_, err := Analyzed(json.RawMessage([]byte("{]")), "")
@@ -499,3 +512,132 @@ const PetStore20 = `{
}
}
`
+
+const expectedExpanded = `
+{
+ "produces":[
+ "application/json",
+ "plain/text"
+ ],
+ "schemes":[
+ "https",
+ "http"
+ ],
+ "swagger":"2.0",
+ "info":{
+ "description":"Something",
+ "title":"Something",
+ "contact":{
+ "name":"Somebody",
+ "url":"https://url.com",
+ "email":"email@url.com"
+ },
+ "version":"v1"
+ },
+ "host":"security.sonusnet.com",
+ "basePath":"/api",
+ "paths":{
+ "/whatnot":{
+ "get":{
+ "description":"Get something",
+ "responses":{
+ "200":{
+ "description":"The something",
+ "schema":{
+ "description":"A collection of service events",
+ "type":"object",
+ "properties":{
+ "page":{
+ "description":"A description of a paged result",
+ "type":"object",
+ "properties":{
+ "page":{
+ "description":"the page that was requested",
+ "type":"integer"
+ },
+ "page_items":{
+ "description":"the number of items per page requested",
+ "type":"integer"
+ },
+ "pages":{
+ "description":"the total number of pages available",
+ "type":"integer"
+ },
+ "total_items":{
+ "description":"the total number of items available",
+ "type":"integer",
+ "format":"int64"
+ }
+ }
+ },
+ "something":{
+ "description":"Something",
+ "type":"object",
+ "properties":{
+ "p1":{
+ "description":"A string",
+ "type":"string"
+ },
+ "p2":{
+ "description":"An integer",
+ "type":"integer"
+ }
+ }
+ }
+ }
+ }
+ },
+ "500":{
+ "description":"Oops"
+ }
+ }
+ }
+ }
+ },
+ "definitions":{
+ "Something":{
+ "description":"A collection of service events",
+ "type":"object",
+ "properties":{
+ "page":{
+ "description":"A description of a paged result",
+ "type":"object",
+ "properties":{
+ "page":{
+ "description":"the page that was requested",
+ "type":"integer"
+ },
+ "page_items":{
+ "description":"the number of items per page requested",
+ "type":"integer"
+ },
+ "pages":{
+ "description":"the total number of pages available",
+ "type":"integer"
+ },
+ "total_items":{
+ "description":"the total number of items available",
+ "type":"integer",
+ "format":"int64"
+ }
+ }
+ },
+ "something":{
+ "description":"Something",
+ "type":"object",
+ "properties":{
+ "p1":{
+ "description":"A string",
+ "type":"string"
+ },
+ "p2":{
+ "description":"An integer",
+ "type":"integer"
+ }
+ }
+ }
+ }
+ }
+ }
+}
+`