mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-06 12:37:49 +00:00
@@ -189,6 +189,17 @@ why:
|
|||||||
assert.Len(t, *r.SpecBytes, 55)
|
assert.Len(t, *r.SpecBytes, 55)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestExtractSpecInfo_AnyDocument_JSON(t *testing.T) {
|
||||||
|
|
||||||
|
random := `{ "something" : "yeah"}`
|
||||||
|
|
||||||
|
r, e := ExtractSpecInfoWithDocumentCheck([]byte(random), true)
|
||||||
|
assert.Nil(t, e)
|
||||||
|
assert.NotNil(t, r.RootNode)
|
||||||
|
assert.Equal(t, "something", r.RootNode.Content[0].Content[0].Value)
|
||||||
|
assert.Len(t, *r.SpecBytes, 23)
|
||||||
|
}
|
||||||
|
|
||||||
func TestExtractSpecInfo_AnyDocumentFromConfig(t *testing.T) {
|
func TestExtractSpecInfo_AnyDocumentFromConfig(t *testing.T) {
|
||||||
|
|
||||||
random := `something: yeah
|
random := `something: yeah
|
||||||
|
|||||||
@@ -291,13 +291,24 @@ func TestDocument_RenderAndReload_Swagger(t *testing.T) {
|
|||||||
|
|
||||||
func TestDocument_BuildModelPreBuild(t *testing.T) {
|
func TestDocument_BuildModelPreBuild(t *testing.T) {
|
||||||
petstore, _ := ioutil.ReadFile("test_specs/petstorev3.json")
|
petstore, _ := ioutil.ReadFile("test_specs/petstorev3.json")
|
||||||
doc, _ := NewDocument(petstore)
|
_, e := NewDocument(petstore)
|
||||||
doc.BuildV3Model()
|
|
||||||
doc.BuildV3Model()
|
|
||||||
_, _, _, e := doc.RenderAndReload()
|
|
||||||
assert.Len(t, e, 0)
|
assert.Len(t, e, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestDocument_AnyDoc(t *testing.T) {
|
||||||
|
anything := []byte(`{"chickens": "3.0.0", "burgers": {"title": "hello"}}`)
|
||||||
|
_, e := NewDocumentWithTypeCheck(anything, true)
|
||||||
|
assert.NoError(t, e)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDocument_AnyDocWithConfig(t *testing.T) {
|
||||||
|
anything := []byte(`{"chickens": "3.0.0", "burgers": {"title": "hello"}}`)
|
||||||
|
_, e := NewDocumentWithConfiguration(anything, &datamodel.DocumentConfiguration{
|
||||||
|
BypassDocumentCheck: true,
|
||||||
|
})
|
||||||
|
assert.NoError(t, e)
|
||||||
|
}
|
||||||
|
|
||||||
func TestDocument_BuildModelCircular(t *testing.T) {
|
func TestDocument_BuildModelCircular(t *testing.T) {
|
||||||
petstore, _ := ioutil.ReadFile("test_specs/circular-tests.yaml")
|
petstore, _ := ioutil.ReadFile("test_specs/circular-tests.yaml")
|
||||||
doc, _ := NewDocument(petstore)
|
doc, _ := NewDocument(petstore)
|
||||||
|
|||||||
Reference in New Issue
Block a user