mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-09 20:47:44 +00:00
Added support for unevaluatedProperties as Schema and bool #118
Also ran `gofmt` across the entire project. Things need cleaning up. Signed-off-by: Dave Shanley <dave@quobix.com>
This commit is contained in:
@@ -4,53 +4,53 @@
|
||||
package v3
|
||||
|
||||
import (
|
||||
"github.com/pb33f/libopenapi/datamodel/low"
|
||||
v3 "github.com/pb33f/libopenapi/datamodel/low/v3"
|
||||
"github.com/pb33f/libopenapi/index"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"gopkg.in/yaml.v3"
|
||||
"strings"
|
||||
"testing"
|
||||
"github.com/pb33f/libopenapi/datamodel/low"
|
||||
v3 "github.com/pb33f/libopenapi/datamodel/low/v3"
|
||||
"github.com/pb33f/libopenapi/index"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"gopkg.in/yaml.v3"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestComponents_MarshalYAML(t *testing.T) {
|
||||
|
||||
comp := &Components{
|
||||
Responses: map[string]*Response{
|
||||
"200": {
|
||||
Description: "OK",
|
||||
},
|
||||
},
|
||||
Parameters: map[string]*Parameter{
|
||||
"id": {
|
||||
Name: "id",
|
||||
In: "path",
|
||||
},
|
||||
},
|
||||
RequestBodies: map[string]*RequestBody{
|
||||
"body": {
|
||||
Content: map[string]*MediaType{
|
||||
"application/json": {
|
||||
Example: "why?",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
comp := &Components{
|
||||
Responses: map[string]*Response{
|
||||
"200": {
|
||||
Description: "OK",
|
||||
},
|
||||
},
|
||||
Parameters: map[string]*Parameter{
|
||||
"id": {
|
||||
Name: "id",
|
||||
In: "path",
|
||||
},
|
||||
},
|
||||
RequestBodies: map[string]*RequestBody{
|
||||
"body": {
|
||||
Content: map[string]*MediaType{
|
||||
"application/json": {
|
||||
Example: "why?",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
dat, _ := comp.Render()
|
||||
dat, _ := comp.Render()
|
||||
|
||||
var idxNode yaml.Node
|
||||
_ = yaml.Unmarshal(dat, &idxNode)
|
||||
idx := index.NewSpecIndexWithConfig(&idxNode, index.CreateOpenAPIIndexConfig())
|
||||
var idxNode yaml.Node
|
||||
_ = yaml.Unmarshal(dat, &idxNode)
|
||||
idx := index.NewSpecIndexWithConfig(&idxNode, index.CreateOpenAPIIndexConfig())
|
||||
|
||||
var n v3.Components
|
||||
_ = low.BuildModel(idxNode.Content[0], &n)
|
||||
_ = n.Build(idxNode.Content[0], idx)
|
||||
var n v3.Components
|
||||
_ = low.BuildModel(idxNode.Content[0], &n)
|
||||
_ = n.Build(idxNode.Content[0], idx)
|
||||
|
||||
r := NewComponents(&n)
|
||||
r := NewComponents(&n)
|
||||
|
||||
desired := `responses:
|
||||
desired := `responses:
|
||||
"200":
|
||||
description: OK
|
||||
parameters:
|
||||
@@ -63,6 +63,6 @@ requestBodies:
|
||||
application/json:
|
||||
example: why?`
|
||||
|
||||
dat, _ = r.Render()
|
||||
assert.Equal(t, desired, strings.TrimSpace(string(dat)))
|
||||
dat, _ = r.Render()
|
||||
assert.Equal(t, desired, strings.TrimSpace(string(dat)))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user