From 22cc4cb4bcee881c996f1feee4dfc0b05da486bb Mon Sep 17 00:00:00 2001 From: Koichi Shiraishi Date: Sun, 26 Sep 2021 17:16:27 +0900 Subject: [PATCH 1/4] go.mod: fix module and cleanup Signed-off-by: Koichi Shiraishi --- go.mod | 4 ++-- go.sum | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index c4b8f1fe..9d757e7c 100644 --- a/go.mod +++ b/go.mod @@ -1,9 +1,9 @@ -module github.com/googleapis/gnostic +module github.com/google/gnostic go 1.12 require ( - github.com/davecgh/go-spew v1.1.1 + github.com/davecgh/go-spew v1.1.1 // indirect github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815 github.com/golang/protobuf v1.5.2 github.com/kr/pretty v0.2.0 // indirect diff --git a/go.sum b/go.sum index 8761c49f..16994e41 100644 --- a/go.sum +++ b/go.sum @@ -20,8 +20,6 @@ github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:W github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.1 h1:jAbXjIeW2ZSW2AwFxlGTDoc2CjI2XujLkV3ArsZFCvc= -github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM= github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= From 05ffbf466bd61225338fbea51d0c583cd699cf3d Mon Sep 17 00:00:00 2001 From: Koichi Shiraishi Date: Sun, 26 Sep 2021 17:23:24 +0900 Subject: [PATCH 2/4] all: replace import path to 'github.com/google/gnostic' Signed-off-by: Koichi Shiraishi --- apps/disco/main.go | 4 ++-- apps/parse-linter-output/main.go | 2 +- apps/petstore-builder/petstore-v2.go | 2 +- apps/petstore-builder/petstore-v3.go | 2 +- apps/protoc-gen-openapi/generator/openapi-v3.go | 2 +- apps/protoc-gen-openapi/main.go | 2 +- apps/report-messages/main.go | 4 ++-- apps/report/main.go | 4 ++-- apps/vocabulary-operations/main.go | 4 ++-- compiler/extensions.go | 2 +- compiler/helpers.go | 2 +- conversions/openapiv2.go | 4 ++-- conversions/openapiv3.go | 4 ++-- discovery/discovery.go | 2 +- discovery/document.go | 2 +- discovery/list.go | 2 +- generate-gnostic/domain.go | 2 +- generate-gnostic/generate-compiler.go | 2 +- generate-gnostic/generate-extension.go | 14 +++++++------- generate-gnostic/generate-proto.go | 2 +- generate-gnostic/main.go | 4 ++-- generate-gnostic/types.go | 2 +- gnostic.go | 2 +- gnostic_test.go | 2 +- jsonwriter/writer_test.go | 4 ++-- lib/gnostic.go | 14 +++++++------- linters/go/gnostic-lint-descriptions/linter_v2.go | 4 ++-- linters/go/gnostic-lint-descriptions/linter_v3.go | 4 ++-- linters/go/gnostic-lint-descriptions/main.go | 6 +++--- linters/go/gnostic-lint-paths/main.go | 6 +++--- metrics/lint/aip-linterv2.go | 4 ++-- metrics/lint/aip-linterv3.go | 4 ++-- metrics/vocabulary/difference.go | 2 +- metrics/vocabulary/discovery.go | 4 ++-- metrics/vocabulary/filterCommon.go | 2 +- metrics/vocabulary/intersection.go | 2 +- metrics/vocabulary/openapiv2.go | 4 ++-- metrics/vocabulary/openapiv3.go | 4 ++-- metrics/vocabulary/union.go | 2 +- metrics/vocabulary/version.go | 2 +- metrics/vocabulary/vocabulary.go | 2 +- metrics/vocabulary/vocabulary_test.go | 8 ++++---- openapiv2/OpenAPIv2.go | 2 +- openapiv2/document.go | 2 +- openapiv3/OpenAPIv3.go | 2 +- openapiv3/document.go | 2 +- openapiv3/schema-generator/main.go | 2 +- plugins/environment.go | 8 ++++---- plugins/gnostic-analyze/main.go | 8 ++++---- plugins/gnostic-analyze/statistics/statsv2.go | 2 +- plugins/gnostic-analyze/statistics/statsv3.go | 2 +- plugins/gnostic-analyze/summarize/main.go | 2 +- plugins/gnostic-complexity/main.go | 8 ++++---- plugins/gnostic-linter/main.go | 8 ++++---- plugins/gnostic-plugin-request/main.go | 8 ++++---- plugins/gnostic-process-plugin-response/main.go | 2 +- plugins/gnostic-summary/main.go | 8 ++++---- plugins/gnostic-vocabulary/main.go | 12 ++++++------ surface/model_openapiv2.go | 4 ++-- surface/model_openapiv3.go | 4 ++-- tools/format-schema/main.go | 2 +- tools/j2y2j/main.go | 2 +- 62 files changed, 121 insertions(+), 121 deletions(-) diff --git a/apps/disco/main.go b/apps/disco/main.go index 59bc19bc..62fb172f 100644 --- a/apps/disco/main.go +++ b/apps/disco/main.go @@ -23,8 +23,8 @@ import ( "github.com/docopt/docopt-go" "github.com/golang/protobuf/proto" - "github.com/googleapis/gnostic/conversions" - discovery "github.com/googleapis/gnostic/discovery" + "github.com/google/gnostic/conversions" + discovery "github.com/google/gnostic/discovery" ) func main() { diff --git a/apps/parse-linter-output/main.go b/apps/parse-linter-output/main.go index a1c47938..c310f296 100644 --- a/apps/parse-linter-output/main.go +++ b/apps/parse-linter-output/main.go @@ -5,7 +5,7 @@ import ( "fmt" "os" - lint "github.com/googleapis/gnostic/metrics/lint" + lint "github.com/google/gnostic/metrics/lint" ) func main() { diff --git a/apps/petstore-builder/petstore-v2.go b/apps/petstore-builder/petstore-v2.go index 83457fa3..4fc977b6 100644 --- a/apps/petstore-builder/petstore-v2.go +++ b/apps/petstore-builder/petstore-v2.go @@ -15,7 +15,7 @@ package main import ( - v2 "github.com/googleapis/gnostic/openapiv2" + v2 "github.com/google/gnostic/openapiv2" ) func buildDocumentV2() *v2.Document { diff --git a/apps/petstore-builder/petstore-v3.go b/apps/petstore-builder/petstore-v3.go index 240a3435..9042ff95 100644 --- a/apps/petstore-builder/petstore-v3.go +++ b/apps/petstore-builder/petstore-v3.go @@ -15,7 +15,7 @@ package main import ( - v3 "github.com/googleapis/gnostic/openapiv3" + v3 "github.com/google/gnostic/openapiv3" ) func buildDocumentV3() *v3.Document { diff --git a/apps/protoc-gen-openapi/generator/openapi-v3.go b/apps/protoc-gen-openapi/generator/openapi-v3.go index 4211c978..5a81ae63 100644 --- a/apps/protoc-gen-openapi/generator/openapi-v3.go +++ b/apps/protoc-gen-openapi/generator/openapi-v3.go @@ -22,7 +22,7 @@ import ( "sort" "strings" - v3 "github.com/googleapis/gnostic/openapiv3" + v3 "github.com/google/gnostic/openapiv3" "google.golang.org/genproto/googleapis/api/annotations" "google.golang.org/protobuf/compiler/protogen" "google.golang.org/protobuf/proto" diff --git a/apps/protoc-gen-openapi/main.go b/apps/protoc-gen-openapi/main.go index 081a373a..3d16d423 100644 --- a/apps/protoc-gen-openapi/main.go +++ b/apps/protoc-gen-openapi/main.go @@ -16,7 +16,7 @@ package main import ( - "github.com/googleapis/gnostic/apps/protoc-gen-openapi/generator" + "github.com/google/gnostic/apps/protoc-gen-openapi/generator" "google.golang.org/protobuf/compiler/protogen" ) diff --git a/apps/report-messages/main.go b/apps/report-messages/main.go index 74c43f06..84388b3a 100644 --- a/apps/report-messages/main.go +++ b/apps/report-messages/main.go @@ -22,9 +22,9 @@ import ( "os" "github.com/golang/protobuf/proto" - "github.com/googleapis/gnostic/printer" + "github.com/google/gnostic/printer" - plugins "github.com/googleapis/gnostic/plugins" + plugins "github.com/google/gnostic/plugins" ) func readMessagesFromFileWithName(filename string) *plugins.Messages { diff --git a/apps/report/main.go b/apps/report/main.go index c259d843..dce382ee 100644 --- a/apps/report/main.go +++ b/apps/report/main.go @@ -24,9 +24,9 @@ import ( "os" "github.com/golang/protobuf/proto" - "github.com/googleapis/gnostic/printer" + "github.com/google/gnostic/printer" - pb "github.com/googleapis/gnostic/openapiv2" + pb "github.com/google/gnostic/openapiv2" ) func readDocumentFromFileWithName(filename string) (*pb.Document, error) { diff --git a/apps/vocabulary-operations/main.go b/apps/vocabulary-operations/main.go index d050fbb2..5a071489 100644 --- a/apps/vocabulary-operations/main.go +++ b/apps/vocabulary-operations/main.go @@ -23,8 +23,8 @@ import ( "strings" "github.com/golang/protobuf/proto" - metrics "github.com/googleapis/gnostic/metrics" - vocabulary "github.com/googleapis/gnostic/metrics/vocabulary" + metrics "github.com/google/gnostic/metrics" + vocabulary "github.com/google/gnostic/metrics/vocabulary" ) // openVocabularyFiles uses standard input to create a slice of diff --git a/compiler/extensions.go b/compiler/extensions.go index 20848a0a..962cb968 100644 --- a/compiler/extensions.go +++ b/compiler/extensions.go @@ -22,7 +22,7 @@ import ( "github.com/golang/protobuf/proto" "github.com/golang/protobuf/ptypes/any" - extensions "github.com/googleapis/gnostic/extensions" + extensions "github.com/google/gnostic/extensions" yaml "gopkg.in/yaml.v3" ) diff --git a/compiler/helpers.go b/compiler/helpers.go index 48f02f39..3dff9e36 100644 --- a/compiler/helpers.go +++ b/compiler/helpers.go @@ -20,7 +20,7 @@ import ( "sort" "strconv" - "github.com/googleapis/gnostic/jsonschema" + "github.com/google/gnostic/jsonschema" "gopkg.in/yaml.v3" ) diff --git a/conversions/openapiv2.go b/conversions/openapiv2.go index 70365536..71a41978 100644 --- a/conversions/openapiv2.go +++ b/conversions/openapiv2.go @@ -18,8 +18,8 @@ import ( "log" "net/url" - openapi2 "github.com/googleapis/gnostic/openapiv2" - discovery "github.com/googleapis/gnostic/discovery" + openapi2 "github.com/google/gnostic/openapiv2" + discovery "github.com/google/gnostic/discovery" ) func addOpenAPI2SchemaForSchema(d *openapi2.Document, name string, schema *discovery.Schema) { diff --git a/conversions/openapiv3.go b/conversions/openapiv3.go index ab0a7eaf..b710fabb 100644 --- a/conversions/openapiv3.go +++ b/conversions/openapiv3.go @@ -19,8 +19,8 @@ import ( "net/url" "strings" - openapi3 "github.com/googleapis/gnostic/openapiv3" - discovery "github.com/googleapis/gnostic/discovery" + openapi3 "github.com/google/gnostic/openapiv3" + discovery "github.com/google/gnostic/discovery" ) func pathForMethod(path string) string { diff --git a/discovery/discovery.go b/discovery/discovery.go index ad62277c..07543230 100644 --- a/discovery/discovery.go +++ b/discovery/discovery.go @@ -18,7 +18,7 @@ package discovery_v1 import ( "fmt" - "github.com/googleapis/gnostic/compiler" + "github.com/google/gnostic/compiler" "gopkg.in/yaml.v3" "regexp" "strings" diff --git a/discovery/document.go b/discovery/document.go index ab6a5c86..13316d1b 100644 --- a/discovery/document.go +++ b/discovery/document.go @@ -15,7 +15,7 @@ package discovery_v1 import ( - "github.com/googleapis/gnostic/compiler" + "github.com/google/gnostic/compiler" ) // FetchDocumentBytes downloads the bytes of a discovery document from a URL. diff --git a/discovery/list.go b/discovery/list.go index ebe01991..257b67da 100644 --- a/discovery/list.go +++ b/discovery/list.go @@ -19,7 +19,7 @@ import ( "errors" "strings" - "github.com/googleapis/gnostic/compiler" + "github.com/google/gnostic/compiler" ) // APIsListServiceURL is the URL for the Google APIs Discovery Service diff --git a/generate-gnostic/domain.go b/generate-gnostic/domain.go index 1487dec9..cb67b677 100644 --- a/generate-gnostic/domain.go +++ b/generate-gnostic/domain.go @@ -21,7 +21,7 @@ import ( "sort" "strings" - "github.com/googleapis/gnostic/jsonschema" + "github.com/google/gnostic/jsonschema" ) // Domain models a collection of types that is defined by a schema. diff --git a/generate-gnostic/generate-compiler.go b/generate-gnostic/generate-compiler.go index 41723237..997db1a5 100644 --- a/generate-gnostic/generate-compiler.go +++ b/generate-gnostic/generate-compiler.go @@ -20,7 +20,7 @@ import ( "sort" "strings" - "github.com/googleapis/gnostic/printer" + "github.com/google/gnostic/printer" ) // patternNames hands out unique names for a given string. diff --git a/generate-gnostic/generate-extension.go b/generate-gnostic/generate-extension.go index e3b990bb..cb90760e 100644 --- a/generate-gnostic/generate-extension.go +++ b/generate-gnostic/generate-extension.go @@ -26,9 +26,9 @@ import ( "sort" "strings" - "github.com/googleapis/gnostic/compiler" - "github.com/googleapis/gnostic/jsonschema" - "github.com/googleapis/gnostic/printer" + "github.com/google/gnostic/compiler" + "github.com/google/gnostic/jsonschema" + "github.com/google/gnostic/printer" ) var protoOptionsForExtensions = []ProtoOption{ @@ -272,7 +272,7 @@ func generateExtension(schemaFile string, outDir string) error { "fmt", "regexp", "strings", - "github.com/googleapis/gnostic/compiler", + "github.com/google/gnostic/compiler", "gopkg.in/yaml.v3", }) goFilename := path.Join(protoOutDirectory, outFileBaseName+".go") @@ -287,7 +287,7 @@ func generateExtension(schemaFile string, outDir string) error { // TODO: This path is currently fixed to the location of the samples. // Can we make it relative, perhaps with an option or by generating // a go.mod file for the generated extension handler? - outDirRelativeToPackageRoot := "github.com/googleapis/gnostic/extensions/sample/" + outDir + outDirRelativeToPackageRoot := "github.com/google/gnostic/extensions/sample/" + outDir var extensionNameKeys []string for k := range extensionNameToMessageName { @@ -315,8 +315,8 @@ func generateExtension(schemaFile string, outDir string) error { extMainCode := fmt.Sprintf(additionalCompilerCodeWithMain, cases) imports := []string{ "github.com/golang/protobuf/proto", - "github.com/googleapis/gnostic/extensions", - "github.com/googleapis/gnostic/compiler", + "github.com/google/gnostic/extensions", + "github.com/google/gnostic/compiler", "gopkg.in/yaml.v3", outDirRelativeToPackageRoot + "/" + "proto", } diff --git a/generate-gnostic/generate-proto.go b/generate-gnostic/generate-proto.go index 6b56d271..1fe0eb99 100644 --- a/generate-gnostic/generate-proto.go +++ b/generate-gnostic/generate-proto.go @@ -18,7 +18,7 @@ import ( "fmt" "strings" - "github.com/googleapis/gnostic/printer" + "github.com/google/gnostic/printer" ) // ProtoOption represents an option to be added to generated .proto files. diff --git a/generate-gnostic/main.go b/generate-gnostic/main.go index 34062f2e..c198809b 100644 --- a/generate-gnostic/main.go +++ b/generate-gnostic/main.go @@ -28,7 +28,7 @@ import ( "runtime" "strings" - "github.com/googleapis/gnostic/jsonschema" + "github.com/google/gnostic/jsonschema" ) // License is the software license applied to generated code. @@ -193,7 +193,7 @@ func generateOpenAPIModel(version string) error { "gopkg.in/yaml.v3", "strings", "regexp", - "github.com/googleapis/gnostic/compiler", + "github.com/google/gnostic/compiler", } // generate the compiler log.Printf("Generating compiler support code") diff --git a/generate-gnostic/types.go b/generate-gnostic/types.go index 917296cc..df148d70 100644 --- a/generate-gnostic/types.go +++ b/generate-gnostic/types.go @@ -18,7 +18,7 @@ import ( "fmt" "strings" - "github.com/googleapis/gnostic/jsonschema" + "github.com/google/gnostic/jsonschema" ) /// Type Modeling diff --git a/gnostic.go b/gnostic.go index 24a2760c..2de60601 100644 --- a/gnostic.go +++ b/gnostic.go @@ -35,7 +35,7 @@ import ( "fmt" "os" - "github.com/googleapis/gnostic/lib" + "github.com/google/gnostic/lib" ) func main() { diff --git a/gnostic_test.go b/gnostic_test.go index 2dfe628e..4cb1609a 100644 --- a/gnostic_test.go +++ b/gnostic_test.go @@ -22,7 +22,7 @@ import ( "strings" "testing" - "github.com/googleapis/gnostic/lib" + "github.com/google/gnostic/lib" ) func isURL(path string) bool { diff --git a/jsonwriter/writer_test.go b/jsonwriter/writer_test.go index a4e2477a..b714e609 100644 --- a/jsonwriter/writer_test.go +++ b/jsonwriter/writer_test.go @@ -17,8 +17,8 @@ package jsonwriter_test import ( "testing" - "github.com/googleapis/gnostic/compiler" - "github.com/googleapis/gnostic/jsonwriter" + "github.com/google/gnostic/compiler" + "github.com/google/gnostic/jsonwriter" "gopkg.in/yaml.v3" ) diff --git a/lib/gnostic.go b/lib/gnostic.go index 7b642cf9..c33cb444 100644 --- a/lib/gnostic.go +++ b/lib/gnostic.go @@ -29,13 +29,13 @@ import ( "time" "github.com/golang/protobuf/proto" - "github.com/googleapis/gnostic/compiler" - discovery_v1 "github.com/googleapis/gnostic/discovery" - "github.com/googleapis/gnostic/jsonwriter" - openapi_v2 "github.com/googleapis/gnostic/openapiv2" - openapi_v3 "github.com/googleapis/gnostic/openapiv3" - plugins "github.com/googleapis/gnostic/plugins" - surface "github.com/googleapis/gnostic/surface" + "github.com/google/gnostic/compiler" + discovery_v1 "github.com/google/gnostic/discovery" + "github.com/google/gnostic/jsonwriter" + openapi_v2 "github.com/google/gnostic/openapiv2" + openapi_v3 "github.com/google/gnostic/openapiv3" + plugins "github.com/google/gnostic/plugins" + surface "github.com/google/gnostic/surface" "gopkg.in/yaml.v3" ) diff --git a/linters/go/gnostic-lint-descriptions/linter_v2.go b/linters/go/gnostic-lint-descriptions/linter_v2.go index fd7d5da5..3e44f300 100644 --- a/linters/go/gnostic-lint-descriptions/linter_v2.go +++ b/linters/go/gnostic-lint-descriptions/linter_v2.go @@ -14,8 +14,8 @@ package main import ( - openapi "github.com/googleapis/gnostic/openapiv2" - plugins "github.com/googleapis/gnostic/plugins" + openapi "github.com/google/gnostic/openapiv2" + plugins "github.com/google/gnostic/plugins" ) // DocumentLinter contains information collected about an API description. diff --git a/linters/go/gnostic-lint-descriptions/linter_v3.go b/linters/go/gnostic-lint-descriptions/linter_v3.go index 7b9894d1..6f8684c6 100644 --- a/linters/go/gnostic-lint-descriptions/linter_v3.go +++ b/linters/go/gnostic-lint-descriptions/linter_v3.go @@ -15,8 +15,8 @@ package main import ( - openapi "github.com/googleapis/gnostic/openapiv3" - plugins "github.com/googleapis/gnostic/plugins" + openapi "github.com/google/gnostic/openapiv3" + plugins "github.com/google/gnostic/plugins" ) // DocumentLinter contains information collected about an API description. diff --git a/linters/go/gnostic-lint-descriptions/main.go b/linters/go/gnostic-lint-descriptions/main.go index a3416721..3b8a7daf 100644 --- a/linters/go/gnostic-lint-descriptions/main.go +++ b/linters/go/gnostic-lint-descriptions/main.go @@ -22,9 +22,9 @@ package main import ( "github.com/golang/protobuf/proto" - openapiv2 "github.com/googleapis/gnostic/openapiv2" - openapiv3 "github.com/googleapis/gnostic/openapiv3" - plugins "github.com/googleapis/gnostic/plugins" + openapiv2 "github.com/google/gnostic/openapiv2" + openapiv3 "github.com/google/gnostic/openapiv3" + plugins "github.com/google/gnostic/plugins" ) type DocumentLinter interface { diff --git a/linters/go/gnostic-lint-paths/main.go b/linters/go/gnostic-lint-paths/main.go index 81934453..73330ee5 100644 --- a/linters/go/gnostic-lint-paths/main.go +++ b/linters/go/gnostic-lint-paths/main.go @@ -19,9 +19,9 @@ package main import ( "github.com/golang/protobuf/proto" - openapiv2 "github.com/googleapis/gnostic/openapiv2" - openapiv3 "github.com/googleapis/gnostic/openapiv3" - plugins "github.com/googleapis/gnostic/plugins" + openapiv2 "github.com/google/gnostic/openapiv2" + openapiv3 "github.com/google/gnostic/openapiv3" + plugins "github.com/google/gnostic/plugins" ) func checkPathsV2(document *openapiv2.Document, messages []*plugins.Message) []*plugins.Message { diff --git a/metrics/lint/aip-linterv2.go b/metrics/lint/aip-linterv2.go index 31fc8939..ee4b17ef 100644 --- a/metrics/lint/aip-linterv2.go +++ b/metrics/lint/aip-linterv2.go @@ -17,8 +17,8 @@ package linter import ( "fmt" - rules "github.com/googleapis/gnostic/metrics/rules" - pb "github.com/googleapis/gnostic/openapiv2" + rules "github.com/google/gnostic/metrics/rules" + pb "github.com/google/gnostic/openapiv2" ) // fillProtoStructure takes a slice of rules and coverts them to a slice of diff --git a/metrics/lint/aip-linterv3.go b/metrics/lint/aip-linterv3.go index 534aad6a..c2737836 100644 --- a/metrics/lint/aip-linterv3.go +++ b/metrics/lint/aip-linterv3.go @@ -18,8 +18,8 @@ import ( "fmt" "os" - rules "github.com/googleapis/gnostic/metrics/rules" - openapi_v3 "github.com/googleapis/gnostic/openapiv3" + rules "github.com/google/gnostic/metrics/rules" + openapi_v3 "github.com/google/gnostic/openapiv3" ) // processParametersV2 loops over the parameters of component and creates a diff --git a/metrics/vocabulary/difference.go b/metrics/vocabulary/difference.go index 8c2ad490..9745099c 100644 --- a/metrics/vocabulary/difference.go +++ b/metrics/vocabulary/difference.go @@ -15,7 +15,7 @@ package vocabulary import ( - metrics "github.com/googleapis/gnostic/metrics" + metrics "github.com/google/gnostic/metrics" ) // mapDifference finds the difference between two Vocabularies. diff --git a/metrics/vocabulary/discovery.go b/metrics/vocabulary/discovery.go index 7c2145d3..3e8d8032 100644 --- a/metrics/vocabulary/discovery.go +++ b/metrics/vocabulary/discovery.go @@ -15,8 +15,8 @@ package vocabulary import ( - discovery_v1 "github.com/googleapis/gnostic/discovery" - metrics "github.com/googleapis/gnostic/metrics" + discovery_v1 "github.com/google/gnostic/discovery" + metrics "github.com/google/gnostic/metrics" ) func (vocab *Vocabulary) processMethodDiscovery(operation *discovery_v1.Method) { diff --git a/metrics/vocabulary/filterCommon.go b/metrics/vocabulary/filterCommon.go index bcbd1679..39c4698a 100644 --- a/metrics/vocabulary/filterCommon.go +++ b/metrics/vocabulary/filterCommon.go @@ -15,7 +15,7 @@ package vocabulary import ( - metrics "github.com/googleapis/gnostic/metrics" + metrics "github.com/google/gnostic/metrics" ) // FilterCommon implements the difference operation amongst a slice of Vocabularies. diff --git a/metrics/vocabulary/intersection.go b/metrics/vocabulary/intersection.go index d417df82..58b22718 100644 --- a/metrics/vocabulary/intersection.go +++ b/metrics/vocabulary/intersection.go @@ -15,7 +15,7 @@ package vocabulary import ( - metrics "github.com/googleapis/gnostic/metrics" + metrics "github.com/google/gnostic/metrics" ) // mapIntersection finds the intersection between two Vocabularies. diff --git a/metrics/vocabulary/openapiv2.go b/metrics/vocabulary/openapiv2.go index 81f725fd..38875cbc 100644 --- a/metrics/vocabulary/openapiv2.go +++ b/metrics/vocabulary/openapiv2.go @@ -15,8 +15,8 @@ package vocabulary import ( - metrics "github.com/googleapis/gnostic/metrics" - openapi_v2 "github.com/googleapis/gnostic/openapiv2" + metrics "github.com/google/gnostic/metrics" + openapi_v2 "github.com/google/gnostic/openapiv2" ) func (vocab *Vocabulary) processOperationV2(operation *openapi_v2.Operation) { diff --git a/metrics/vocabulary/openapiv3.go b/metrics/vocabulary/openapiv3.go index b7e874fa..ab94df51 100644 --- a/metrics/vocabulary/openapiv3.go +++ b/metrics/vocabulary/openapiv3.go @@ -17,8 +17,8 @@ package vocabulary import ( "sort" - metrics "github.com/googleapis/gnostic/metrics" - openapi_v3 "github.com/googleapis/gnostic/openapiv3" + metrics "github.com/google/gnostic/metrics" + openapi_v3 "github.com/google/gnostic/openapiv3" ) func fillProtoStructures(m map[string]int) []*metrics.WordCount { diff --git a/metrics/vocabulary/union.go b/metrics/vocabulary/union.go index 10a8e718..57d05b8a 100644 --- a/metrics/vocabulary/union.go +++ b/metrics/vocabulary/union.go @@ -15,7 +15,7 @@ package vocabulary import ( - metrics "github.com/googleapis/gnostic/metrics" + metrics "github.com/google/gnostic/metrics" ) // Union implements the union operation between multiple Vocabularies. diff --git a/metrics/vocabulary/version.go b/metrics/vocabulary/version.go index 783a210c..7dd0de55 100644 --- a/metrics/vocabulary/version.go +++ b/metrics/vocabulary/version.go @@ -15,7 +15,7 @@ package vocabulary import ( - metrics "github.com/googleapis/gnostic/metrics" + metrics "github.com/google/gnostic/metrics" ) // fillVersionProto takes a newer and older version of a vocabularies and utilizes the diff --git a/metrics/vocabulary/vocabulary.go b/metrics/vocabulary/vocabulary.go index bb11368b..1ef1faea 100644 --- a/metrics/vocabulary/vocabulary.go +++ b/metrics/vocabulary/vocabulary.go @@ -24,7 +24,7 @@ import ( "sort" "strings" - metrics "github.com/googleapis/gnostic/metrics" + metrics "github.com/google/gnostic/metrics" "google.golang.org/protobuf/proto" ) diff --git a/metrics/vocabulary/vocabulary_test.go b/metrics/vocabulary/vocabulary_test.go index caefcda3..edf1f37f 100644 --- a/metrics/vocabulary/vocabulary_test.go +++ b/metrics/vocabulary/vocabulary_test.go @@ -21,10 +21,10 @@ import ( "testing" "github.com/golang/protobuf/jsonpb" - discovery "github.com/googleapis/gnostic/discovery" - metrics "github.com/googleapis/gnostic/metrics" - openapiv2 "github.com/googleapis/gnostic/openapiv2" - openapiv3 "github.com/googleapis/gnostic/openapiv3" + discovery "github.com/google/gnostic/discovery" + metrics "github.com/google/gnostic/metrics" + openapiv2 "github.com/google/gnostic/openapiv2" + openapiv3 "github.com/google/gnostic/openapiv3" ) func fillTestProtoStructure(words []string, count []int) []*metrics.WordCount { diff --git a/openapiv2/OpenAPIv2.go b/openapiv2/OpenAPIv2.go index 727d7f4a..0a595f9f 100644 --- a/openapiv2/OpenAPIv2.go +++ b/openapiv2/OpenAPIv2.go @@ -18,7 +18,7 @@ package openapi_v2 import ( "fmt" - "github.com/googleapis/gnostic/compiler" + "github.com/google/gnostic/compiler" "gopkg.in/yaml.v3" "regexp" "strings" diff --git a/openapiv2/document.go b/openapiv2/document.go index 56e5966b..c22f03fa 100644 --- a/openapiv2/document.go +++ b/openapiv2/document.go @@ -15,7 +15,7 @@ package openapi_v2 import ( - "github.com/googleapis/gnostic/compiler" + "github.com/google/gnostic/compiler" "gopkg.in/yaml.v3" ) diff --git a/openapiv3/OpenAPIv3.go b/openapiv3/OpenAPIv3.go index 607e33c7..58d63571 100644 --- a/openapiv3/OpenAPIv3.go +++ b/openapiv3/OpenAPIv3.go @@ -18,7 +18,7 @@ package openapi_v3 import ( "fmt" - "github.com/googleapis/gnostic/compiler" + "github.com/google/gnostic/compiler" "gopkg.in/yaml.v3" "regexp" "strings" diff --git a/openapiv3/document.go b/openapiv3/document.go index 999f7fd2..f64e52be 100644 --- a/openapiv3/document.go +++ b/openapiv3/document.go @@ -15,7 +15,7 @@ package openapi_v3 import ( - "github.com/googleapis/gnostic/compiler" + "github.com/google/gnostic/compiler" "gopkg.in/yaml.v3" ) diff --git a/openapiv3/schema-generator/main.go b/openapiv3/schema-generator/main.go index 3ee2ed41..a75002ff 100644 --- a/openapiv3/schema-generator/main.go +++ b/openapiv3/schema-generator/main.go @@ -29,7 +29,7 @@ import ( "unicode" "unicode/utf8" - "github.com/googleapis/gnostic/jsonschema" + "github.com/google/gnostic/jsonschema" ) // convert the first character of a string to lower case diff --git a/plugins/environment.go b/plugins/environment.go index f0ca035b..0a856aa4 100644 --- a/plugins/environment.go +++ b/plugins/environment.go @@ -14,10 +14,10 @@ import ( "github.com/golang/protobuf/proto" "github.com/golang/protobuf/ptypes/any" - openapiv2 "github.com/googleapis/gnostic/openapiv2" - openapiv3 "github.com/googleapis/gnostic/openapiv3" - discovery "github.com/googleapis/gnostic/discovery" - surface "github.com/googleapis/gnostic/surface" + openapiv2 "github.com/google/gnostic/openapiv2" + openapiv3 "github.com/google/gnostic/openapiv3" + discovery "github.com/google/gnostic/discovery" + surface "github.com/google/gnostic/surface" ) // Environment contains the environment of a plugin call. diff --git a/plugins/gnostic-analyze/main.go b/plugins/gnostic-analyze/main.go index 0d4babac..fd4cc174 100644 --- a/plugins/gnostic-analyze/main.go +++ b/plugins/gnostic-analyze/main.go @@ -30,12 +30,12 @@ import ( "path" "strings" - "github.com/googleapis/gnostic/plugins/gnostic-analyze/statistics" + "github.com/google/gnostic/plugins/gnostic-analyze/statistics" "github.com/golang/protobuf/proto" - openapiv2 "github.com/googleapis/gnostic/openapiv2" - openapiv3 "github.com/googleapis/gnostic/openapiv3" - plugins "github.com/googleapis/gnostic/plugins" + openapiv2 "github.com/google/gnostic/openapiv2" + openapiv3 "github.com/google/gnostic/openapiv3" + plugins "github.com/google/gnostic/plugins" ) // Record an error, then serialize and return a response. diff --git a/plugins/gnostic-analyze/statistics/statsv2.go b/plugins/gnostic-analyze/statistics/statsv2.go index b7199308..7f64e81d 100644 --- a/plugins/gnostic-analyze/statistics/statsv2.go +++ b/plugins/gnostic-analyze/statistics/statsv2.go @@ -18,7 +18,7 @@ import ( "fmt" "strings" - openapi "github.com/googleapis/gnostic/openapiv2" + openapi "github.com/google/gnostic/openapiv2" ) // DocumentStatistics contains information collected about an API description. diff --git a/plugins/gnostic-analyze/statistics/statsv3.go b/plugins/gnostic-analyze/statistics/statsv3.go index 7bd4ba0d..e7f8f0c9 100644 --- a/plugins/gnostic-analyze/statistics/statsv3.go +++ b/plugins/gnostic-analyze/statistics/statsv3.go @@ -15,7 +15,7 @@ package statistics import ( - openapi "github.com/googleapis/gnostic/openapiv3" + openapi "github.com/google/gnostic/openapiv3" ) // NewDocumentStatistics builds a new DocumentStatistics object. diff --git a/plugins/gnostic-analyze/summarize/main.go b/plugins/gnostic-analyze/summarize/main.go index c0119ce7..7056ee82 100644 --- a/plugins/gnostic-analyze/summarize/main.go +++ b/plugins/gnostic-analyze/summarize/main.go @@ -24,7 +24,7 @@ import ( "path/filepath" "sort" - "github.com/googleapis/gnostic/plugins/gnostic-analyze/statistics" + "github.com/google/gnostic/plugins/gnostic-analyze/statistics" ) // Results are collected in this global slice. diff --git a/plugins/gnostic-complexity/main.go b/plugins/gnostic-complexity/main.go index d3053c91..1e8543b9 100644 --- a/plugins/gnostic-complexity/main.go +++ b/plugins/gnostic-complexity/main.go @@ -20,10 +20,10 @@ import ( "path/filepath" "github.com/golang/protobuf/proto" - metrics "github.com/googleapis/gnostic/metrics" - openapiv2 "github.com/googleapis/gnostic/openapiv2" - openapiv3 "github.com/googleapis/gnostic/openapiv3" - plugins "github.com/googleapis/gnostic/plugins" + metrics "github.com/google/gnostic/metrics" + openapiv2 "github.com/google/gnostic/openapiv2" + openapiv3 "github.com/google/gnostic/openapiv3" + plugins "github.com/google/gnostic/plugins" ) // This is the main function for the plugin. diff --git a/plugins/gnostic-linter/main.go b/plugins/gnostic-linter/main.go index 68208b9d..826d5508 100644 --- a/plugins/gnostic-linter/main.go +++ b/plugins/gnostic-linter/main.go @@ -19,10 +19,10 @@ import ( "path/filepath" "github.com/golang/protobuf/proto" - lint "github.com/googleapis/gnostic/metrics/lint" - openapiv2 "github.com/googleapis/gnostic/openapiv2" - openapiv3 "github.com/googleapis/gnostic/openapiv3" - plugins "github.com/googleapis/gnostic/plugins" + lint "github.com/google/gnostic/metrics/lint" + openapiv2 "github.com/google/gnostic/openapiv2" + openapiv3 "github.com/google/gnostic/openapiv3" + plugins "github.com/google/gnostic/plugins" ) // Record an error, then serialize and return a response. diff --git a/plugins/gnostic-plugin-request/main.go b/plugins/gnostic-plugin-request/main.go index f85f012c..dd131193 100644 --- a/plugins/gnostic-plugin-request/main.go +++ b/plugins/gnostic-plugin-request/main.go @@ -21,10 +21,10 @@ import ( "github.com/golang/protobuf/jsonpb" "github.com/golang/protobuf/proto" - openapiv2 "github.com/googleapis/gnostic/openapiv2" - openapiv3 "github.com/googleapis/gnostic/openapiv3" - plugins "github.com/googleapis/gnostic/plugins" - surface "github.com/googleapis/gnostic/surface" + openapiv2 "github.com/google/gnostic/openapiv2" + openapiv3 "github.com/google/gnostic/openapiv3" + plugins "github.com/google/gnostic/plugins" + surface "github.com/google/gnostic/surface" ) func main() { diff --git a/plugins/gnostic-process-plugin-response/main.go b/plugins/gnostic-process-plugin-response/main.go index 3332128b..cfaee0a1 100644 --- a/plugins/gnostic-process-plugin-response/main.go +++ b/plugins/gnostic-process-plugin-response/main.go @@ -24,7 +24,7 @@ import ( "os" "github.com/golang/protobuf/proto" - plugins "github.com/googleapis/gnostic/plugins" + plugins "github.com/google/gnostic/plugins" ) func exitIfError(err error) { diff --git a/plugins/gnostic-summary/main.go b/plugins/gnostic-summary/main.go index 9a63a736..d25a27e9 100644 --- a/plugins/gnostic-summary/main.go +++ b/plugins/gnostic-summary/main.go @@ -21,10 +21,10 @@ import ( "path/filepath" "github.com/golang/protobuf/proto" - openapiv2 "github.com/googleapis/gnostic/openapiv2" - openapiv3 "github.com/googleapis/gnostic/openapiv3" - plugins "github.com/googleapis/gnostic/plugins" - "github.com/googleapis/gnostic/printer" + openapiv2 "github.com/google/gnostic/openapiv2" + openapiv3 "github.com/google/gnostic/openapiv3" + plugins "github.com/google/gnostic/plugins" + "github.com/google/gnostic/printer" ) // generate a simple report of an OpenAPI document's contents diff --git a/plugins/gnostic-vocabulary/main.go b/plugins/gnostic-vocabulary/main.go index 18873137..b67c666a 100644 --- a/plugins/gnostic-vocabulary/main.go +++ b/plugins/gnostic-vocabulary/main.go @@ -20,12 +20,12 @@ import ( "path/filepath" "github.com/golang/protobuf/proto" - discovery_v1 "github.com/googleapis/gnostic/discovery" - metrics "github.com/googleapis/gnostic/metrics" - vocabulary "github.com/googleapis/gnostic/metrics/vocabulary" - openapiv2 "github.com/googleapis/gnostic/openapiv2" - openapiv3 "github.com/googleapis/gnostic/openapiv3" - plugins "github.com/googleapis/gnostic/plugins" + discovery_v1 "github.com/google/gnostic/discovery" + metrics "github.com/google/gnostic/metrics" + vocabulary "github.com/google/gnostic/metrics/vocabulary" + openapiv2 "github.com/google/gnostic/openapiv2" + openapiv3 "github.com/google/gnostic/openapiv3" + plugins "github.com/google/gnostic/plugins" ) // Record an error, then serialize and return a response. diff --git a/surface/model_openapiv2.go b/surface/model_openapiv2.go index 772c1e54..547d1b18 100644 --- a/surface/model_openapiv2.go +++ b/surface/model_openapiv2.go @@ -15,8 +15,8 @@ package surface_v1 import ( - openapiv2 "github.com/googleapis/gnostic/openapiv2" - "github.com/googleapis/gnostic/compiler" + openapiv2 "github.com/google/gnostic/openapiv2" + "github.com/google/gnostic/compiler" "log" "strconv" ) diff --git a/surface/model_openapiv3.go b/surface/model_openapiv3.go index 86282028..1e8b0dfa 100644 --- a/surface/model_openapiv3.go +++ b/surface/model_openapiv3.go @@ -15,8 +15,8 @@ package surface_v1 import ( - "github.com/googleapis/gnostic/compiler" - openapiv3 "github.com/googleapis/gnostic/openapiv3" + "github.com/google/gnostic/compiler" + openapiv3 "github.com/google/gnostic/openapiv3" "log" "strings" ) diff --git a/tools/format-schema/main.go b/tools/format-schema/main.go index 1feb7134..9c8245be 100644 --- a/tools/format-schema/main.go +++ b/tools/format-schema/main.go @@ -17,7 +17,7 @@ package main import ( "fmt" - "github.com/googleapis/gnostic/jsonschema" + "github.com/google/gnostic/jsonschema" "os" "path" ) diff --git a/tools/j2y2j/main.go b/tools/j2y2j/main.go index ae8eecb0..b4060978 100644 --- a/tools/j2y2j/main.go +++ b/tools/j2y2j/main.go @@ -21,7 +21,7 @@ import ( "os" "path" - "github.com/googleapis/gnostic/jsonschema" + "github.com/google/gnostic/jsonschema" "gopkg.in/yaml.v3" ) From 7a887559791b55f14d67a3d0c01f2891de346ba2 Mon Sep 17 00:00:00 2001 From: Koichi Shiraishi Date: Sun, 26 Sep 2021 17:26:36 +0900 Subject: [PATCH 3/4] all: run goimports $ goimports -w -local github.com/google/gnostic $(find . -type f -name '*.go' -not -iwholename '*vendor*' -not -name '*.pb.go') Signed-off-by: Koichi Shiraishi --- apps/disco/main.go | 1 + apps/petstore-builder/petstore-v2.go | 2 +- apps/protoc-gen-openapi/generator/openapi-v3.go | 3 ++- apps/protoc-gen-openapi/main.go | 3 ++- apps/report-messages/main.go | 13 +++++++------ apps/report/main.go | 1 + apps/vocabulary-operations/main.go | 1 + compiler/extensions.go | 3 ++- compiler/helpers.go | 3 ++- conversions/openapiv2.go | 2 +- conversions/openapiv3.go | 2 +- discovery/discovery.go | 6 ++++-- lib/gnostic.go | 3 ++- linters/go/gnostic-lint-descriptions/linter_v3.go | 2 +- linters/go/gnostic-lint-descriptions/main.go | 1 + linters/go/gnostic-lint-paths/main.go | 1 + metrics/vocabulary/vocabulary.go | 3 ++- metrics/vocabulary/vocabulary_test.go | 1 + openapiv2/OpenAPIv2.go | 6 ++++-- openapiv2/document.go | 3 ++- openapiv3/OpenAPIv3.go | 6 ++++-- openapiv3/document.go | 3 ++- plugins/environment.go | 2 +- plugins/gnostic-analyze/main.go | 1 + plugins/gnostic-complexity/main.go | 1 + plugins/gnostic-linter/main.go | 1 + plugins/gnostic-plugin-request/main.go | 1 + plugins/gnostic-process-plugin-response/main.go | 1 + plugins/gnostic-summary/main.go | 1 + plugins/gnostic-vocabulary/main.go | 1 + surface/model_openapiv2.go | 5 +++-- surface/model_openapiv3.go | 5 +++-- tools/format-schema/main.go | 3 ++- tools/j2y2j/main.go | 3 ++- 34 files changed, 63 insertions(+), 31 deletions(-) diff --git a/apps/disco/main.go b/apps/disco/main.go index 62fb172f..ec5a067e 100644 --- a/apps/disco/main.go +++ b/apps/disco/main.go @@ -23,6 +23,7 @@ import ( "github.com/docopt/docopt-go" "github.com/golang/protobuf/proto" + "github.com/google/gnostic/conversions" discovery "github.com/google/gnostic/discovery" ) diff --git a/apps/petstore-builder/petstore-v2.go b/apps/petstore-builder/petstore-v2.go index 4fc977b6..ec2cd6e2 100644 --- a/apps/petstore-builder/petstore-v2.go +++ b/apps/petstore-builder/petstore-v2.go @@ -252,7 +252,7 @@ func buildDocumentV2() *v2.Document { &v2.NamedSchema{Name: "code", Value: &v2.Schema{ Type: &v2.TypeItem{Value: []string{"integer"}}, Format: "int32"}}, - &v2.NamedSchema{Name: "message", Value: &v2.Schema{Type: &v2.TypeItem{Value:[]string{"string"}}}}, + &v2.NamedSchema{Name: "message", Value: &v2.Schema{Type: &v2.TypeItem{Value: []string{"string"}}}}, }, }, }}) diff --git a/apps/protoc-gen-openapi/generator/openapi-v3.go b/apps/protoc-gen-openapi/generator/openapi-v3.go index 5a81ae63..c486f1b3 100644 --- a/apps/protoc-gen-openapi/generator/openapi-v3.go +++ b/apps/protoc-gen-openapi/generator/openapi-v3.go @@ -22,11 +22,12 @@ import ( "sort" "strings" - v3 "github.com/google/gnostic/openapiv3" "google.golang.org/genproto/googleapis/api/annotations" "google.golang.org/protobuf/compiler/protogen" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/reflect/protoreflect" + + v3 "github.com/google/gnostic/openapiv3" ) const infoURL = "https://github.com/googleapis/gnostic/tree/master/apps/protoc-gen-openapi" diff --git a/apps/protoc-gen-openapi/main.go b/apps/protoc-gen-openapi/main.go index 3d16d423..af621d65 100644 --- a/apps/protoc-gen-openapi/main.go +++ b/apps/protoc-gen-openapi/main.go @@ -16,8 +16,9 @@ package main import ( - "github.com/google/gnostic/apps/protoc-gen-openapi/generator" "google.golang.org/protobuf/compiler/protogen" + + "github.com/google/gnostic/apps/protoc-gen-openapi/generator" ) func main() { diff --git a/apps/report-messages/main.go b/apps/report-messages/main.go index 84388b3a..a308a80f 100644 --- a/apps/report-messages/main.go +++ b/apps/report-messages/main.go @@ -22,6 +22,7 @@ import ( "os" "github.com/golang/protobuf/proto" + "github.com/google/gnostic/printer" plugins "github.com/google/gnostic/plugins" @@ -43,13 +44,13 @@ func readMessagesFromFileWithName(filename string) *plugins.Messages { func printMessages(code *printer.Code, messages *plugins.Messages) { for _, message := range messages.Messages { - line := fmt.Sprintf("%-7s %-14s %s %+v", - message.Level, - message.Code, - message.Text, - message.Keys) + line := fmt.Sprintf("%-7s %-14s %s %+v", + message.Level, + message.Code, + message.Text, + message.Keys) code.Print(line) - } + } } func main() { diff --git a/apps/report/main.go b/apps/report/main.go index dce382ee..f0b166b3 100644 --- a/apps/report/main.go +++ b/apps/report/main.go @@ -24,6 +24,7 @@ import ( "os" "github.com/golang/protobuf/proto" + "github.com/google/gnostic/printer" pb "github.com/google/gnostic/openapiv2" diff --git a/apps/vocabulary-operations/main.go b/apps/vocabulary-operations/main.go index 5a071489..8bc22ef2 100644 --- a/apps/vocabulary-operations/main.go +++ b/apps/vocabulary-operations/main.go @@ -23,6 +23,7 @@ import ( "strings" "github.com/golang/protobuf/proto" + metrics "github.com/google/gnostic/metrics" vocabulary "github.com/google/gnostic/metrics/vocabulary" ) diff --git a/compiler/extensions.go b/compiler/extensions.go index 962cb968..5b5a916d 100644 --- a/compiler/extensions.go +++ b/compiler/extensions.go @@ -22,8 +22,9 @@ import ( "github.com/golang/protobuf/proto" "github.com/golang/protobuf/ptypes/any" - extensions "github.com/google/gnostic/extensions" yaml "gopkg.in/yaml.v3" + + extensions "github.com/google/gnostic/extensions" ) // ExtensionHandler describes a binary that is called by the compiler to handle specification extensions. diff --git a/compiler/helpers.go b/compiler/helpers.go index 3dff9e36..97ffaa51 100644 --- a/compiler/helpers.go +++ b/compiler/helpers.go @@ -20,8 +20,9 @@ import ( "sort" "strconv" - "github.com/google/gnostic/jsonschema" "gopkg.in/yaml.v3" + + "github.com/google/gnostic/jsonschema" ) // compiler helper functions, usually called from generated code diff --git a/conversions/openapiv2.go b/conversions/openapiv2.go index 71a41978..fb738865 100644 --- a/conversions/openapiv2.go +++ b/conversions/openapiv2.go @@ -18,8 +18,8 @@ import ( "log" "net/url" - openapi2 "github.com/google/gnostic/openapiv2" discovery "github.com/google/gnostic/discovery" + openapi2 "github.com/google/gnostic/openapiv2" ) func addOpenAPI2SchemaForSchema(d *openapi2.Document, name string, schema *discovery.Schema) { diff --git a/conversions/openapiv3.go b/conversions/openapiv3.go index b710fabb..576c2ec2 100644 --- a/conversions/openapiv3.go +++ b/conversions/openapiv3.go @@ -19,8 +19,8 @@ import ( "net/url" "strings" - openapi3 "github.com/google/gnostic/openapiv3" discovery "github.com/google/gnostic/discovery" + openapi3 "github.com/google/gnostic/openapiv3" ) func pathForMethod(path string) string { diff --git a/discovery/discovery.go b/discovery/discovery.go index 07543230..c13c2320 100644 --- a/discovery/discovery.go +++ b/discovery/discovery.go @@ -18,10 +18,12 @@ package discovery_v1 import ( "fmt" - "github.com/google/gnostic/compiler" - "gopkg.in/yaml.v3" "regexp" "strings" + + "gopkg.in/yaml.v3" + + "github.com/google/gnostic/compiler" ) // Version returns the package name (and OpenAPI version). diff --git a/lib/gnostic.go b/lib/gnostic.go index c33cb444..dc7cd843 100644 --- a/lib/gnostic.go +++ b/lib/gnostic.go @@ -29,6 +29,8 @@ import ( "time" "github.com/golang/protobuf/proto" + "gopkg.in/yaml.v3" + "github.com/google/gnostic/compiler" discovery_v1 "github.com/google/gnostic/discovery" "github.com/google/gnostic/jsonwriter" @@ -36,7 +38,6 @@ import ( openapi_v3 "github.com/google/gnostic/openapiv3" plugins "github.com/google/gnostic/plugins" surface "github.com/google/gnostic/surface" - "gopkg.in/yaml.v3" ) // UsageError is a response to invalid command-line inputs diff --git a/linters/go/gnostic-lint-descriptions/linter_v3.go b/linters/go/gnostic-lint-descriptions/linter_v3.go index 6f8684c6..b30ba8c0 100644 --- a/linters/go/gnostic-lint-descriptions/linter_v3.go +++ b/linters/go/gnostic-lint-descriptions/linter_v3.go @@ -16,7 +16,7 @@ package main import ( openapi "github.com/google/gnostic/openapiv3" - plugins "github.com/google/gnostic/plugins" + plugins "github.com/google/gnostic/plugins" ) // DocumentLinter contains information collected about an API description. diff --git a/linters/go/gnostic-lint-descriptions/main.go b/linters/go/gnostic-lint-descriptions/main.go index 3b8a7daf..ea33ce62 100644 --- a/linters/go/gnostic-lint-descriptions/main.go +++ b/linters/go/gnostic-lint-descriptions/main.go @@ -22,6 +22,7 @@ package main import ( "github.com/golang/protobuf/proto" + openapiv2 "github.com/google/gnostic/openapiv2" openapiv3 "github.com/google/gnostic/openapiv3" plugins "github.com/google/gnostic/plugins" diff --git a/linters/go/gnostic-lint-paths/main.go b/linters/go/gnostic-lint-paths/main.go index 73330ee5..56dab5bd 100644 --- a/linters/go/gnostic-lint-paths/main.go +++ b/linters/go/gnostic-lint-paths/main.go @@ -19,6 +19,7 @@ package main import ( "github.com/golang/protobuf/proto" + openapiv2 "github.com/google/gnostic/openapiv2" openapiv3 "github.com/google/gnostic/openapiv3" plugins "github.com/google/gnostic/plugins" diff --git a/metrics/vocabulary/vocabulary.go b/metrics/vocabulary/vocabulary.go index 1ef1faea..cbca53f9 100644 --- a/metrics/vocabulary/vocabulary.go +++ b/metrics/vocabulary/vocabulary.go @@ -24,8 +24,9 @@ import ( "sort" "strings" - metrics "github.com/google/gnostic/metrics" "google.golang.org/protobuf/proto" + + metrics "github.com/google/gnostic/metrics" ) type Vocabulary struct { diff --git a/metrics/vocabulary/vocabulary_test.go b/metrics/vocabulary/vocabulary_test.go index edf1f37f..90d93868 100644 --- a/metrics/vocabulary/vocabulary_test.go +++ b/metrics/vocabulary/vocabulary_test.go @@ -21,6 +21,7 @@ import ( "testing" "github.com/golang/protobuf/jsonpb" + discovery "github.com/google/gnostic/discovery" metrics "github.com/google/gnostic/metrics" openapiv2 "github.com/google/gnostic/openapiv2" diff --git a/openapiv2/OpenAPIv2.go b/openapiv2/OpenAPIv2.go index 0a595f9f..0f179076 100644 --- a/openapiv2/OpenAPIv2.go +++ b/openapiv2/OpenAPIv2.go @@ -18,10 +18,12 @@ package openapi_v2 import ( "fmt" - "github.com/google/gnostic/compiler" - "gopkg.in/yaml.v3" "regexp" "strings" + + "gopkg.in/yaml.v3" + + "github.com/google/gnostic/compiler" ) // Version returns the package name (and OpenAPI version). diff --git a/openapiv2/document.go b/openapiv2/document.go index c22f03fa..0021ae87 100644 --- a/openapiv2/document.go +++ b/openapiv2/document.go @@ -15,8 +15,9 @@ package openapi_v2 import ( - "github.com/google/gnostic/compiler" "gopkg.in/yaml.v3" + + "github.com/google/gnostic/compiler" ) // ParseDocument reads an OpenAPI v2 description from a YAML/JSON representation. diff --git a/openapiv3/OpenAPIv3.go b/openapiv3/OpenAPIv3.go index 58d63571..dc6feb3d 100644 --- a/openapiv3/OpenAPIv3.go +++ b/openapiv3/OpenAPIv3.go @@ -18,10 +18,12 @@ package openapi_v3 import ( "fmt" - "github.com/google/gnostic/compiler" - "gopkg.in/yaml.v3" "regexp" "strings" + + "gopkg.in/yaml.v3" + + "github.com/google/gnostic/compiler" ) // Version returns the package name (and OpenAPI version). diff --git a/openapiv3/document.go b/openapiv3/document.go index f64e52be..ef10d1d9 100644 --- a/openapiv3/document.go +++ b/openapiv3/document.go @@ -15,8 +15,9 @@ package openapi_v3 import ( - "github.com/google/gnostic/compiler" "gopkg.in/yaml.v3" + + "github.com/google/gnostic/compiler" ) // ParseDocument reads an OpenAPI v3 description from a YAML/JSON representation. diff --git a/plugins/environment.go b/plugins/environment.go index 0a856aa4..3a935295 100644 --- a/plugins/environment.go +++ b/plugins/environment.go @@ -14,9 +14,9 @@ import ( "github.com/golang/protobuf/proto" "github.com/golang/protobuf/ptypes/any" + discovery "github.com/google/gnostic/discovery" openapiv2 "github.com/google/gnostic/openapiv2" openapiv3 "github.com/google/gnostic/openapiv3" - discovery "github.com/google/gnostic/discovery" surface "github.com/google/gnostic/surface" ) diff --git a/plugins/gnostic-analyze/main.go b/plugins/gnostic-analyze/main.go index fd4cc174..f2e6918f 100644 --- a/plugins/gnostic-analyze/main.go +++ b/plugins/gnostic-analyze/main.go @@ -33,6 +33,7 @@ import ( "github.com/google/gnostic/plugins/gnostic-analyze/statistics" "github.com/golang/protobuf/proto" + openapiv2 "github.com/google/gnostic/openapiv2" openapiv3 "github.com/google/gnostic/openapiv3" plugins "github.com/google/gnostic/plugins" diff --git a/plugins/gnostic-complexity/main.go b/plugins/gnostic-complexity/main.go index 1e8543b9..fbffc45c 100644 --- a/plugins/gnostic-complexity/main.go +++ b/plugins/gnostic-complexity/main.go @@ -20,6 +20,7 @@ import ( "path/filepath" "github.com/golang/protobuf/proto" + metrics "github.com/google/gnostic/metrics" openapiv2 "github.com/google/gnostic/openapiv2" openapiv3 "github.com/google/gnostic/openapiv3" diff --git a/plugins/gnostic-linter/main.go b/plugins/gnostic-linter/main.go index 826d5508..116f80b6 100644 --- a/plugins/gnostic-linter/main.go +++ b/plugins/gnostic-linter/main.go @@ -19,6 +19,7 @@ import ( "path/filepath" "github.com/golang/protobuf/proto" + lint "github.com/google/gnostic/metrics/lint" openapiv2 "github.com/google/gnostic/openapiv2" openapiv3 "github.com/google/gnostic/openapiv3" diff --git a/plugins/gnostic-plugin-request/main.go b/plugins/gnostic-plugin-request/main.go index dd131193..0c42af60 100644 --- a/plugins/gnostic-plugin-request/main.go +++ b/plugins/gnostic-plugin-request/main.go @@ -21,6 +21,7 @@ import ( "github.com/golang/protobuf/jsonpb" "github.com/golang/protobuf/proto" + openapiv2 "github.com/google/gnostic/openapiv2" openapiv3 "github.com/google/gnostic/openapiv3" plugins "github.com/google/gnostic/plugins" diff --git a/plugins/gnostic-process-plugin-response/main.go b/plugins/gnostic-process-plugin-response/main.go index cfaee0a1..294b97b0 100644 --- a/plugins/gnostic-process-plugin-response/main.go +++ b/plugins/gnostic-process-plugin-response/main.go @@ -24,6 +24,7 @@ import ( "os" "github.com/golang/protobuf/proto" + plugins "github.com/google/gnostic/plugins" ) diff --git a/plugins/gnostic-summary/main.go b/plugins/gnostic-summary/main.go index d25a27e9..846e2904 100644 --- a/plugins/gnostic-summary/main.go +++ b/plugins/gnostic-summary/main.go @@ -21,6 +21,7 @@ import ( "path/filepath" "github.com/golang/protobuf/proto" + openapiv2 "github.com/google/gnostic/openapiv2" openapiv3 "github.com/google/gnostic/openapiv3" plugins "github.com/google/gnostic/plugins" diff --git a/plugins/gnostic-vocabulary/main.go b/plugins/gnostic-vocabulary/main.go index b67c666a..dbfb1125 100644 --- a/plugins/gnostic-vocabulary/main.go +++ b/plugins/gnostic-vocabulary/main.go @@ -20,6 +20,7 @@ import ( "path/filepath" "github.com/golang/protobuf/proto" + discovery_v1 "github.com/google/gnostic/discovery" metrics "github.com/google/gnostic/metrics" vocabulary "github.com/google/gnostic/metrics/vocabulary" diff --git a/surface/model_openapiv2.go b/surface/model_openapiv2.go index 547d1b18..9974f028 100644 --- a/surface/model_openapiv2.go +++ b/surface/model_openapiv2.go @@ -15,10 +15,11 @@ package surface_v1 import ( - openapiv2 "github.com/google/gnostic/openapiv2" - "github.com/google/gnostic/compiler" "log" "strconv" + + "github.com/google/gnostic/compiler" + openapiv2 "github.com/google/gnostic/openapiv2" ) type OpenAPI2Builder struct { diff --git a/surface/model_openapiv3.go b/surface/model_openapiv3.go index 1e8b0dfa..83df4ed9 100644 --- a/surface/model_openapiv3.go +++ b/surface/model_openapiv3.go @@ -15,10 +15,11 @@ package surface_v1 import ( - "github.com/google/gnostic/compiler" - openapiv3 "github.com/google/gnostic/openapiv3" "log" "strings" + + "github.com/google/gnostic/compiler" + openapiv3 "github.com/google/gnostic/openapiv3" ) type OpenAPI3Builder struct { diff --git a/tools/format-schema/main.go b/tools/format-schema/main.go index 9c8245be..5cc363c3 100644 --- a/tools/format-schema/main.go +++ b/tools/format-schema/main.go @@ -17,9 +17,10 @@ package main import ( "fmt" - "github.com/google/gnostic/jsonschema" "os" "path" + + "github.com/google/gnostic/jsonschema" ) func main() { diff --git a/tools/j2y2j/main.go b/tools/j2y2j/main.go index b4060978..4b74fb43 100644 --- a/tools/j2y2j/main.go +++ b/tools/j2y2j/main.go @@ -21,8 +21,9 @@ import ( "os" "path" - "github.com/google/gnostic/jsonschema" "gopkg.in/yaml.v3" + + "github.com/google/gnostic/jsonschema" ) func usage() { From 1cca2a0159f81255dea2b0708d2cba972a3cc927 Mon Sep 17 00:00:00 2001 From: Koichi Shiraishi Date: Sun, 26 Sep 2021 18:18:19 +0900 Subject: [PATCH 4/4] generate-gnostic: support goimports local prefix Signed-off-by: Koichi Shiraishi --- generate-gnostic/main.go | 20 ++++++++++++++------ go.mod | 2 ++ go.sum | 4 +++- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/generate-gnostic/main.go b/generate-gnostic/main.go index c198809b..59397181 100644 --- a/generate-gnostic/main.go +++ b/generate-gnostic/main.go @@ -23,11 +23,11 @@ import ( "io/ioutil" "log" "os" - "os/exec" "path" - "runtime" "strings" + "golang.org/x/tools/imports" + "github.com/google/gnostic/jsonschema" ) @@ -199,13 +199,21 @@ func generateOpenAPIModel(version string) error { log.Printf("Generating compiler support code") compiler := cc.GenerateCompiler(goPackageName, License, packageImports) goFileName := projectRoot + directoryName + "/" + filename + ".go" - err = ioutil.WriteFile(goFileName, []byte(compiler), 0644) + + // format the compiler + log.Printf("Formatting compiler support code") + imports.LocalPrefix = "github.com/google/gnostic" + data, err := imports.Process(goFileName, []byte(compiler), &imports.Options{ + TabWidth: 8, + TabIndent: true, + Comments: true, + Fragment: true, + }) if err != nil { return err } - // format the compiler - log.Printf("Formatting compiler support code") - return exec.Command(runtime.GOROOT()+"/bin/gofmt", "-w", goFileName).Run() + + return ioutil.WriteFile(goFileName, []byte(data), 0644) } func usage() string { diff --git a/go.mod b/go.mod index 9d757e7c..077a2270 100644 --- a/go.mod +++ b/go.mod @@ -8,6 +8,8 @@ require ( github.com/golang/protobuf v1.5.2 github.com/kr/pretty v0.2.0 // indirect github.com/stoewer/go-strcase v1.2.0 + golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135 + golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect google.golang.org/genproto v0.0.0-20201019141844-1ed22bb0c154 google.golang.org/protobuf v1.26.0 gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 diff --git a/go.sum b/go.sum index 16994e41..b71b39f0 100644 --- a/go.sum +++ b/go.sum @@ -60,9 +60,11 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135 h1:5Beo0mZN8dRzgrMMkDp0jc8YXQKx9DiJ2k1dkvGsn5A= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=