mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-10 04:20:24 +00:00
Added a couple of null checks to v3 model
Asana spec was blowing up, now it's working as expected.
This commit is contained in:
@@ -350,6 +350,18 @@ func TestStripeAsDoc(t *testing.T) {
|
|||||||
fmt.Println(d)
|
fmt.Println(d)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestAsanaAsDoc(t *testing.T) {
|
||||||
|
data, _ := ioutil.ReadFile("../../../test_specs/asana.yaml")
|
||||||
|
info, _ := datamodel.ExtractSpecInfo(data)
|
||||||
|
var err []error
|
||||||
|
doc, err = lowv3.CreateDocument(info)
|
||||||
|
if err != nil {
|
||||||
|
panic("broken something")
|
||||||
|
}
|
||||||
|
d := NewDocument(doc)
|
||||||
|
fmt.Println(d)
|
||||||
|
}
|
||||||
|
|
||||||
func TestCircularReferencesDoc(t *testing.T) {
|
func TestCircularReferencesDoc(t *testing.T) {
|
||||||
data, _ := ioutil.ReadFile("../../../test_specs/circular-tests.yaml")
|
data, _ := ioutil.ReadFile("../../../test_specs/circular-tests.yaml")
|
||||||
info, _ := datamodel.ExtractSpecInfo(data)
|
info, _ := datamodel.ExtractSpecInfo(data)
|
||||||
|
|||||||
@@ -18,8 +18,12 @@ type ExternalDoc struct {
|
|||||||
func NewExternalDoc(extDoc *low.ExternalDoc) *ExternalDoc {
|
func NewExternalDoc(extDoc *low.ExternalDoc) *ExternalDoc {
|
||||||
d := new(ExternalDoc)
|
d := new(ExternalDoc)
|
||||||
d.low = extDoc
|
d.low = extDoc
|
||||||
d.Description = extDoc.Description.Value
|
if !extDoc.Description.IsEmpty() {
|
||||||
d.URL = extDoc.URL.Value
|
d.Description = extDoc.Description.Value
|
||||||
|
}
|
||||||
|
if !extDoc.URL.IsEmpty() {
|
||||||
|
d.URL = extDoc.URL.Value
|
||||||
|
}
|
||||||
d.Extensions = high.ExtractExtensions(extDoc.Extensions)
|
d.Extensions = high.ExtractExtensions(extDoc.Extensions)
|
||||||
return d
|
return d
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,9 +19,15 @@ type Tag struct {
|
|||||||
func NewTag(tag *low.Tag) *Tag {
|
func NewTag(tag *low.Tag) *Tag {
|
||||||
t := new(Tag)
|
t := new(Tag)
|
||||||
t.low = tag
|
t.low = tag
|
||||||
t.Name = tag.Name.Value
|
if !tag.Name.IsEmpty() {
|
||||||
t.Description = tag.Description.Value
|
t.Name = tag.Name.Value
|
||||||
t.ExternalDocs = NewExternalDoc(tag.ExternalDocs.Value)
|
}
|
||||||
|
if !tag.Description.IsEmpty() {
|
||||||
|
t.Description = tag.Description.Value
|
||||||
|
}
|
||||||
|
if !tag.ExternalDocs.IsEmpty() {
|
||||||
|
t.ExternalDocs = NewExternalDoc(tag.ExternalDocs.Value)
|
||||||
|
}
|
||||||
t.Extensions = high.ExtractExtensions(tag.Extensions)
|
t.Extensions = high.ExtractExtensions(tag.Extensions)
|
||||||
return t
|
return t
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user