diff --git a/datamodel/high/3.0/tag.go b/datamodel/high/3.0/tag.go index d1b4a55..c176e68 100644 --- a/datamodel/high/3.0/tag.go +++ b/datamodel/high/3.0/tag.go @@ -36,12 +36,12 @@ func (t *Tag) GoLow() *low.Tag { return t.low } -func (t *Tag) SetName(value string) { - t.GoLow().Name.ValueNode.Value = value -} -func (t *Tag) SetDescription(value string) { - t.GoLow().Description.ValueNode.Value = value -} +//func (t *Tag) SetName(value string) { +// t.GoLow().Name.ValueNode.Value = value +//} +//func (t *Tag) SetDescription(value string) { +// t.GoLow().Description.ValueNode.Value = value +//} //func (t *Tag) MarshalYAML() (interface{}, error) { // m := make(map[string]interface{}) diff --git a/datamodel/low/base/schema_proxy_test.go b/datamodel/low/base/schema_proxy_test.go new file mode 100644 index 0000000..8f26172 --- /dev/null +++ b/datamodel/low/base/schema_proxy_test.go @@ -0,0 +1,23 @@ +// Copyright 2022 Princess B33f Heavy Industries / Dave Shanley +// SPDX-License-Identifier: MIT + +package base + +import ( + "github.com/stretchr/testify/assert" + "gopkg.in/yaml.v3" + "testing" +) + +func TestSchemaProxy_Build(t *testing.T) { + + yml := `description: something` + + var sch SchemaProxy + var idxNode yaml.Node + _ = yaml.Unmarshal([]byte(yml), &idxNode) + + err := sch.Build(&idxNode, nil) + assert.NoError(t, err) + assert.Equal(t, "something", sch.Schema().Description.Value) +} diff --git a/datamodel/low/extraction_functions_test.go b/datamodel/low/extraction_functions_test.go index 548980f..9b0e6de 100644 --- a/datamodel/low/extraction_functions_test.go +++ b/datamodel/low/extraction_functions_test.go @@ -24,6 +24,16 @@ func TestFindItemInMap(t *testing.T) { assert.Equal(t, "pie", FindItemInMap("pizza", v).Value) } +func TestFindItemInMap_WrongCase(t *testing.T) { + v := make(map[KeyReference[string]]ValueReference[string]) + v[KeyReference[string]{ + Value: "pizza", + }] = ValueReference[string]{ + Value: "pie", + } + assert.Equal(t, "pie", FindItemInMap("PIZZA", v).Value) +} + func TestFindItemInMap_Error(t *testing.T) { v := make(map[KeyReference[string]]ValueReference[string]) v[KeyReference[string]{ diff --git a/datamodel/model_utils_test.go b/datamodel/model_utils_test.go index a06a31d..18bef68 100644 --- a/datamodel/model_utils_test.go +++ b/datamodel/model_utils_test.go @@ -245,3 +245,30 @@ func TestCheckEnumForDuplicates_FailMultiple(t *testing.T) { yaml.Unmarshal([]byte(yml), &rootNode) assert.Len(t, CheckEnumForDuplicates(rootNode.Content[0].Content), 3) } + +func TestExtractSpecInfo_BadVersion_OpenAPI3(t *testing.T) { + + yml := `openapi: + should: fail` + + _, err := ExtractSpecInfo([]byte(yml)) + assert.Error(t, err) +} + +func TestExtractSpecInfo_BadVersion_Swagger(t *testing.T) { + + yml := `swagger: + should: fail` + + _, err := ExtractSpecInfo([]byte(yml)) + assert.Error(t, err) +} + +func TestExtractSpecInfo_BadVersion_AsyncAPI(t *testing.T) { + + yml := `asyncapi: + should: fail` + + _, err := ExtractSpecInfo([]byte(yml)) + assert.Error(t, err) +} diff --git a/libopenapi.go b/libopenapi.go index e1e7172..1bb36d8 100644 --- a/libopenapi.go +++ b/libopenapi.go @@ -38,8 +38,8 @@ tags: highDoc := high.NewDocument(lowDoc) highDoc.Info.GoLow().Title.ValueNode.Value = "let's hack this" - highDoc.Tags[0].SetName("We are a new name now") - highDoc.Tags[0].SetDescription("and a new description") + //highDoc.Tags[0].SetName("We are a new name now") + //highDoc.Tags[0].SetDescription("and a new description") //newTag := lowDoc.AddTag() //fmt.Println(newTag)