Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
11 changes: 11 additions & 0 deletions .gitpod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This configuration file was automatically generated by Gitpod.
# Please adjust to your needs (see https://www.gitpod.io/docs/introduction/learn-gitpod/gitpod-yaml)
# and commit this file to your remote git repository to share the goodness with others.

# Learn more from ready-to-use templates: https://www.gitpod.io/docs/introduction/getting-started/quickstart

tasks:
- init: go get && go build ./... && go test ./...
command: go run .


4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ This tool will accept an OpenAPI/Swagger definition (yaml or JSON) and generate

To install, have Go installed with `$GOPATH/bin` on your `$PATH` and then:
```
go install github.com/NYTimes/openapi2proto/cmd/openapi2proto@latest
go install github.com/sanposhiho/openapi2proto/cmd/openapi2proto@latest
```

On Older versions of Go (<1.15), use:
```
go get -u github.com/NYTimes/openapi2proto/cmd/openapi2proto
go get -u github.com/sanposhiho/openapi2proto/cmd/openapi2proto
```

## Run
Expand Down
6 changes: 3 additions & 3 deletions cmd/openapi2proto/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"io"
"os"

"github.com/NYTimes/openapi2proto"
"github.com/NYTimes/openapi2proto/compiler"
"github.com/NYTimes/openapi2proto/protobuf"
"github.com/sanposhiho/openapi2proto"
"github.com/sanposhiho/openapi2proto/compiler"
"github.com/sanposhiho/openapi2proto/protobuf"
"github.com/pkg/errors"
)

Expand Down
8 changes: 5 additions & 3 deletions compiler/compiler.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// Package compiler contains tools to take openapi.* definitions and
// compile them into protobuf.* structures.
package compiler // github.com/NYTimes/openapi2proto/compiler
package compiler // github.com/sanposhiho/openapi2proto/compiler

import (
"bytes"
"sort"
"strings"

"github.com/NYTimes/openapi2proto/openapi"
"github.com/NYTimes/openapi2proto/protobuf"
"github.com/sanposhiho/openapi2proto/openapi"
"github.com/sanposhiho/openapi2proto/protobuf"
"github.com/pkg/errors"
)

