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)
|
||||
}
|
||||
|
||||
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) {
|
||||
data, _ := ioutil.ReadFile("../../../test_specs/circular-tests.yaml")
|
||||
info, _ := datamodel.ExtractSpecInfo(data)
|
||||
|
||||
@@ -18,8 +18,12 @@ type ExternalDoc struct {
|
||||
func NewExternalDoc(extDoc *low.ExternalDoc) *ExternalDoc {
|
||||
d := new(ExternalDoc)
|
||||
d.low = extDoc
|
||||
d.Description = extDoc.Description.Value
|
||||
d.URL = extDoc.URL.Value
|
||||
if !extDoc.Description.IsEmpty() {
|
||||
d.Description = extDoc.Description.Value
|
||||
}
|
||||
if !extDoc.URL.IsEmpty() {
|
||||
d.URL = extDoc.URL.Value
|
||||
}
|
||||
d.Extensions = high.ExtractExtensions(extDoc.Extensions)
|
||||
return d
|
||||
}
|
||||
|
||||
@@ -19,9 +19,15 @@ type Tag struct {
|
||||
func NewTag(tag *low.Tag) *Tag {
|
||||
t := new(Tag)
|
||||
t.low = tag
|
||||
t.Name = tag.Name.Value
|
||||
t.Description = tag.Description.Value
|
||||
t.ExternalDocs = NewExternalDoc(tag.ExternalDocs.Value)
|
||||
if !tag.Name.IsEmpty() {
|
||||
t.Name = tag.Name.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)
|
||||
return t
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user