mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-10 04:20:24 +00:00
Wired up multi-version handling patterns
Designs for handling multiple versions of objects have been set, seems clean and scalable. Generic functions for handling maps has been added also, which will cut down time moving forward.
This commit is contained in:
@@ -4,9 +4,11 @@
|
||||
package what_changed
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/pb33f/libopenapi/datamodel"
|
||||
"github.com/pb33f/libopenapi/datamodel/low"
|
||||
"github.com/pb33f/libopenapi/datamodel/low/base"
|
||||
v2 "github.com/pb33f/libopenapi/datamodel/low/v2"
|
||||
v3 "github.com/pb33f/libopenapi/datamodel/low/v3"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
@@ -150,6 +152,25 @@ func test_BuildDoc(l, r string) (*v3.Document, *v3.Document) {
|
||||
return leftDoc, rightDoc
|
||||
}
|
||||
|
||||
func test_BuildDocv2(l, r string) (*v2.Swagger, *v2.Swagger) {
|
||||
|
||||
leftInfo, _ := datamodel.ExtractSpecInfo([]byte(l))
|
||||
rightInfo, _ := datamodel.ExtractSpecInfo([]byte(r))
|
||||
|
||||
var err []error
|
||||
var leftDoc, rightDoc *v2.Swagger
|
||||
leftDoc, err = v2.CreateDocument(leftInfo)
|
||||
rightDoc, err = v2.CreateDocument(rightInfo)
|
||||
|
||||
if len(err) > 0 {
|
||||
for i := range err {
|
||||
fmt.Printf("error: %v\n", err[i])
|
||||
}
|
||||
panic("failed to create doc")
|
||||
}
|
||||
return leftDoc, rightDoc
|
||||
}
|
||||
|
||||
func TestCompareSchemas_RefIgnore(t *testing.T) {
|
||||
left := `components:
|
||||
schemas:
|
||||
|
||||
Reference in New Issue
Block a user