Expand Down Expand Up @@ -339,6 +339,7 @@ func (c *compileCtx) compilePath(path string, p *openapi.Path) error {
if err != nil {
return errors.Wrapf(err, `failed to compile parameters for %s`, endpointName)
}
reqType = c.getBoxedType(reqType)
m, ok := reqType.(*protobuf.Message)
if !ok {
return errors.Errorf(`type %s is not a message (%T)`, reqName, reqType)
Expand Down Expand Up @@ -388,6 +389,7 @@ func (c *compileCtx) compilePath(path string, p *openapi.Path) error {
}

if resType != nil {
resType = c.getBoxedType(resType)
m, ok := resType.(*protobuf.Message)
if !ok {
return errors.Errorf(`got non-message type (%T) in response for %s`, resType, endpointName)
Expand Down
6 changes: 3 additions & 3 deletions compiler/interface.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package compiler

import (
"github.com/NYTimes/openapi2proto/internal/option"
"github.com/sanposhiho/openapi2proto/internal/option"

"github.com/NYTimes/openapi2proto/openapi"
"github.com/NYTimes/openapi2proto/protobuf"
"github.com/sanposhiho/openapi2proto/openapi"
"github.com/sanposhiho/openapi2proto/protobuf"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion compiler/options.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package compiler

import "github.com/NYTimes/openapi2proto/internal/option"
import "github.com/sanposhiho/openapi2proto/internal/option"

const (
optkeyAnnotation = "annotation"
Expand Down
2 changes: 1 addition & 1 deletion compiler/parameter.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package compiler

import "github.com/NYTimes/openapi2proto/protobuf"
import "github.com/sanposhiho/openapi2proto/protobuf"

// Parameter is used to represent a parameter.
type Parameter struct {
Expand Down
2 changes: 1 addition & 1 deletion compiler/strings.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strings"
"unicode"

"github.com/NYTimes/openapi2proto/openapi"
"github.com/sanposhiho/openapi2proto/openapi"
)

// since we're not considering unicode here, we're not using unicode.*
Expand Down
2 changes: 1 addition & 1 deletion compiler/strings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package compiler
import (
"testing"

"github.com/NYTimes/openapi2proto/openapi"
"github.com/sanposhiho/openapi2proto/openapi"
)

type endpointNamingConversionTestCase struct {
Expand Down
26,483 changes: 14,166 additions & 12,317 deletions fixtures/kubernetes.proto

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/NYTimes/openapi2proto
module github.com/sanposhiho/openapi2proto

go 1.12

Expand Down
2 changes: 1 addition & 1 deletion internal/option/option.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package option // github.com/NYTimes/openapi2proto/internal/option
package option // github.com/sanposhiho/openapi2proto/internal/option

type Option interface {
Name() string
Expand Down
2 changes: 1 addition & 1 deletion openapi/external.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ func (c *resolveCtx) resolve(rv reflect.Value) (reflect.Value, error) {
refValue = refValue.Elem()

if refValue.Kind() != reflect.String {
return zeroval, errors.Errorf("'$ref' key contains non-string element (%s)", refValue.Type())
return rv, nil
}

ref := refValue.String()
Expand Down
2 changes: 1 addition & 1 deletion openapi/interface.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package openapi

import (
"github.com/NYTimes/openapi2proto/internal/option"
"github.com/sanposhiho/openapi2proto/internal/option"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion openapi/openapi.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Package openapi contains tools to read in OpenAPI specifications
// so that they can be passed to the openapi2proto compiler
package openapi // github.com/NYTimes/openapi2proto/openapi
package openapi // github.com/sanposhiho/openapi2proto/openapi

import (
"bytes"
Expand Down
2 changes: 1 addition & 1 deletion openapi/openapi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"path/filepath"
"testing"

"github.com/NYTimes/openapi2proto/openapi"
"github.com/sanposhiho/openapi2proto/openapi"
)

func TestLoadFile(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion openapi/options.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package openapi

import "github.com/NYTimes/openapi2proto/internal/option"
import "github.com/sanposhiho/openapi2proto/internal/option"

// WithDir returns an option to specify the directory from
// which external references should be resolved.
Expand Down
6 changes: 3 additions & 3 deletions options.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package openapi2proto

import (
"github.com/NYTimes/openapi2proto/compiler"
"github.com/NYTimes/openapi2proto/internal/option"
"github.com/NYTimes/openapi2proto/protobuf"
"github.com/sanposhiho/openapi2proto/compiler"
"github.com/sanposhiho/openapi2proto/internal/option"
"github.com/sanposhiho/openapi2proto/protobuf"
)

const (
Expand Down
14 changes: 6 additions & 8 deletions proto_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
"strings"
"testing"

"github.com/NYTimes/openapi2proto"
"github.com/NYTimes/openapi2proto/compiler"
"github.com/NYTimes/openapi2proto/protobuf"
"github.com/sanposhiho/openapi2proto"
"github.com/sanposhiho/openapi2proto/compiler"
"github.com/sanposhiho/openapi2proto/protobuf"
"github.com/pmezard/go-difflib/difflib"
)

Expand Down Expand Up @@ -151,11 +151,9 @@ func TestGenerateProto(t *testing.T) {
{
fixturePath: "fixtures/missing_type.json",
},
/*
{
fixturePath: "fixtures/kubernetes.json",
},
*/
{
fixturePath: "fixtures/kubernetes.json",
},
{
fixturePath: "fixtures/accountv1-0.json",
},
Expand Down
2 changes: 1 addition & 1 deletion protobuf/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package protobuf
import (
"io"

"github.com/NYTimes/openapi2proto/internal/option"
"github.com/sanposhiho/openapi2proto/internal/option"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion protobuf/options.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package protobuf

import "github.com/NYTimes/openapi2proto/internal/option"
import "github.com/sanposhiho/openapi2proto/internal/option"

const (
optkeyIndent = "indent"
Expand Down
2 changes: 1 addition & 1 deletion protobuf/protobuf.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Package protobuf contains structures to represent a protobuf
// definition, and tools to create textual representation of the
// definition.
package protobuf // github.com/NYTimes/openapi2proto/protobuf
package protobuf // github.com/sanposhiho/openapi2proto/protobuf
2 changes: 1 addition & 1 deletion protobuf/protobuf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"bytes"
"testing"

"github.com/NYTimes/openapi2proto/protobuf"
"github.com/sanposhiho/openapi2proto/protobuf"
"github.com/pmezard/go-difflib/difflib"
)

Expand Down
8 changes: 4 additions & 4 deletions transpiler.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package openapi2proto // github.com/NYTimes/openapi2proto
package openapi2proto // github.com/sanposhiho/openapi2proto

import (
"io"

"github.com/NYTimes/openapi2proto/compiler"
"github.com/NYTimes/openapi2proto/openapi"
"github.com/NYTimes/openapi2proto/protobuf"
"github.com/sanposhiho/openapi2proto/compiler"
"github.com/sanposhiho/openapi2proto/openapi"
"github.com/sanposhiho/openapi2proto/protobuf"
"github.com/pkg/errors"
)

Expand Down