Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update gnostic to use yaml.v3 #194

Merged
merged 14 commits into from
Jul 14, 2020
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/petstore-builder/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func testBuilder(version string, t *testing.T) {
// Verify that the generated text matches our reference.
err = exec.Command("diff", textFile, textReference).Run()
if err != nil {
t.Logf("Diff failed: %+v", err)
t.Logf("Diff %s vs %s failed: %+v", textFile, textReference, err)
t.FailNow()
}

Expand Down
10 changes: 4 additions & 6 deletions compiler/extension-handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,16 @@ package compiler

import (
"bytes"
"errors"
"fmt"
"os/exec"

"strings"

"errors"

"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/ptypes/any"
ext_plugin "github.com/googleapis/gnostic/extensions"
yaml "gopkg.in/yaml.v2"
yaml "gopkg.in/yaml.v3"
)

// ExtensionHandler describes a binary that is called by the compiler to handle specification extensions.
Expand All @@ -35,7 +34,7 @@ type ExtensionHandler struct {
}

// HandleExtension calls a binary extension handler.
func HandleExtension(context *Context, in interface{}, extensionName string) (bool, *any.Any, error) {
func HandleExtension(context *Context, in *yaml.Node, extensionName string) (bool, *any.Any, error) {
handled := false
var errFromPlugin error
var outFromPlugin *any.Any
Expand All @@ -54,7 +53,7 @@ func HandleExtension(context *Context, in interface{}, extensionName string) (bo
return handled, outFromPlugin, errFromPlugin
}

func (extensionHandlers *ExtensionHandler) handle(in interface{}, extensionName string) (*any.Any, error) {
func (extensionHandlers *ExtensionHandler) handle(in *yaml.Node, extensionName string) (*any.Any, error) {
if extensionHandlers.Name != "" {
binary, _ := yaml.Marshal(in)

Expand All @@ -76,7 +75,6 @@ func (extensionHandlers *ExtensionHandler) handle(in interface{}, extensionName
cmd := exec.Command(extensionHandlers.Name)
cmd.Stdin = bytes.NewReader(requestBytes)
output, err := cmd.Output()

if err != nil {
fmt.Printf("Error: %+v\n", err)
return nil, err
Expand Down
Loading