Fix dependencies
This commit is contained in:
parent
ef7b435f1b
commit
10ab9265d9
5
go.mod
5
go.mod
@ -8,7 +8,6 @@ require (
|
|||||||
github.com/go-ping/ping v0.0.0-20201115131931-3300c582a663
|
github.com/go-ping/ping v0.0.0-20201115131931-3300c582a663
|
||||||
github.com/google/gofuzz v1.2.0 // indirect
|
github.com/google/gofuzz v1.2.0 // indirect
|
||||||
github.com/imdario/mergo v0.3.11 // indirect
|
github.com/imdario/mergo v0.3.11 // indirect
|
||||||
github.com/kr/pretty v0.2.0 // indirect
|
|
||||||
github.com/miekg/dns v1.1.35
|
github.com/miekg/dns v1.1.35
|
||||||
github.com/prometheus/client_golang v1.9.0
|
github.com/prometheus/client_golang v1.9.0
|
||||||
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad // indirect
|
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad // indirect
|
||||||
@ -19,9 +18,9 @@ require (
|
|||||||
gopkg.in/yaml.v2 v2.4.0
|
gopkg.in/yaml.v2 v2.4.0
|
||||||
k8s.io/api v0.19.6
|
k8s.io/api v0.19.6
|
||||||
k8s.io/apimachinery v0.19.6
|
k8s.io/apimachinery v0.19.6
|
||||||
k8s.io/client-go v0.19.6
|
k8s.io/client-go v0.0.0-00010101000000-000000000000
|
||||||
)
|
)
|
||||||
|
|
||||||
replace k8s.io/client-go => k8s.io/client-go v0.19.6
|
replace k8s.io/client-go => k8s.io/client-go v0.19.6
|
||||||
|
|
||||||
replace github.com/googleapis/gnostic => github.com/googleapis/gnostic v0.4.0
|
replace github.com/googleapis/gnostic => github.com/googleapis/gnostic v0.5.3
|
||||||
|
8
go.sum
8
go.sum
@ -217,8 +217,8 @@ github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+
|
|||||||
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
|
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
|
||||||
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
|
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
|
||||||
github.com/googleapis/gnostic v0.4.0 h1:BXDUo8p/DaxC+4FJY/SSx3gvnx9C1VdHNgaUkiEL5mk=
|
github.com/googleapis/gnostic v0.5.3 h1:2qsuRm+bzgwSIKikigPASa2GhW8H2Dn4Qq7UxD8K/48=
|
||||||
github.com/googleapis/gnostic v0.4.0/go.mod h1:on+2t9HRStVgn95RSsFWFz+6Q0Snyqv1awfrALZdbtU=
|
github.com/googleapis/gnostic v0.5.3/go.mod h1:TRWw1s4gxBGjSe301Dai3c7wXJAZy57+/6tawkOvqHQ=
|
||||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
||||||
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
|
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
|
||||||
github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
|
github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
|
||||||
@ -406,6 +406,7 @@ github.com/spf13/pflag v1.0.1 h1:aCvUg6QPl3ibpQUxyLkrEkCHtPqYJL4x9AuhqVqFis4=
|
|||||||
github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
||||||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||||
|
github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8=
|
||||||
github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
|
github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
|
||||||
github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
|
github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
|
||||||
github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI=
|
github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI=
|
||||||
@ -741,6 +742,7 @@ google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6D
|
|||||||
google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||||
google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||||
google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||||
|
google.golang.org/genproto v0.0.0-20201019141844-1ed22bb0c154/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||||
google.golang.org/genproto v0.0.0-20201109203340-2640f1f9cdfb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
google.golang.org/genproto v0.0.0-20201109203340-2640f1f9cdfb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||||
google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||||
google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||||
@ -802,6 +804,8 @@ gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
|
|||||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||||
|
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 h1:tQIYjPdBoyREyB9XMu+nnTclpTYkz2zFM+lzLJFO4gQ=
|
||||||
|
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
|
3610
vendor/github.com/googleapis/gnostic/OpenAPIv2/OpenAPIv2.go
generated
vendored
3610
vendor/github.com/googleapis/gnostic/OpenAPIv2/OpenAPIv2.go
generated
vendored
File diff suppressed because it is too large
Load Diff
8662
vendor/github.com/googleapis/gnostic/OpenAPIv2/OpenAPIv2.pb.go
generated
vendored
8662
vendor/github.com/googleapis/gnostic/OpenAPIv2/OpenAPIv2.pb.go
generated
vendored
File diff suppressed because it is too large
Load Diff
7
vendor/github.com/googleapis/gnostic/OpenAPIv2/OpenAPIv2.proto
generated
vendored
7
vendor/github.com/googleapis/gnostic/OpenAPIv2/OpenAPIv2.proto
generated
vendored
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2017 Google Inc. All Rights Reserved.
|
// Copyright 2020 Google LLC. All Rights Reserved.
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
@ -41,6 +41,9 @@ option java_package = "org.openapi_v2";
|
|||||||
// the future. 'GPB' is reserved for the protocol buffer implementation itself.
|
// the future. 'GPB' is reserved for the protocol buffer implementation itself.
|
||||||
option objc_class_prefix = "OAS";
|
option objc_class_prefix = "OAS";
|
||||||
|
|
||||||
|
// The Go package name.
|
||||||
|
option go_package = "openapiv2;openapi_v2";
|
||||||
|
|
||||||
message AdditionalPropertiesItem {
|
message AdditionalPropertiesItem {
|
||||||
oneof oneof {
|
oneof oneof {
|
||||||
Schema schema = 1;
|
Schema schema = 1;
|
||||||
@ -553,7 +556,7 @@ message Response {
|
|||||||
repeated NamedAny vendor_extension = 5;
|
repeated NamedAny vendor_extension = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
// One or more JSON representations for parameters
|
// One or more JSON representations for responses
|
||||||
message ResponseDefinitions {
|
message ResponseDefinitions {
|
||||||
repeated NamedResponse additional_properties = 1;
|
repeated NamedResponse additional_properties = 1;
|
||||||
}
|
}
|
||||||
|
20
vendor/github.com/googleapis/gnostic/OpenAPIv2/README.md
generated
vendored
20
vendor/github.com/googleapis/gnostic/OpenAPIv2/README.md
generated
vendored
@ -1,16 +1,14 @@
|
|||||||
# OpenAPI v2 Protocol Buffer Models
|
# OpenAPI v2 Protocol Buffer Models
|
||||||
|
|
||||||
This directory contains a Protocol Buffer-language model
|
This directory contains a Protocol Buffer-language model and related code for
|
||||||
and related code for supporting OpenAPI v2.
|
supporting OpenAPI v2.
|
||||||
|
|
||||||
Gnostic applications and plugins can use OpenAPIv2.proto
|
Gnostic applications and plugins can use OpenAPIv2.proto to generate Protocol
|
||||||
to generate Protocol Buffer support code for their preferred languages.
|
Buffer support code for their preferred languages.
|
||||||
|
|
||||||
OpenAPIv2.go is used by Gnostic to read JSON and YAML OpenAPI
|
OpenAPIv2.go is used by Gnostic to read JSON and YAML OpenAPI descriptions into
|
||||||
descriptions into the Protocol Buffer-based datastructures
|
the Protocol Buffer-based datastructures generated from OpenAPIv2.proto.
|
||||||
generated from OpenAPIv2.proto.
|
|
||||||
|
|
||||||
OpenAPIv2.proto and OpenAPIv2.go are generated by the Gnostic
|
OpenAPIv2.proto and OpenAPIv2.go are generated by the Gnostic compiler
|
||||||
compiler generator, and OpenAPIv2.pb.go is generated by
|
generator, and OpenAPIv2.pb.go is generated by protoc, the Protocol Buffer
|
||||||
protoc, the Protocol Buffer compiler, and protoc-gen-go, the
|
compiler, and protoc-gen-go, the Protocol Buffer Go code generation plugin.
|
||||||
Protocol Buffer Go code generation plugin.
|
|
||||||
|
41
vendor/github.com/googleapis/gnostic/OpenAPIv2/document.go
generated
vendored
Normal file
41
vendor/github.com/googleapis/gnostic/OpenAPIv2/document.go
generated
vendored
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
// Copyright 2020 Google LLC. All Rights Reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package openapi_v2
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/googleapis/gnostic/compiler"
|
||||||
|
"gopkg.in/yaml.v3"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ParseDocument reads an OpenAPI v2 description from a YAML/JSON representation.
|
||||||
|
func ParseDocument(b []byte) (*Document, error) {
|
||||||
|
info, err := compiler.ReadInfoFromBytes("", b)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
root := info.Content[0]
|
||||||
|
return NewDocument(root, compiler.NewContextWithExtensions("$root", root, nil, nil))
|
||||||
|
}
|
||||||
|
|
||||||
|
// YAMLValue produces a serialized YAML representation of the document.
|
||||||
|
func (d *Document) YAMLValue(comment string) ([]byte, error) {
|
||||||
|
rawInfo := d.ToRawInfo()
|
||||||
|
rawInfo = &yaml.Node{
|
||||||
|
Kind: yaml.DocumentNode,
|
||||||
|
Content: []*yaml.Node{rawInfo},
|
||||||
|
HeadComment: comment,
|
||||||
|
}
|
||||||
|
return yaml.Marshal(rawInfo)
|
||||||
|
}
|
4
vendor/github.com/googleapis/gnostic/OpenAPIv2/openapi-2.0.json
generated
vendored
4
vendor/github.com/googleapis/gnostic/OpenAPIv2/openapi-2.0.json
generated
vendored
@ -203,7 +203,7 @@
|
|||||||
"additionalProperties": {
|
"additionalProperties": {
|
||||||
"$ref": "#/definitions/response"
|
"$ref": "#/definitions/response"
|
||||||
},
|
},
|
||||||
"description": "One or more JSON representations for parameters"
|
"description": "One or more JSON representations for responses"
|
||||||
},
|
},
|
||||||
"externalDocs": {
|
"externalDocs": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
@ -1607,4 +1607,4 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
3
vendor/github.com/googleapis/gnostic/compiler/README.md
generated
vendored
3
vendor/github.com/googleapis/gnostic/compiler/README.md
generated
vendored
@ -1,3 +1,4 @@
|
|||||||
# Compiler support code
|
# Compiler support code
|
||||||
|
|
||||||
This directory contains compiler support code used by Gnostic and Gnostic extensions.
|
This directory contains compiler support code used by Gnostic and Gnostic
|
||||||
|
extensions.
|
||||||
|
20
vendor/github.com/googleapis/gnostic/compiler/context.go
generated
vendored
20
vendor/github.com/googleapis/gnostic/compiler/context.go
generated
vendored
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2017 Google Inc. All Rights Reserved.
|
// Copyright 2017 Google LLC. All Rights Reserved.
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
@ -14,30 +14,36 @@
|
|||||||
|
|
||||||
package compiler
|
package compiler
|
||||||
|
|
||||||
|
import (
|
||||||
|
yaml "gopkg.in/yaml.v3"
|
||||||
|
)
|
||||||
|
|
||||||
// Context contains state of the compiler as it traverses a document.
|
// Context contains state of the compiler as it traverses a document.
|
||||||
type Context struct {
|
type Context struct {
|
||||||
Parent *Context
|
Parent *Context
|
||||||
Name string
|
Name string
|
||||||
|
Node *yaml.Node
|
||||||
ExtensionHandlers *[]ExtensionHandler
|
ExtensionHandlers *[]ExtensionHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewContextWithExtensions returns a new object representing the compiler state
|
// NewContextWithExtensions returns a new object representing the compiler state
|
||||||
func NewContextWithExtensions(name string, parent *Context, extensionHandlers *[]ExtensionHandler) *Context {
|
func NewContextWithExtensions(name string, node *yaml.Node, parent *Context, extensionHandlers *[]ExtensionHandler) *Context {
|
||||||
return &Context{Name: name, Parent: parent, ExtensionHandlers: extensionHandlers}
|
return &Context{Name: name, Node: node, Parent: parent, ExtensionHandlers: extensionHandlers}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewContext returns a new object representing the compiler state
|
// NewContext returns a new object representing the compiler state
|
||||||
func NewContext(name string, parent *Context) *Context {
|
func NewContext(name string, node *yaml.Node, parent *Context) *Context {
|
||||||
if parent != nil {
|
if parent != nil {
|
||||||
return &Context{Name: name, Parent: parent, ExtensionHandlers: parent.ExtensionHandlers}
|
return &Context{Name: name, Node: node, Parent: parent, ExtensionHandlers: parent.ExtensionHandlers}
|
||||||
}
|
}
|
||||||
return &Context{Name: name, Parent: parent, ExtensionHandlers: nil}
|
return &Context{Name: name, Parent: parent, ExtensionHandlers: nil}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Description returns a text description of the compiler state
|
// Description returns a text description of the compiler state
|
||||||
func (context *Context) Description() string {
|
func (context *Context) Description() string {
|
||||||
|
name := context.Name
|
||||||
if context.Parent != nil {
|
if context.Parent != nil {
|
||||||
return context.Parent.Description() + "." + context.Name
|
name = context.Parent.Description() + "." + name
|
||||||
}
|
}
|
||||||
return context.Name
|
return name
|
||||||
}
|
}
|
||||||
|
15
vendor/github.com/googleapis/gnostic/compiler/error.go
generated
vendored
15
vendor/github.com/googleapis/gnostic/compiler/error.go
generated
vendored
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2017 Google Inc. All Rights Reserved.
|
// Copyright 2017 Google LLC. All Rights Reserved.
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
package compiler
|
package compiler
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
// Error represents compiler errors and their location in the document.
|
// Error represents compiler errors and their location in the document.
|
||||||
type Error struct {
|
type Error struct {
|
||||||
Context *Context
|
Context *Context
|
||||||
@ -25,12 +27,19 @@ func NewError(context *Context, message string) *Error {
|
|||||||
return &Error{Context: context, Message: message}
|
return &Error{Context: context, Message: message}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (err *Error) locationDescription() string {
|
||||||
|
if err.Context.Node != nil {
|
||||||
|
return fmt.Sprintf("[%d,%d] %s", err.Context.Node.Line, err.Context.Node.Column, err.Context.Description())
|
||||||
|
}
|
||||||
|
return err.Context.Description()
|
||||||
|
}
|
||||||
|
|
||||||
// Error returns the string value of an Error.
|
// Error returns the string value of an Error.
|
||||||
func (err *Error) Error() string {
|
func (err *Error) Error() string {
|
||||||
if err.Context == nil {
|
if err.Context == nil {
|
||||||
return "ERROR " + err.Message
|
return err.Message
|
||||||
}
|
}
|
||||||
return "ERROR " + err.Context.Description() + " " + err.Message
|
return err.locationDescription() + " " + err.Message
|
||||||
}
|
}
|
||||||
|
|
||||||
// ErrorGroup is a container for groups of Error values.
|
// ErrorGroup is a container for groups of Error values.
|
||||||
|
101
vendor/github.com/googleapis/gnostic/compiler/extension-handler.go
generated
vendored
101
vendor/github.com/googleapis/gnostic/compiler/extension-handler.go
generated
vendored
@ -1,101 +0,0 @@
|
|||||||
// Copyright 2017 Google Inc. All Rights Reserved.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
package compiler
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"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"
|
|
||||||
)
|
|
||||||
|
|
||||||
// ExtensionHandler describes a binary that is called by the compiler to handle specification extensions.
|
|
||||||
type ExtensionHandler struct {
|
|
||||||
Name string
|
|
||||||
}
|
|
||||||
|
|
||||||
// HandleExtension calls a binary extension handler.
|
|
||||||
func HandleExtension(context *Context, in interface{}, extensionName string) (bool, *any.Any, error) {
|
|
||||||
handled := false
|
|
||||||
var errFromPlugin error
|
|
||||||
var outFromPlugin *any.Any
|
|
||||||
|
|
||||||
if context != nil && context.ExtensionHandlers != nil && len(*(context.ExtensionHandlers)) != 0 {
|
|
||||||
for _, customAnyProtoGenerator := range *(context.ExtensionHandlers) {
|
|
||||||
outFromPlugin, errFromPlugin = customAnyProtoGenerator.handle(in, extensionName)
|
|
||||||
if outFromPlugin == nil {
|
|
||||||
continue
|
|
||||||
} else {
|
|
||||||
handled = true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return handled, outFromPlugin, errFromPlugin
|
|
||||||
}
|
|
||||||
|
|
||||||
func (extensionHandlers *ExtensionHandler) handle(in interface{}, extensionName string) (*any.Any, error) {
|
|
||||||
if extensionHandlers.Name != "" {
|
|
||||||
binary, _ := yaml.Marshal(in)
|
|
||||||
|
|
||||||
request := &ext_plugin.ExtensionHandlerRequest{}
|
|
||||||
|
|
||||||
version := &ext_plugin.Version{}
|
|
||||||
version.Major = 0
|
|
||||||
version.Minor = 1
|
|
||||||
version.Patch = 0
|
|
||||||
request.CompilerVersion = version
|
|
||||||
|
|
||||||
request.Wrapper = &ext_plugin.Wrapper{}
|
|
||||||
|
|
||||||
request.Wrapper.Version = "v2"
|
|
||||||
request.Wrapper.Yaml = string(binary)
|
|
||||||
request.Wrapper.ExtensionName = extensionName
|
|
||||||
|
|
||||||
requestBytes, _ := proto.Marshal(request)
|
|
||||||
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
|
|
||||||
}
|
|
||||||
response := &ext_plugin.ExtensionHandlerResponse{}
|
|
||||||
err = proto.Unmarshal(output, response)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Printf("Error: %+v\n", err)
|
|
||||||
fmt.Printf("%s\n", string(output))
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if !response.Handled {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
if len(response.Error) != 0 {
|
|
||||||
message := fmt.Sprintf("Errors when parsing: %+v for field %s by vendor extension handler %s. Details %+v", in, extensionName, extensionHandlers.Name, strings.Join(response.Error, ","))
|
|
||||||
return nil, errors.New(message)
|
|
||||||
}
|
|
||||||
return response.Value, nil
|
|
||||||
}
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
85
vendor/github.com/googleapis/gnostic/compiler/extensions.go
generated
vendored
Normal file
85
vendor/github.com/googleapis/gnostic/compiler/extensions.go
generated
vendored
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
// Copyright 2017 Google LLC. All Rights Reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package compiler
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"fmt"
|
||||||
|
"os/exec"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/golang/protobuf/proto"
|
||||||
|
"github.com/golang/protobuf/ptypes/any"
|
||||||
|
extensions "github.com/googleapis/gnostic/extensions"
|
||||||
|
yaml "gopkg.in/yaml.v3"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ExtensionHandler describes a binary that is called by the compiler to handle specification extensions.
|
||||||
|
type ExtensionHandler struct {
|
||||||
|
Name string
|
||||||
|
}
|
||||||
|
|
||||||
|
// CallExtension calls a binary extension handler.
|
||||||
|
func CallExtension(context *Context, in *yaml.Node, extensionName string) (handled bool, response *any.Any, err error) {
|
||||||
|
if context == nil || context.ExtensionHandlers == nil {
|
||||||
|
return false, nil, nil
|
||||||
|
}
|
||||||
|
handled = false
|
||||||
|
for _, handler := range *(context.ExtensionHandlers) {
|
||||||
|
response, err = handler.handle(in, extensionName)
|
||||||
|
if response == nil {
|
||||||
|
continue
|
||||||
|
} else {
|
||||||
|
handled = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return handled, response, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (extensionHandlers *ExtensionHandler) handle(in *yaml.Node, extensionName string) (*any.Any, error) {
|
||||||
|
if extensionHandlers.Name != "" {
|
||||||
|
yamlData, _ := yaml.Marshal(in)
|
||||||
|
request := &extensions.ExtensionHandlerRequest{
|
||||||
|
CompilerVersion: &extensions.Version{
|
||||||
|
Major: 0,
|
||||||
|
Minor: 1,
|
||||||
|
Patch: 0,
|
||||||
|
},
|
||||||
|
Wrapper: &extensions.Wrapper{
|
||||||
|
Version: "unknown", // TODO: set this to the type/version of spec being parsed.
|
||||||
|
Yaml: string(yamlData),
|
||||||
|
ExtensionName: extensionName,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
requestBytes, _ := proto.Marshal(request)
|
||||||
|
cmd := exec.Command(extensionHandlers.Name)
|
||||||
|
cmd.Stdin = bytes.NewReader(requestBytes)
|
||||||
|
output, err := cmd.Output()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
response := &extensions.ExtensionHandlerResponse{}
|
||||||
|
err = proto.Unmarshal(output, response)
|
||||||
|
if err != nil || !response.Handled {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if len(response.Errors) != 0 {
|
||||||
|
return nil, fmt.Errorf("Errors when parsing: %+v for field %s by vendor extension handler %s. Details %+v", in, extensionName, extensionHandlers.Name, strings.Join(response.Errors, ","))
|
||||||
|
}
|
||||||
|
return response.Value, nil
|
||||||
|
}
|
||||||
|
return nil, nil
|
||||||
|
}
|
347
vendor/github.com/googleapis/gnostic/compiler/helpers.go
generated
vendored
347
vendor/github.com/googleapis/gnostic/compiler/helpers.go
generated
vendored
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2017 Google Inc. All Rights Reserved.
|
// Copyright 2017 Google LLC. All Rights Reserved.
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
@ -16,56 +16,63 @@ package compiler
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"gopkg.in/yaml.v2"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/googleapis/gnostic/jsonschema"
|
||||||
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
// compiler helper functions, usually called from generated code
|
// compiler helper functions, usually called from generated code
|
||||||
|
|
||||||
// UnpackMap gets a yaml.MapSlice if possible.
|
// UnpackMap gets a *yaml.Node if possible.
|
||||||
func UnpackMap(in interface{}) (yaml.MapSlice, bool) {
|
func UnpackMap(in *yaml.Node) (*yaml.Node, bool) {
|
||||||
m, ok := in.(yaml.MapSlice)
|
if in == nil {
|
||||||
if ok {
|
return nil, false
|
||||||
return m, true
|
|
||||||
}
|
}
|
||||||
// do we have an empty array?
|
return in, true
|
||||||
a, ok := in.([]interface{})
|
|
||||||
if ok && len(a) == 0 {
|
|
||||||
// if so, return an empty map
|
|
||||||
return yaml.MapSlice{}, true
|
|
||||||
}
|
|
||||||
return nil, false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SortedKeysForMap returns the sorted keys of a yaml.MapSlice.
|
// SortedKeysForMap returns the sorted keys of a yamlv2.MapSlice.
|
||||||
func SortedKeysForMap(m yaml.MapSlice) []string {
|
func SortedKeysForMap(m *yaml.Node) []string {
|
||||||
keys := make([]string, 0)
|
keys := make([]string, 0)
|
||||||
for _, item := range m {
|
if m.Kind == yaml.MappingNode {
|
||||||
keys = append(keys, item.Key.(string))
|
for i := 0; i < len(m.Content); i += 2 {
|
||||||
|
keys = append(keys, m.Content[i].Value)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
sort.Strings(keys)
|
sort.Strings(keys)
|
||||||
return keys
|
return keys
|
||||||
}
|
}
|
||||||
|
|
||||||
// MapHasKey returns true if a yaml.MapSlice contains a specified key.
|
// MapHasKey returns true if a yamlv2.MapSlice contains a specified key.
|
||||||
func MapHasKey(m yaml.MapSlice, key string) bool {
|
func MapHasKey(m *yaml.Node, key string) bool {
|
||||||
for _, item := range m {
|
if m == nil {
|
||||||
itemKey, ok := item.Key.(string)
|
return false
|
||||||
if ok && key == itemKey {
|
}
|
||||||
return true
|
if m.Kind == yaml.MappingNode {
|
||||||
|
for i := 0; i < len(m.Content); i += 2 {
|
||||||
|
itemKey := m.Content[i].Value
|
||||||
|
if key == itemKey {
|
||||||
|
return true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// MapValueForKey gets the value of a map value for a specified key.
|
// MapValueForKey gets the value of a map value for a specified key.
|
||||||
func MapValueForKey(m yaml.MapSlice, key string) interface{} {
|
func MapValueForKey(m *yaml.Node, key string) *yaml.Node {
|
||||||
for _, item := range m {
|
if m == nil {
|
||||||
itemKey, ok := item.Key.(string)
|
return nil
|
||||||
if ok && key == itemKey {
|
}
|
||||||
return item.Value
|
if m.Kind == yaml.MappingNode {
|
||||||
|
for i := 0; i < len(m.Content); i += 2 {
|
||||||
|
itemKey := m.Content[i].Value
|
||||||
|
if key == itemKey {
|
||||||
|
return m.Content[i+1]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@ -83,8 +90,118 @@ func ConvertInterfaceArrayToStringArray(interfaceArray []interface{}) []string {
|
|||||||
return stringArray
|
return stringArray
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SequenceNodeForNode returns a node if it is a SequenceNode.
|
||||||
|
func SequenceNodeForNode(node *yaml.Node) (*yaml.Node, bool) {
|
||||||
|
if node.Kind != yaml.SequenceNode {
|
||||||
|
return nil, false
|
||||||
|
}
|
||||||
|
return node, true
|
||||||
|
}
|
||||||
|
|
||||||
|
// BoolForScalarNode returns the bool value of a node.
|
||||||
|
func BoolForScalarNode(node *yaml.Node) (bool, bool) {
|
||||||
|
if node == nil {
|
||||||
|
return false, false
|
||||||
|
}
|
||||||
|
if node.Kind == yaml.DocumentNode {
|
||||||
|
return BoolForScalarNode(node.Content[0])
|
||||||
|
}
|
||||||
|
if node.Kind != yaml.ScalarNode {
|
||||||
|
return false, false
|
||||||
|
}
|
||||||
|
if node.Tag != "!!bool" {
|
||||||
|
return false, false
|
||||||
|
}
|
||||||
|
v, err := strconv.ParseBool(node.Value)
|
||||||
|
if err != nil {
|
||||||
|
return false, false
|
||||||
|
}
|
||||||
|
return v, true
|
||||||
|
}
|
||||||
|
|
||||||
|
// IntForScalarNode returns the integer value of a node.
|
||||||
|
func IntForScalarNode(node *yaml.Node) (int64, bool) {
|
||||||
|
if node == nil {
|
||||||
|
return 0, false
|
||||||
|
}
|
||||||
|
if node.Kind == yaml.DocumentNode {
|
||||||
|
return IntForScalarNode(node.Content[0])
|
||||||
|
}
|
||||||
|
if node.Kind != yaml.ScalarNode {
|
||||||
|
return 0, false
|
||||||
|
}
|
||||||
|
if node.Tag != "!!int" {
|
||||||
|
return 0, false
|
||||||
|
}
|
||||||
|
v, err := strconv.ParseInt(node.Value, 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
return 0, false
|
||||||
|
}
|
||||||
|
return v, true
|
||||||
|
}
|
||||||
|
|
||||||
|
// FloatForScalarNode returns the float value of a node.
|
||||||
|
func FloatForScalarNode(node *yaml.Node) (float64, bool) {
|
||||||
|
if node == nil {
|
||||||
|
return 0.0, false
|
||||||
|
}
|
||||||
|
if node.Kind == yaml.DocumentNode {
|
||||||
|
return FloatForScalarNode(node.Content[0])
|
||||||
|
}
|
||||||
|
if node.Kind != yaml.ScalarNode {
|
||||||
|
return 0.0, false
|
||||||
|
}
|
||||||
|
if (node.Tag != "!!int") && (node.Tag != "!!float") {
|
||||||
|
return 0.0, false
|
||||||
|
}
|
||||||
|
v, err := strconv.ParseFloat(node.Value, 64)
|
||||||
|
if err != nil {
|
||||||
|
return 0.0, false
|
||||||
|
}
|
||||||
|
return v, true
|
||||||
|
}
|
||||||
|
|
||||||
|
// StringForScalarNode returns the string value of a node.
|
||||||
|
func StringForScalarNode(node *yaml.Node) (string, bool) {
|
||||||
|
if node == nil {
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
if node.Kind == yaml.DocumentNode {
|
||||||
|
return StringForScalarNode(node.Content[0])
|
||||||
|
}
|
||||||
|
switch node.Kind {
|
||||||
|
case yaml.ScalarNode:
|
||||||
|
switch node.Tag {
|
||||||
|
case "!!int":
|
||||||
|
return node.Value, true
|
||||||
|
case "!!str":
|
||||||
|
return node.Value, true
|
||||||
|
case "!!timestamp":
|
||||||
|
return node.Value, true
|
||||||
|
case "!!null":
|
||||||
|
return "", true
|
||||||
|
default:
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// StringArrayForSequenceNode converts a sequence node to an array of strings, if possible.
|
||||||
|
func StringArrayForSequenceNode(node *yaml.Node) []string {
|
||||||
|
stringArray := make([]string, 0)
|
||||||
|
for _, item := range node.Content {
|
||||||
|
v, ok := StringForScalarNode(item)
|
||||||
|
if ok {
|
||||||
|
stringArray = append(stringArray, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return stringArray
|
||||||
|
}
|
||||||
|
|
||||||
// MissingKeysInMap identifies which keys from a list of required keys are not in a map.
|
// MissingKeysInMap identifies which keys from a list of required keys are not in a map.
|
||||||
func MissingKeysInMap(m yaml.MapSlice, requiredKeys []string) []string {
|
func MissingKeysInMap(m *yaml.Node, requiredKeys []string) []string {
|
||||||
missingKeys := make([]string, 0)
|
missingKeys := make([]string, 0)
|
||||||
for _, k := range requiredKeys {
|
for _, k := range requiredKeys {
|
||||||
if !MapHasKey(m, k) {
|
if !MapHasKey(m, k) {
|
||||||
@ -95,64 +212,109 @@ func MissingKeysInMap(m yaml.MapSlice, requiredKeys []string) []string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// InvalidKeysInMap returns keys in a map that don't match a list of allowed keys and patterns.
|
// InvalidKeysInMap returns keys in a map that don't match a list of allowed keys and patterns.
|
||||||
func InvalidKeysInMap(m yaml.MapSlice, allowedKeys []string, allowedPatterns []*regexp.Regexp) []string {
|
func InvalidKeysInMap(m *yaml.Node, allowedKeys []string, allowedPatterns []*regexp.Regexp) []string {
|
||||||
invalidKeys := make([]string, 0)
|
invalidKeys := make([]string, 0)
|
||||||
for _, item := range m {
|
if m == nil || m.Kind != yaml.MappingNode {
|
||||||
itemKey, ok := item.Key.(string)
|
return invalidKeys
|
||||||
if ok {
|
}
|
||||||
key := itemKey
|
for i := 0; i < len(m.Content); i += 2 {
|
||||||
found := false
|
key := m.Content[i].Value
|
||||||
// does the key match an allowed key?
|
found := false
|
||||||
for _, allowedKey := range allowedKeys {
|
// does the key match an allowed key?
|
||||||
if key == allowedKey {
|
for _, allowedKey := range allowedKeys {
|
||||||
|
if key == allowedKey {
|
||||||
|
found = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !found {
|
||||||
|
// does the key match an allowed pattern?
|
||||||
|
for _, allowedPattern := range allowedPatterns {
|
||||||
|
if allowedPattern.MatchString(key) {
|
||||||
found = true
|
found = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !found {
|
if !found {
|
||||||
// does the key match an allowed pattern?
|
invalidKeys = append(invalidKeys, key)
|
||||||
for _, allowedPattern := range allowedPatterns {
|
|
||||||
if allowedPattern.MatchString(key) {
|
|
||||||
found = true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if !found {
|
|
||||||
invalidKeys = append(invalidKeys, key)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return invalidKeys
|
return invalidKeys
|
||||||
}
|
}
|
||||||
|
|
||||||
// DescribeMap describes a map (for debugging purposes).
|
// NewNullNode creates a new Null node.
|
||||||
func DescribeMap(in interface{}, indent string) string {
|
func NewNullNode() *yaml.Node {
|
||||||
description := ""
|
node := &yaml.Node{
|
||||||
m, ok := in.(map[string]interface{})
|
Kind: yaml.ScalarNode,
|
||||||
if ok {
|
Tag: "!!null",
|
||||||
keys := make([]string, 0)
|
|
||||||
for k := range m {
|
|
||||||
keys = append(keys, k)
|
|
||||||
}
|
|
||||||
sort.Strings(keys)
|
|
||||||
for _, k := range keys {
|
|
||||||
v := m[k]
|
|
||||||
description += fmt.Sprintf("%s%s:\n", indent, k)
|
|
||||||
description += DescribeMap(v, indent+" ")
|
|
||||||
}
|
|
||||||
return description
|
|
||||||
}
|
}
|
||||||
a, ok := in.([]interface{})
|
return node
|
||||||
if ok {
|
}
|
||||||
for i, v := range a {
|
|
||||||
description += fmt.Sprintf("%s%d:\n", indent, i)
|
// NewMappingNode creates a new Mapping node.
|
||||||
description += DescribeMap(v, indent+" ")
|
func NewMappingNode() *yaml.Node {
|
||||||
}
|
return &yaml.Node{
|
||||||
return description
|
Kind: yaml.MappingNode,
|
||||||
|
Content: make([]*yaml.Node, 0),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewSequenceNode creates a new Sequence node.
|
||||||
|
func NewSequenceNode() *yaml.Node {
|
||||||
|
node := &yaml.Node{
|
||||||
|
Kind: yaml.SequenceNode,
|
||||||
|
Content: make([]*yaml.Node, 0),
|
||||||
|
}
|
||||||
|
return node
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewScalarNodeForString creates a new node to hold a string.
|
||||||
|
func NewScalarNodeForString(s string) *yaml.Node {
|
||||||
|
return &yaml.Node{
|
||||||
|
Kind: yaml.ScalarNode,
|
||||||
|
Tag: "!!str",
|
||||||
|
Value: s,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewSequenceNodeForStringArray creates a new node to hold an array of strings.
|
||||||
|
func NewSequenceNodeForStringArray(strings []string) *yaml.Node {
|
||||||
|
node := &yaml.Node{
|
||||||
|
Kind: yaml.SequenceNode,
|
||||||
|
Content: make([]*yaml.Node, 0),
|
||||||
|
}
|
||||||
|
for _, s := range strings {
|
||||||
|
node.Content = append(node.Content, NewScalarNodeForString(s))
|
||||||
|
}
|
||||||
|
return node
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewScalarNodeForBool creates a new node to hold a bool.
|
||||||
|
func NewScalarNodeForBool(b bool) *yaml.Node {
|
||||||
|
return &yaml.Node{
|
||||||
|
Kind: yaml.ScalarNode,
|
||||||
|
Tag: "!!bool",
|
||||||
|
Value: fmt.Sprintf("%t", b),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewScalarNodeForFloat creates a new node to hold a float.
|
||||||
|
func NewScalarNodeForFloat(f float64) *yaml.Node {
|
||||||
|
return &yaml.Node{
|
||||||
|
Kind: yaml.ScalarNode,
|
||||||
|
Tag: "!!float",
|
||||||
|
Value: fmt.Sprintf("%g", f),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewScalarNodeForInt creates a new node to hold an integer.
|
||||||
|
func NewScalarNodeForInt(i int64) *yaml.Node {
|
||||||
|
return &yaml.Node{
|
||||||
|
Kind: yaml.ScalarNode,
|
||||||
|
Tag: "!!int",
|
||||||
|
Value: fmt.Sprintf("%d", i),
|
||||||
}
|
}
|
||||||
description += fmt.Sprintf("%s%+v\n", indent, in)
|
|
||||||
return description
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// PluralProperties returns the string "properties" pluralized.
|
// PluralProperties returns the string "properties" pluralized.
|
||||||
@ -195,3 +357,40 @@ func StringValue(item interface{}) (value string, ok bool) {
|
|||||||
}
|
}
|
||||||
return "", false
|
return "", false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Description returns a human-readable represention of an item.
|
||||||
|
func Description(item interface{}) string {
|
||||||
|
value, ok := item.(*yaml.Node)
|
||||||
|
if ok {
|
||||||
|
return jsonschema.Render(value)
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("%+v", item)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Display returns a description of a node for use in error messages.
|
||||||
|
func Display(node *yaml.Node) string {
|
||||||
|
switch node.Kind {
|
||||||
|
case yaml.ScalarNode:
|
||||||
|
switch node.Tag {
|
||||||
|
case "!!str":
|
||||||
|
return fmt.Sprintf("%s (string)", node.Value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("%+v (%T)", node, node)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Marshal creates a yaml version of a structure in our preferred style
|
||||||
|
func Marshal(in *yaml.Node) []byte {
|
||||||
|
clearStyle(in)
|
||||||
|
//bytes, _ := yaml.Marshal(&yaml.Node{Kind: yaml.DocumentNode, Content: []*yaml.Node{in}})
|
||||||
|
bytes, _ := yaml.Marshal(in)
|
||||||
|
|
||||||
|
return bytes
|
||||||
|
}
|
||||||
|
|
||||||
|
func clearStyle(node *yaml.Node) {
|
||||||
|
node.Style = 0
|
||||||
|
for _, c := range node.Content {
|
||||||
|
clearStyle(c)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
2
vendor/github.com/googleapis/gnostic/compiler/main.go
generated
vendored
2
vendor/github.com/googleapis/gnostic/compiler/main.go
generated
vendored
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2017 Google Inc. All Rights Reserved.
|
// Copyright 2017 Google LLC. All Rights Reserved.
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
|
135
vendor/github.com/googleapis/gnostic/compiler/reader.go
generated
vendored
135
vendor/github.com/googleapis/gnostic/compiler/reader.go
generated
vendored
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2017 Google Inc. All Rights Reserved.
|
// Copyright 2017 Google LLC. All Rights Reserved.
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
@ -15,7 +15,6 @@
|
|||||||
package compiler
|
package compiler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
@ -23,18 +22,30 @@ import (
|
|||||||
"net/url"
|
"net/url"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
|
|
||||||
yaml "gopkg.in/yaml.v2"
|
yaml "gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
var fileCache map[string][]byte
|
|
||||||
var infoCache map[string]interface{}
|
|
||||||
var count int64
|
|
||||||
|
|
||||||
var verboseReader = false
|
var verboseReader = false
|
||||||
|
|
||||||
|
var fileCache map[string][]byte
|
||||||
|
var infoCache map[string]*yaml.Node
|
||||||
|
|
||||||
var fileCacheEnable = true
|
var fileCacheEnable = true
|
||||||
var infoCacheEnable = true
|
var infoCacheEnable = true
|
||||||
|
|
||||||
|
// These locks are used to synchronize accesses to the fileCache and infoCache
|
||||||
|
// maps (above). They are global state and can throw thread-related errors
|
||||||
|
// when modified from separate goroutines. The general strategy is to protect
|
||||||
|
// all public functions in this file with mutex Lock() calls. As a result, to
|
||||||
|
// avoid deadlock, these public functions should not call other public
|
||||||
|
// functions, so some public functions have private equivalents.
|
||||||
|
// In the future, we might consider replacing the maps with sync.Map and
|
||||||
|
// eliminating these mutexes.
|
||||||
|
var fileCacheMutex sync.Mutex
|
||||||
|
var infoCacheMutex sync.Mutex
|
||||||
|
|
||||||
func initializeFileCache() {
|
func initializeFileCache() {
|
||||||
if fileCache == nil {
|
if fileCache == nil {
|
||||||
fileCache = make(map[string][]byte, 0)
|
fileCache = make(map[string][]byte, 0)
|
||||||
@ -43,19 +54,42 @@ func initializeFileCache() {
|
|||||||
|
|
||||||
func initializeInfoCache() {
|
func initializeInfoCache() {
|
||||||
if infoCache == nil {
|
if infoCache == nil {
|
||||||
infoCache = make(map[string]interface{}, 0)
|
infoCache = make(map[string]*yaml.Node, 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// EnableFileCache turns on file caching.
|
||||||
|
func EnableFileCache() {
|
||||||
|
fileCacheMutex.Lock()
|
||||||
|
defer fileCacheMutex.Unlock()
|
||||||
|
fileCacheEnable = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// EnableInfoCache turns on parsed info caching.
|
||||||
|
func EnableInfoCache() {
|
||||||
|
infoCacheMutex.Lock()
|
||||||
|
defer infoCacheMutex.Unlock()
|
||||||
|
infoCacheEnable = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// DisableFileCache turns off file caching.
|
||||||
func DisableFileCache() {
|
func DisableFileCache() {
|
||||||
|
fileCacheMutex.Lock()
|
||||||
|
defer fileCacheMutex.Unlock()
|
||||||
fileCacheEnable = false
|
fileCacheEnable = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DisableInfoCache turns off parsed info caching.
|
||||||
func DisableInfoCache() {
|
func DisableInfoCache() {
|
||||||
|
infoCacheMutex.Lock()
|
||||||
|
defer infoCacheMutex.Unlock()
|
||||||
infoCacheEnable = false
|
infoCacheEnable = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RemoveFromFileCache removes an entry from the file cache.
|
||||||
func RemoveFromFileCache(fileurl string) {
|
func RemoveFromFileCache(fileurl string) {
|
||||||
|
fileCacheMutex.Lock()
|
||||||
|
defer fileCacheMutex.Unlock()
|
||||||
if !fileCacheEnable {
|
if !fileCacheEnable {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -63,7 +97,10 @@ func RemoveFromFileCache(fileurl string) {
|
|||||||
delete(fileCache, fileurl)
|
delete(fileCache, fileurl)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RemoveFromInfoCache removes an entry from the info cache.
|
||||||
func RemoveFromInfoCache(filename string) {
|
func RemoveFromInfoCache(filename string) {
|
||||||
|
infoCacheMutex.Lock()
|
||||||
|
defer infoCacheMutex.Unlock()
|
||||||
if !infoCacheEnable {
|
if !infoCacheEnable {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -71,19 +108,44 @@ func RemoveFromInfoCache(filename string) {
|
|||||||
delete(infoCache, filename)
|
delete(infoCache, filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetInfoCache() map[string]interface{} {
|
// GetInfoCache returns the info cache map.
|
||||||
|
func GetInfoCache() map[string]*yaml.Node {
|
||||||
|
infoCacheMutex.Lock()
|
||||||
|
defer infoCacheMutex.Unlock()
|
||||||
if infoCache == nil {
|
if infoCache == nil {
|
||||||
initializeInfoCache()
|
initializeInfoCache()
|
||||||
}
|
}
|
||||||
return infoCache
|
return infoCache
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ClearFileCache clears the file cache.
|
||||||
|
func ClearFileCache() {
|
||||||
|
fileCacheMutex.Lock()
|
||||||
|
defer fileCacheMutex.Unlock()
|
||||||
|
fileCache = make(map[string][]byte, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClearInfoCache clears the info cache.
|
||||||
func ClearInfoCache() {
|
func ClearInfoCache() {
|
||||||
infoCache = make(map[string]interface{})
|
infoCacheMutex.Lock()
|
||||||
|
defer infoCacheMutex.Unlock()
|
||||||
|
infoCache = make(map[string]*yaml.Node)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClearCaches clears all caches.
|
||||||
|
func ClearCaches() {
|
||||||
|
ClearFileCache()
|
||||||
|
ClearInfoCache()
|
||||||
}
|
}
|
||||||
|
|
||||||
// FetchFile gets a specified file from the local filesystem or a remote location.
|
// FetchFile gets a specified file from the local filesystem or a remote location.
|
||||||
func FetchFile(fileurl string) ([]byte, error) {
|
func FetchFile(fileurl string) ([]byte, error) {
|
||||||
|
fileCacheMutex.Lock()
|
||||||
|
defer fileCacheMutex.Unlock()
|
||||||
|
return fetchFile(fileurl)
|
||||||
|
}
|
||||||
|
|
||||||
|
func fetchFile(fileurl string) ([]byte, error) {
|
||||||
var bytes []byte
|
var bytes []byte
|
||||||
initializeFileCache()
|
initializeFileCache()
|
||||||
if fileCacheEnable {
|
if fileCacheEnable {
|
||||||
@ -104,7 +166,7 @@ func FetchFile(fileurl string) ([]byte, error) {
|
|||||||
}
|
}
|
||||||
defer response.Body.Close()
|
defer response.Body.Close()
|
||||||
if response.StatusCode != 200 {
|
if response.StatusCode != 200 {
|
||||||
return nil, errors.New(fmt.Sprintf("Error downloading %s: %s", fileurl, response.Status))
|
return nil, fmt.Errorf("Error downloading %s: %s", fileurl, response.Status)
|
||||||
}
|
}
|
||||||
bytes, err = ioutil.ReadAll(response.Body)
|
bytes, err = ioutil.ReadAll(response.Body)
|
||||||
if fileCacheEnable && err == nil {
|
if fileCacheEnable && err == nil {
|
||||||
@ -115,11 +177,17 @@ func FetchFile(fileurl string) ([]byte, error) {
|
|||||||
|
|
||||||
// ReadBytesForFile reads the bytes of a file.
|
// ReadBytesForFile reads the bytes of a file.
|
||||||
func ReadBytesForFile(filename string) ([]byte, error) {
|
func ReadBytesForFile(filename string) ([]byte, error) {
|
||||||
|
fileCacheMutex.Lock()
|
||||||
|
defer fileCacheMutex.Unlock()
|
||||||
|
return readBytesForFile(filename)
|
||||||
|
}
|
||||||
|
|
||||||
|
func readBytesForFile(filename string) ([]byte, error) {
|
||||||
// is the filename a url?
|
// is the filename a url?
|
||||||
fileurl, _ := url.Parse(filename)
|
fileurl, _ := url.Parse(filename)
|
||||||
if fileurl.Scheme != "" {
|
if fileurl.Scheme != "" {
|
||||||
// yes, fetch it
|
// yes, fetch it
|
||||||
bytes, err := FetchFile(filename)
|
bytes, err := fetchFile(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -133,8 +201,14 @@ func ReadBytesForFile(filename string) ([]byte, error) {
|
|||||||
return bytes, nil
|
return bytes, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReadInfoFromBytes unmarshals a file as a yaml.MapSlice.
|
// ReadInfoFromBytes unmarshals a file as a *yaml.Node.
|
||||||
func ReadInfoFromBytes(filename string, bytes []byte) (interface{}, error) {
|
func ReadInfoFromBytes(filename string, bytes []byte) (*yaml.Node, error) {
|
||||||
|
infoCacheMutex.Lock()
|
||||||
|
defer infoCacheMutex.Unlock()
|
||||||
|
return readInfoFromBytes(filename, bytes)
|
||||||
|
}
|
||||||
|
|
||||||
|
func readInfoFromBytes(filename string, bytes []byte) (*yaml.Node, error) {
|
||||||
initializeInfoCache()
|
initializeInfoCache()
|
||||||
if infoCacheEnable {
|
if infoCacheEnable {
|
||||||
cachedInfo, ok := infoCache[filename]
|
cachedInfo, ok := infoCache[filename]
|
||||||
@ -148,19 +222,23 @@ func ReadInfoFromBytes(filename string, bytes []byte) (interface{}, error) {
|
|||||||
log.Printf("Reading info for file %s", filename)
|
log.Printf("Reading info for file %s", filename)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var info yaml.MapSlice
|
var info yaml.Node
|
||||||
err := yaml.Unmarshal(bytes, &info)
|
err := yaml.Unmarshal(bytes, &info)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if infoCacheEnable && len(filename) > 0 {
|
if infoCacheEnable && len(filename) > 0 {
|
||||||
infoCache[filename] = info
|
infoCache[filename] = &info
|
||||||
}
|
}
|
||||||
return info, nil
|
return &info, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReadInfoForRef reads a file and return the fragment needed to resolve a $ref.
|
// ReadInfoForRef reads a file and return the fragment needed to resolve a $ref.
|
||||||
func ReadInfoForRef(basefile string, ref string) (interface{}, error) {
|
func ReadInfoForRef(basefile string, ref string) (*yaml.Node, error) {
|
||||||
|
fileCacheMutex.Lock()
|
||||||
|
defer fileCacheMutex.Unlock()
|
||||||
|
infoCacheMutex.Lock()
|
||||||
|
defer infoCacheMutex.Unlock()
|
||||||
initializeInfoCache()
|
initializeInfoCache()
|
||||||
if infoCacheEnable {
|
if infoCacheEnable {
|
||||||
info, ok := infoCache[ref]
|
info, ok := infoCache[ref]
|
||||||
@ -174,7 +252,6 @@ func ReadInfoForRef(basefile string, ref string) (interface{}, error) {
|
|||||||
log.Printf("Reading info for ref %s#%s", basefile, ref)
|
log.Printf("Reading info for ref %s#%s", basefile, ref)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
count = count + 1
|
|
||||||
basedir, _ := filepath.Split(basefile)
|
basedir, _ := filepath.Split(basefile)
|
||||||
parts := strings.Split(ref, "#")
|
parts := strings.Split(ref, "#")
|
||||||
var filename string
|
var filename string
|
||||||
@ -187,24 +264,30 @@ func ReadInfoForRef(basefile string, ref string) (interface{}, error) {
|
|||||||
} else {
|
} else {
|
||||||
filename = basefile
|
filename = basefile
|
||||||
}
|
}
|
||||||
bytes, err := ReadBytesForFile(filename)
|
bytes, err := readBytesForFile(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
info, err := ReadInfoFromBytes(filename, bytes)
|
info, err := readInfoFromBytes(filename, bytes)
|
||||||
|
if info != nil && info.Kind == yaml.DocumentNode {
|
||||||
|
info = info.Content[0]
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("File error: %v\n", err)
|
log.Printf("File error: %v\n", err)
|
||||||
} else {
|
} else {
|
||||||
|
if info == nil {
|
||||||
|
return nil, NewError(nil, fmt.Sprintf("could not resolve %s", ref))
|
||||||
|
}
|
||||||
if len(parts) > 1 {
|
if len(parts) > 1 {
|
||||||
path := strings.Split(parts[1], "/")
|
path := strings.Split(parts[1], "/")
|
||||||
for i, key := range path {
|
for i, key := range path {
|
||||||
if i > 0 {
|
if i > 0 {
|
||||||
m, ok := info.(yaml.MapSlice)
|
m := info
|
||||||
if ok {
|
if true {
|
||||||
found := false
|
found := false
|
||||||
for _, section := range m {
|
for i := 0; i < len(m.Content); i += 2 {
|
||||||
if section.Key == key {
|
if m.Content[i].Value == key {
|
||||||
info = section.Value
|
info = m.Content[i+1]
|
||||||
found = true
|
found = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
12
vendor/github.com/googleapis/gnostic/extensions/README.md
generated
vendored
12
vendor/github.com/googleapis/gnostic/extensions/README.md
generated
vendored
@ -1,5 +1,13 @@
|
|||||||
# Extensions
|
# Extensions
|
||||||
|
|
||||||
This directory contains support code for building Gnostic extensions and associated examples.
|
**Extension Support is experimental.**
|
||||||
|
|
||||||
Extensions are used to compile vendor or specification extensions into protocol buffer structures.
|
This directory contains support code for building Gnostic extensio handlers and
|
||||||
|
associated examples.
|
||||||
|
|
||||||
|
Extension handlers can be used to compile vendor or specification extensions
|
||||||
|
into protocol buffer structures.
|
||||||
|
|
||||||
|
Like plugins, extension handlers are built as separate executables. Extension
|
||||||
|
bodies are written to extension handlers as serialized
|
||||||
|
ExtensionHandlerRequests.
|
||||||
|
547
vendor/github.com/googleapis/gnostic/extensions/extension.pb.go
generated
vendored
547
vendor/github.com/googleapis/gnostic/extensions/extension.pb.go
generated
vendored
@ -1,148 +1,186 @@
|
|||||||
|
// Copyright 2017 Google LLC. All Rights Reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||||
|
// versions:
|
||||||
|
// protoc-gen-go v1.24.0
|
||||||
|
// protoc v3.12.0
|
||||||
// source: extensions/extension.proto
|
// source: extensions/extension.proto
|
||||||
|
|
||||||
package openapiextension_v1
|
package gnostic_extension_v1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
fmt "fmt"
|
|
||||||
proto "github.com/golang/protobuf/proto"
|
proto "github.com/golang/protobuf/proto"
|
||||||
any "github.com/golang/protobuf/ptypes/any"
|
any "github.com/golang/protobuf/ptypes/any"
|
||||||
math "math"
|
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||||
|
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||||
|
reflect "reflect"
|
||||||
|
sync "sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Reference imports to suppress errors if they are not otherwise used.
|
const (
|
||||||
var _ = proto.Marshal
|
// Verify that this generated code is sufficiently up-to-date.
|
||||||
var _ = fmt.Errorf
|
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||||
var _ = math.Inf
|
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||||
|
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||||
|
)
|
||||||
|
|
||||||
// This is a compile-time assertion to ensure that this generated file
|
// This is a compile-time assertion that a sufficiently up-to-date version
|
||||||
// is compatible with the proto package it is being compiled against.
|
// of the legacy proto package is being used.
|
||||||
// A compilation error at this line likely means your copy of the
|
const _ = proto.ProtoPackageIsVersion4
|
||||||
// proto package needs to be updated.
|
|
||||||
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
|
|
||||||
|
|
||||||
// The version number of OpenAPI compiler.
|
// The version number of Gnostic.
|
||||||
type Version struct {
|
type Version struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
Major int32 `protobuf:"varint,1,opt,name=major,proto3" json:"major,omitempty"`
|
Major int32 `protobuf:"varint,1,opt,name=major,proto3" json:"major,omitempty"`
|
||||||
Minor int32 `protobuf:"varint,2,opt,name=minor,proto3" json:"minor,omitempty"`
|
Minor int32 `protobuf:"varint,2,opt,name=minor,proto3" json:"minor,omitempty"`
|
||||||
Patch int32 `protobuf:"varint,3,opt,name=patch,proto3" json:"patch,omitempty"`
|
Patch int32 `protobuf:"varint,3,opt,name=patch,proto3" json:"patch,omitempty"`
|
||||||
// A suffix for alpha, beta or rc release, e.g., "alpha-1", "rc2". It should
|
// A suffix for alpha, beta or rc release, e.g., "alpha-1", "rc2". It should
|
||||||
// be empty for mainline stable releases.
|
// be empty for mainline stable releases.
|
||||||
Suffix string `protobuf:"bytes,4,opt,name=suffix,proto3" json:"suffix,omitempty"`
|
Suffix string `protobuf:"bytes,4,opt,name=suffix,proto3" json:"suffix,omitempty"`
|
||||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
|
||||||
XXX_unrecognized []byte `json:"-"`
|
|
||||||
XXX_sizecache int32 `json:"-"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Version) Reset() { *m = Version{} }
|
func (x *Version) Reset() {
|
||||||
func (m *Version) String() string { return proto.CompactTextString(m) }
|
*x = Version{}
|
||||||
func (*Version) ProtoMessage() {}
|
if protoimpl.UnsafeEnabled {
|
||||||
|
mi := &file_extensions_extension_proto_msgTypes[0]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *Version) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*Version) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *Version) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_extensions_extension_proto_msgTypes[0]
|
||||||
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use Version.ProtoReflect.Descriptor instead.
|
||||||
func (*Version) Descriptor() ([]byte, []int) {
|
func (*Version) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_661e47e790f76671, []int{0}
|
return file_extensions_extension_proto_rawDescGZIP(), []int{0}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Version) XXX_Unmarshal(b []byte) error {
|
func (x *Version) GetMajor() int32 {
|
||||||
return xxx_messageInfo_Version.Unmarshal(m, b)
|
if x != nil {
|
||||||
}
|
return x.Major
|
||||||
func (m *Version) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
|
||||||
return xxx_messageInfo_Version.Marshal(b, m, deterministic)
|
|
||||||
}
|
|
||||||
func (m *Version) XXX_Merge(src proto.Message) {
|
|
||||||
xxx_messageInfo_Version.Merge(m, src)
|
|
||||||
}
|
|
||||||
func (m *Version) XXX_Size() int {
|
|
||||||
return xxx_messageInfo_Version.Size(m)
|
|
||||||
}
|
|
||||||
func (m *Version) XXX_DiscardUnknown() {
|
|
||||||
xxx_messageInfo_Version.DiscardUnknown(m)
|
|
||||||
}
|
|
||||||
|
|
||||||
var xxx_messageInfo_Version proto.InternalMessageInfo
|
|
||||||
|
|
||||||
func (m *Version) GetMajor() int32 {
|
|
||||||
if m != nil {
|
|
||||||
return m.Major
|
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Version) GetMinor() int32 {
|
func (x *Version) GetMinor() int32 {
|
||||||
if m != nil {
|
if x != nil {
|
||||||
return m.Minor
|
return x.Minor
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Version) GetPatch() int32 {
|
func (x *Version) GetPatch() int32 {
|
||||||
if m != nil {
|
if x != nil {
|
||||||
return m.Patch
|
return x.Patch
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Version) GetSuffix() string {
|
func (x *Version) GetSuffix() string {
|
||||||
if m != nil {
|
if x != nil {
|
||||||
return m.Suffix
|
return x.Suffix
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
// An encoded Request is written to the ExtensionHandler's stdin.
|
// An encoded Request is written to the ExtensionHandler's stdin.
|
||||||
type ExtensionHandlerRequest struct {
|
type ExtensionHandlerRequest struct {
|
||||||
// The OpenAPI descriptions that were explicitly listed on the command line.
|
state protoimpl.MessageState
|
||||||
// The specifications will appear in the order they are specified to gnostic.
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
// The extension to process.
|
||||||
Wrapper *Wrapper `protobuf:"bytes,1,opt,name=wrapper,proto3" json:"wrapper,omitempty"`
|
Wrapper *Wrapper `protobuf:"bytes,1,opt,name=wrapper,proto3" json:"wrapper,omitempty"`
|
||||||
// The version number of openapi compiler.
|
// The version number of Gnostic.
|
||||||
CompilerVersion *Version `protobuf:"bytes,3,opt,name=compiler_version,json=compilerVersion,proto3" json:"compiler_version,omitempty"`
|
CompilerVersion *Version `protobuf:"bytes,2,opt,name=compiler_version,json=compilerVersion,proto3" json:"compiler_version,omitempty"`
|
||||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
|
||||||
XXX_unrecognized []byte `json:"-"`
|
|
||||||
XXX_sizecache int32 `json:"-"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *ExtensionHandlerRequest) Reset() { *m = ExtensionHandlerRequest{} }
|
func (x *ExtensionHandlerRequest) Reset() {
|
||||||
func (m *ExtensionHandlerRequest) String() string { return proto.CompactTextString(m) }
|
*x = ExtensionHandlerRequest{}
|
||||||
func (*ExtensionHandlerRequest) ProtoMessage() {}
|
if protoimpl.UnsafeEnabled {
|
||||||
|
mi := &file_extensions_extension_proto_msgTypes[1]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ExtensionHandlerRequest) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*ExtensionHandlerRequest) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *ExtensionHandlerRequest) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_extensions_extension_proto_msgTypes[1]
|
||||||
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use ExtensionHandlerRequest.ProtoReflect.Descriptor instead.
|
||||||
func (*ExtensionHandlerRequest) Descriptor() ([]byte, []int) {
|
func (*ExtensionHandlerRequest) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_661e47e790f76671, []int{1}
|
return file_extensions_extension_proto_rawDescGZIP(), []int{1}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *ExtensionHandlerRequest) XXX_Unmarshal(b []byte) error {
|
func (x *ExtensionHandlerRequest) GetWrapper() *Wrapper {
|
||||||
return xxx_messageInfo_ExtensionHandlerRequest.Unmarshal(m, b)
|
if x != nil {
|
||||||
}
|
return x.Wrapper
|
||||||
func (m *ExtensionHandlerRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
|
||||||
return xxx_messageInfo_ExtensionHandlerRequest.Marshal(b, m, deterministic)
|
|
||||||
}
|
|
||||||
func (m *ExtensionHandlerRequest) XXX_Merge(src proto.Message) {
|
|
||||||
xxx_messageInfo_ExtensionHandlerRequest.Merge(m, src)
|
|
||||||
}
|
|
||||||
func (m *ExtensionHandlerRequest) XXX_Size() int {
|
|
||||||
return xxx_messageInfo_ExtensionHandlerRequest.Size(m)
|
|
||||||
}
|
|
||||||
func (m *ExtensionHandlerRequest) XXX_DiscardUnknown() {
|
|
||||||
xxx_messageInfo_ExtensionHandlerRequest.DiscardUnknown(m)
|
|
||||||
}
|
|
||||||
|
|
||||||
var xxx_messageInfo_ExtensionHandlerRequest proto.InternalMessageInfo
|
|
||||||
|
|
||||||
func (m *ExtensionHandlerRequest) GetWrapper() *Wrapper {
|
|
||||||
if m != nil {
|
|
||||||
return m.Wrapper
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *ExtensionHandlerRequest) GetCompilerVersion() *Version {
|
func (x *ExtensionHandlerRequest) GetCompilerVersion() *Version {
|
||||||
if m != nil {
|
if x != nil {
|
||||||
return m.CompilerVersion
|
return x.CompilerVersion
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// The extensions writes an encoded ExtensionHandlerResponse to stdout.
|
// The extensions writes an encoded ExtensionHandlerResponse to stdout.
|
||||||
type ExtensionHandlerResponse struct {
|
type ExtensionHandlerResponse struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
// true if the extension is handled by the extension handler; false otherwise
|
// true if the extension is handled by the extension handler; false otherwise
|
||||||
Handled bool `protobuf:"varint,1,opt,name=handled,proto3" json:"handled,omitempty"`
|
Handled bool `protobuf:"varint,1,opt,name=handled,proto3" json:"handled,omitempty"`
|
||||||
// Error message. If non-empty, the extension handling failed.
|
// Error message(s). If non-empty, the extension handling failed.
|
||||||
// The extension handler process should exit with status code zero
|
// The extension handler process should exit with status code zero
|
||||||
// even if it reports an error in this way.
|
// even if it reports an error in this way.
|
||||||
//
|
//
|
||||||
@ -151,150 +189,277 @@ type ExtensionHandlerResponse struct {
|
|||||||
// itself -- such as the input Document being unparseable -- should be
|
// itself -- such as the input Document being unparseable -- should be
|
||||||
// reported by writing a message to stderr and exiting with a non-zero
|
// reported by writing a message to stderr and exiting with a non-zero
|
||||||
// status code.
|
// status code.
|
||||||
Error []string `protobuf:"bytes,2,rep,name=error,proto3" json:"error,omitempty"`
|
Errors []string `protobuf:"bytes,2,rep,name=errors,proto3" json:"errors,omitempty"`
|
||||||
// text output
|
// text output
|
||||||
Value *any.Any `protobuf:"bytes,3,opt,name=value,proto3" json:"value,omitempty"`
|
Value *any.Any `protobuf:"bytes,3,opt,name=value,proto3" json:"value,omitempty"`
|
||||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
|
||||||
XXX_unrecognized []byte `json:"-"`
|
|
||||||
XXX_sizecache int32 `json:"-"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *ExtensionHandlerResponse) Reset() { *m = ExtensionHandlerResponse{} }
|
func (x *ExtensionHandlerResponse) Reset() {
|
||||||
func (m *ExtensionHandlerResponse) String() string { return proto.CompactTextString(m) }
|
*x = ExtensionHandlerResponse{}
|
||||||
func (*ExtensionHandlerResponse) ProtoMessage() {}
|
if protoimpl.UnsafeEnabled {
|
||||||
|
mi := &file_extensions_extension_proto_msgTypes[2]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ExtensionHandlerResponse) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*ExtensionHandlerResponse) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *ExtensionHandlerResponse) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_extensions_extension_proto_msgTypes[2]
|
||||||
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use ExtensionHandlerResponse.ProtoReflect.Descriptor instead.
|
||||||
func (*ExtensionHandlerResponse) Descriptor() ([]byte, []int) {
|
func (*ExtensionHandlerResponse) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_661e47e790f76671, []int{2}
|
return file_extensions_extension_proto_rawDescGZIP(), []int{2}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *ExtensionHandlerResponse) XXX_Unmarshal(b []byte) error {
|
func (x *ExtensionHandlerResponse) GetHandled() bool {
|
||||||
return xxx_messageInfo_ExtensionHandlerResponse.Unmarshal(m, b)
|
if x != nil {
|
||||||
}
|
return x.Handled
|
||||||
func (m *ExtensionHandlerResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
|
||||||
return xxx_messageInfo_ExtensionHandlerResponse.Marshal(b, m, deterministic)
|
|
||||||
}
|
|
||||||
func (m *ExtensionHandlerResponse) XXX_Merge(src proto.Message) {
|
|
||||||
xxx_messageInfo_ExtensionHandlerResponse.Merge(m, src)
|
|
||||||
}
|
|
||||||
func (m *ExtensionHandlerResponse) XXX_Size() int {
|
|
||||||
return xxx_messageInfo_ExtensionHandlerResponse.Size(m)
|
|
||||||
}
|
|
||||||
func (m *ExtensionHandlerResponse) XXX_DiscardUnknown() {
|
|
||||||
xxx_messageInfo_ExtensionHandlerResponse.DiscardUnknown(m)
|
|
||||||
}
|
|
||||||
|
|
||||||
var xxx_messageInfo_ExtensionHandlerResponse proto.InternalMessageInfo
|
|
||||||
|
|
||||||
func (m *ExtensionHandlerResponse) GetHandled() bool {
|
|
||||||
if m != nil {
|
|
||||||
return m.Handled
|
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *ExtensionHandlerResponse) GetError() []string {
|
func (x *ExtensionHandlerResponse) GetErrors() []string {
|
||||||
if m != nil {
|
if x != nil {
|
||||||
return m.Error
|
return x.Errors
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *ExtensionHandlerResponse) GetValue() *any.Any {
|
func (x *ExtensionHandlerResponse) GetValue() *any.Any {
|
||||||
if m != nil {
|
if x != nil {
|
||||||
return m.Value
|
return x.Value
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type Wrapper struct {
|
type Wrapper struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
// version of the OpenAPI specification in which this extension was written.
|
// version of the OpenAPI specification in which this extension was written.
|
||||||
Version string `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"`
|
Version string `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"`
|
||||||
// Name of the extension
|
// Name of the extension.
|
||||||
ExtensionName string `protobuf:"bytes,2,opt,name=extension_name,json=extensionName,proto3" json:"extension_name,omitempty"`
|
ExtensionName string `protobuf:"bytes,2,opt,name=extension_name,json=extensionName,proto3" json:"extension_name,omitempty"`
|
||||||
// Must be a valid yaml for the proto
|
// YAML-formatted extension value.
|
||||||
Yaml string `protobuf:"bytes,3,opt,name=yaml,proto3" json:"yaml,omitempty"`
|
Yaml string `protobuf:"bytes,3,opt,name=yaml,proto3" json:"yaml,omitempty"`
|
||||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
|
||||||
XXX_unrecognized []byte `json:"-"`
|
|
||||||
XXX_sizecache int32 `json:"-"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Wrapper) Reset() { *m = Wrapper{} }
|
func (x *Wrapper) Reset() {
|
||||||
func (m *Wrapper) String() string { return proto.CompactTextString(m) }
|
*x = Wrapper{}
|
||||||
func (*Wrapper) ProtoMessage() {}
|
if protoimpl.UnsafeEnabled {
|
||||||
|
mi := &file_extensions_extension_proto_msgTypes[3]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *Wrapper) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*Wrapper) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *Wrapper) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_extensions_extension_proto_msgTypes[3]
|
||||||
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use Wrapper.ProtoReflect.Descriptor instead.
|
||||||
func (*Wrapper) Descriptor() ([]byte, []int) {
|
func (*Wrapper) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_661e47e790f76671, []int{3}
|
return file_extensions_extension_proto_rawDescGZIP(), []int{3}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Wrapper) XXX_Unmarshal(b []byte) error {
|
func (x *Wrapper) GetVersion() string {
|
||||||
return xxx_messageInfo_Wrapper.Unmarshal(m, b)
|
if x != nil {
|
||||||
}
|
return x.Version
|
||||||
func (m *Wrapper) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
|
||||||
return xxx_messageInfo_Wrapper.Marshal(b, m, deterministic)
|
|
||||||
}
|
|
||||||
func (m *Wrapper) XXX_Merge(src proto.Message) {
|
|
||||||
xxx_messageInfo_Wrapper.Merge(m, src)
|
|
||||||
}
|
|
||||||
func (m *Wrapper) XXX_Size() int {
|
|
||||||
return xxx_messageInfo_Wrapper.Size(m)
|
|
||||||
}
|
|
||||||
func (m *Wrapper) XXX_DiscardUnknown() {
|
|
||||||
xxx_messageInfo_Wrapper.DiscardUnknown(m)
|
|
||||||
}
|
|
||||||
|
|
||||||
var xxx_messageInfo_Wrapper proto.InternalMessageInfo
|
|
||||||
|
|
||||||
func (m *Wrapper) GetVersion() string {
|
|
||||||
if m != nil {
|
|
||||||
return m.Version
|
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Wrapper) GetExtensionName() string {
|
func (x *Wrapper) GetExtensionName() string {
|
||||||
if m != nil {
|
if x != nil {
|
||||||
return m.ExtensionName
|
return x.ExtensionName
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Wrapper) GetYaml() string {
|
func (x *Wrapper) GetYaml() string {
|
||||||
if m != nil {
|
if x != nil {
|
||||||
return m.Yaml
|
return x.Yaml
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
var File_extensions_extension_proto protoreflect.FileDescriptor
|
||||||
proto.RegisterType((*Version)(nil), "openapiextension.v1.Version")
|
|
||||||
proto.RegisterType((*ExtensionHandlerRequest)(nil), "openapiextension.v1.ExtensionHandlerRequest")
|
var file_extensions_extension_proto_rawDesc = []byte{
|
||||||
proto.RegisterType((*ExtensionHandlerResponse)(nil), "openapiextension.v1.ExtensionHandlerResponse")
|
0x0a, 0x1a, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x65, 0x78, 0x74,
|
||||||
proto.RegisterType((*Wrapper)(nil), "openapiextension.v1.Wrapper")
|
0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x14, 0x67, 0x6e,
|
||||||
|
0x6f, 0x73, 0x74, 0x69, 0x63, 0x2e, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x2e,
|
||||||
|
0x76, 0x31, 0x1a, 0x19, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||||
|
0x62, 0x75, 0x66, 0x2f, 0x61, 0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x63, 0x0a,
|
||||||
|
0x07, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x6d, 0x61, 0x6a, 0x6f,
|
||||||
|
0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x6d, 0x61, 0x6a, 0x6f, 0x72, 0x12, 0x14,
|
||||||
|
0x0a, 0x05, 0x6d, 0x69, 0x6e, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x6d,
|
||||||
|
0x69, 0x6e, 0x6f, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x61, 0x74, 0x63, 0x68, 0x18, 0x03, 0x20,
|
||||||
|
0x01, 0x28, 0x05, 0x52, 0x05, 0x70, 0x61, 0x74, 0x63, 0x68, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x75,
|
||||||
|
0x66, 0x66, 0x69, 0x78, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x75, 0x66, 0x66,
|
||||||
|
0x69, 0x78, 0x22, 0x9c, 0x01, 0x0a, 0x17, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e,
|
||||||
|
0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x37,
|
||||||
|
0x0a, 0x07, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32,
|
||||||
|
0x1d, 0x2e, 0x67, 0x6e, 0x6f, 0x73, 0x74, 0x69, 0x63, 0x2e, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73,
|
||||||
|
0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x57, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x52, 0x07,
|
||||||
|
0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x12, 0x48, 0x0a, 0x10, 0x63, 0x6f, 0x6d, 0x70, 0x69,
|
||||||
|
0x6c, 0x65, 0x72, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28,
|
||||||
|
0x0b, 0x32, 0x1d, 0x2e, 0x67, 0x6e, 0x6f, 0x73, 0x74, 0x69, 0x63, 0x2e, 0x65, 0x78, 0x74, 0x65,
|
||||||
|
0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e,
|
||||||
|
0x52, 0x0f, 0x63, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f,
|
||||||
|
0x6e, 0x22, 0x78, 0x0a, 0x18, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x48, 0x61,
|
||||||
|
0x6e, 0x64, 0x6c, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a,
|
||||||
|
0x07, 0x68, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07,
|
||||||
|
0x68, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x65, 0x72, 0x72, 0x6f, 0x72,
|
||||||
|
0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x12,
|
||||||
|
0x2a, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14,
|
||||||
|
0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66,
|
||||||
|
0x2e, 0x41, 0x6e, 0x79, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x5e, 0x0a, 0x07, 0x57,
|
||||||
|
0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f,
|
||||||
|
0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e,
|
||||||
|
0x12, 0x25, 0x0a, 0x0e, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x6e, 0x61,
|
||||||
|
0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73,
|
||||||
|
0x69, 0x6f, 0x6e, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x79, 0x61, 0x6d, 0x6c, 0x18,
|
||||||
|
0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x79, 0x61, 0x6d, 0x6c, 0x42, 0x4b, 0x0a, 0x0e, 0x6f,
|
||||||
|
0x72, 0x67, 0x2e, 0x67, 0x6e, 0x6f, 0x73, 0x74, 0x69, 0x63, 0x2e, 0x76, 0x31, 0x42, 0x10, 0x47,
|
||||||
|
0x6e, 0x6f, 0x73, 0x74, 0x69, 0x63, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x50,
|
||||||
|
0x01, 0x5a, 0x1f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x3b, 0x67, 0x6e,
|
||||||
|
0x6f, 0x73, 0x74, 0x69, 0x63, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x5f,
|
||||||
|
0x76, 0x31, 0xa2, 0x02, 0x03, 0x47, 0x4e, 0x58, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { proto.RegisterFile("extensions/extension.proto", fileDescriptor_661e47e790f76671) }
|
var (
|
||||||
|
file_extensions_extension_proto_rawDescOnce sync.Once
|
||||||
|
file_extensions_extension_proto_rawDescData = file_extensions_extension_proto_rawDesc
|
||||||
|
)
|
||||||
|
|
||||||
var fileDescriptor_661e47e790f76671 = []byte{
|
func file_extensions_extension_proto_rawDescGZIP() []byte {
|
||||||
// 360 bytes of a gzipped FileDescriptorProto
|
file_extensions_extension_proto_rawDescOnce.Do(func() {
|
||||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x74, 0x91, 0xdf, 0x4b, 0xeb, 0x30,
|
file_extensions_extension_proto_rawDescData = protoimpl.X.CompressGZIP(file_extensions_extension_proto_rawDescData)
|
||||||
0x1c, 0xc5, 0xe9, 0x7e, 0xf5, 0xee, 0x7b, 0xb9, 0xbb, 0x12, 0x87, 0xd6, 0xe1, 0x83, 0x14, 0x04,
|
})
|
||||||
0x11, 0xe9, 0x98, 0x82, 0xef, 0x1b, 0x0c, 0xf5, 0xc5, 0x8d, 0x3c, 0xcc, 0x37, 0x47, 0xd6, 0x65,
|
return file_extensions_extension_proto_rawDescData
|
||||||
0x5d, 0xa5, 0x4d, 0x62, 0xfa, 0xc3, 0xed, 0x5f, 0xf1, 0xd1, 0xbf, 0xd4, 0x34, 0x69, 0xeb, 0x83,
|
}
|
||||||
0xfa, 0x96, 0xf3, 0xe1, 0x34, 0x39, 0xe7, 0x14, 0x06, 0x74, 0x97, 0x52, 0x96, 0x84, 0x9c, 0x25,
|
|
||||||
0xc3, 0xfa, 0xe8, 0x09, 0xc9, 0x53, 0x8e, 0x0e, 0xb9, 0xa0, 0x8c, 0x88, 0xf0, 0x8b, 0xe7, 0xa3,
|
var file_extensions_extension_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
|
||||||
0xc1, 0x49, 0xc0, 0x79, 0x10, 0xd1, 0xa1, 0xb6, 0xac, 0xb2, 0xcd, 0x90, 0xb0, 0xbd, 0xf1, 0xbb,
|
var file_extensions_extension_proto_goTypes = []interface{}{
|
||||||
0x3e, 0xd8, 0x0b, 0x2a, 0x0b, 0x23, 0xea, 0x43, 0x3b, 0x26, 0x2f, 0x5c, 0x3a, 0xd6, 0x99, 0x75,
|
(*Version)(nil), // 0: gnostic.extension.v1.Version
|
||||||
0xd1, 0xc6, 0x46, 0x68, 0x1a, 0x32, 0x45, 0x1b, 0x25, 0x2d, 0x44, 0x41, 0x05, 0x49, 0xfd, 0xad,
|
(*ExtensionHandlerRequest)(nil), // 1: gnostic.extension.v1.ExtensionHandlerRequest
|
||||||
0xd3, 0x34, 0x54, 0x0b, 0x74, 0x04, 0x9d, 0x24, 0xdb, 0x6c, 0xc2, 0x9d, 0xd3, 0x52, 0xb8, 0x8b,
|
(*ExtensionHandlerResponse)(nil), // 2: gnostic.extension.v1.ExtensionHandlerResponse
|
||||||
0x4b, 0xe5, 0xbe, 0x5b, 0x70, 0x3c, 0xad, 0x02, 0xdd, 0x13, 0xb6, 0x8e, 0xa8, 0xc4, 0xf4, 0x35,
|
(*Wrapper)(nil), // 3: gnostic.extension.v1.Wrapper
|
||||||
0xa3, 0x49, 0x8a, 0x6e, 0xc1, 0x7e, 0x93, 0x44, 0x08, 0x6a, 0xde, 0xfd, 0x7b, 0x7d, 0xea, 0xfd,
|
(*any.Any)(nil), // 4: google.protobuf.Any
|
||||||
0x50, 0xc1, 0x7b, 0x32, 0x1e, 0x5c, 0x99, 0xd1, 0x1d, 0x1c, 0xf8, 0x3c, 0x16, 0xa1, 0xba, 0x6a,
|
}
|
||||||
0x99, 0x9b, 0x06, 0x3a, 0xcc, 0x6f, 0x17, 0x94, 0x2d, 0xf1, 0xff, 0xea, 0xab, 0x12, 0xb8, 0x39,
|
var file_extensions_extension_proto_depIdxs = []int32{
|
||||||
0x38, 0xdf, 0xb3, 0x25, 0x42, 0x8d, 0x4b, 0x91, 0x03, 0xf6, 0x56, 0xa3, 0xb5, 0x0e, 0xf7, 0x07,
|
3, // 0: gnostic.extension.v1.ExtensionHandlerRequest.wrapper:type_name -> gnostic.extension.v1.Wrapper
|
||||||
0x57, 0xb2, 0x18, 0x80, 0x4a, 0xa9, 0x67, 0x69, 0xaa, 0xa6, 0x46, 0xa0, 0x4b, 0x68, 0xe7, 0x24,
|
0, // 1: gnostic.extension.v1.ExtensionHandlerRequest.compiler_version:type_name -> gnostic.extension.v1.Version
|
||||||
0xca, 0x68, 0x99, 0xa4, 0xef, 0x99, 0xe1, 0xbd, 0x6a, 0x78, 0x6f, 0xcc, 0xf6, 0xd8, 0x58, 0xdc,
|
4, // 2: gnostic.extension.v1.ExtensionHandlerResponse.value:type_name -> google.protobuf.Any
|
||||||
0x67, 0xb0, 0xcb, 0x52, 0xc5, 0x33, 0x55, 0x05, 0x4b, 0x0f, 0x57, 0x49, 0x74, 0x0e, 0xbd, 0xba,
|
3, // [3:3] is the sub-list for method output_type
|
||||||
0xc5, 0x92, 0x91, 0x98, 0xea, 0xdf, 0xd0, 0xc5, 0xff, 0x6a, 0xfa, 0xa8, 0x20, 0x42, 0xd0, 0xda,
|
3, // [3:3] is the sub-list for method input_type
|
||||||
0x93, 0x38, 0xd2, 0xcf, 0x76, 0xb1, 0x3e, 0x4f, 0xae, 0xa0, 0xc7, 0x65, 0xe0, 0x05, 0x8c, 0x27,
|
3, // [3:3] is the sub-list for extension type_name
|
||||||
0x69, 0xe8, 0xab, 0x09, 0x26, 0x68, 0xa6, 0x76, 0x19, 0xcf, 0x1f, 0xea, 0xba, 0x8b, 0xd1, 0xdc,
|
3, // [3:3] is the sub-list for extension extendee
|
||||||
0xfa, 0x68, 0x34, 0x67, 0xe3, 0xe9, 0xaa, 0xa3, 0x23, 0xde, 0x7c, 0x06, 0x00, 0x00, 0xff, 0xff,
|
0, // [0:3] is the sub-list for field type_name
|
||||||
0xeb, 0xf3, 0xfa, 0x65, 0x5c, 0x02, 0x00, 0x00,
|
}
|
||||||
|
|
||||||
|
func init() { file_extensions_extension_proto_init() }
|
||||||
|
func file_extensions_extension_proto_init() {
|
||||||
|
if File_extensions_extension_proto != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if !protoimpl.UnsafeEnabled {
|
||||||
|
file_extensions_extension_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||||
|
switch v := v.(*Version); i {
|
||||||
|
case 0:
|
||||||
|
return &v.state
|
||||||
|
case 1:
|
||||||
|
return &v.sizeCache
|
||||||
|
case 2:
|
||||||
|
return &v.unknownFields
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
file_extensions_extension_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||||
|
switch v := v.(*ExtensionHandlerRequest); i {
|
||||||
|
case 0:
|
||||||
|
return &v.state
|
||||||
|
case 1:
|
||||||
|
return &v.sizeCache
|
||||||
|
case 2:
|
||||||
|
return &v.unknownFields
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
file_extensions_extension_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||||
|
switch v := v.(*ExtensionHandlerResponse); i {
|
||||||
|
case 0:
|
||||||
|
return &v.state
|
||||||
|
case 1:
|
||||||
|
return &v.sizeCache
|
||||||
|
case 2:
|
||||||
|
return &v.unknownFields
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
file_extensions_extension_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
||||||
|
switch v := v.(*Wrapper); i {
|
||||||
|
case 0:
|
||||||
|
return &v.state
|
||||||
|
case 1:
|
||||||
|
return &v.sizeCache
|
||||||
|
case 2:
|
||||||
|
return &v.unknownFields
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
type x struct{}
|
||||||
|
out := protoimpl.TypeBuilder{
|
||||||
|
File: protoimpl.DescBuilder{
|
||||||
|
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||||
|
RawDescriptor: file_extensions_extension_proto_rawDesc,
|
||||||
|
NumEnums: 0,
|
||||||
|
NumMessages: 4,
|
||||||
|
NumExtensions: 0,
|
||||||
|
NumServices: 0,
|
||||||
|
},
|
||||||
|
GoTypes: file_extensions_extension_proto_goTypes,
|
||||||
|
DependencyIndexes: file_extensions_extension_proto_depIdxs,
|
||||||
|
MessageInfos: file_extensions_extension_proto_msgTypes,
|
||||||
|
}.Build()
|
||||||
|
File_extensions_extension_proto = out.File
|
||||||
|
file_extensions_extension_proto_rawDesc = nil
|
||||||
|
file_extensions_extension_proto_goTypes = nil
|
||||||
|
file_extensions_extension_proto_depIdxs = nil
|
||||||
}
|
}
|
||||||
|
29
vendor/github.com/googleapis/gnostic/extensions/extension.proto
generated
vendored
29
vendor/github.com/googleapis/gnostic/extensions/extension.proto
generated
vendored
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2017 Google Inc. All Rights Reserved.
|
// Copyright 2017 Google LLC. All Rights Reserved.
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
@ -14,8 +14,9 @@
|
|||||||
|
|
||||||
syntax = "proto3";
|
syntax = "proto3";
|
||||||
|
|
||||||
|
package gnostic.extension.v1;
|
||||||
|
|
||||||
import "google/protobuf/any.proto";
|
import "google/protobuf/any.proto";
|
||||||
package openapiextension.v1;
|
|
||||||
|
|
||||||
// This option lets the proto compiler generate Java code inside the package
|
// This option lets the proto compiler generate Java code inside the package
|
||||||
// name (see below) instead of inside an outer class. It creates a simpler
|
// name (see below) instead of inside an outer class. It creates a simpler
|
||||||
@ -26,7 +27,7 @@ option java_multiple_files = true;
|
|||||||
// The Java outer classname should be the filename in UpperCamelCase. This
|
// The Java outer classname should be the filename in UpperCamelCase. This
|
||||||
// class is only used to hold proto descriptor, so developers don't need to
|
// class is only used to hold proto descriptor, so developers don't need to
|
||||||
// work with it directly.
|
// work with it directly.
|
||||||
option java_outer_classname = "OpenAPIExtensionV1";
|
option java_outer_classname = "GnosticExtension";
|
||||||
|
|
||||||
// The Java package name must be proto package name with proper prefix.
|
// The Java package name must be proto package name with proper prefix.
|
||||||
option java_package = "org.gnostic.v1";
|
option java_package = "org.gnostic.v1";
|
||||||
@ -37,9 +38,12 @@ option java_package = "org.gnostic.v1";
|
|||||||
// hopefully unique enough to not conflict with things that may come along in
|
// hopefully unique enough to not conflict with things that may come along in
|
||||||
// the future. 'GPB' is reserved for the protocol buffer implementation itself.
|
// the future. 'GPB' is reserved for the protocol buffer implementation itself.
|
||||||
//
|
//
|
||||||
option objc_class_prefix = "OAE"; // "OpenAPI Extension"
|
option objc_class_prefix = "GNX"; // "Gnostic Extension"
|
||||||
|
|
||||||
// The version number of OpenAPI compiler.
|
// The Go package name.
|
||||||
|
option go_package = "extensions;gnostic_extension_v1";
|
||||||
|
|
||||||
|
// The version number of Gnostic.
|
||||||
message Version {
|
message Version {
|
||||||
int32 major = 1;
|
int32 major = 1;
|
||||||
int32 minor = 2;
|
int32 minor = 2;
|
||||||
@ -52,12 +56,11 @@ message Version {
|
|||||||
// An encoded Request is written to the ExtensionHandler's stdin.
|
// An encoded Request is written to the ExtensionHandler's stdin.
|
||||||
message ExtensionHandlerRequest {
|
message ExtensionHandlerRequest {
|
||||||
|
|
||||||
// The OpenAPI descriptions that were explicitly listed on the command line.
|
// The extension to process.
|
||||||
// The specifications will appear in the order they are specified to gnostic.
|
|
||||||
Wrapper wrapper = 1;
|
Wrapper wrapper = 1;
|
||||||
|
|
||||||
// The version number of openapi compiler.
|
// The version number of Gnostic.
|
||||||
Version compiler_version = 3;
|
Version compiler_version = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The extensions writes an encoded ExtensionHandlerResponse to stdout.
|
// The extensions writes an encoded ExtensionHandlerResponse to stdout.
|
||||||
@ -66,7 +69,7 @@ message ExtensionHandlerResponse {
|
|||||||
// true if the extension is handled by the extension handler; false otherwise
|
// true if the extension is handled by the extension handler; false otherwise
|
||||||
bool handled = 1;
|
bool handled = 1;
|
||||||
|
|
||||||
// Error message. If non-empty, the extension handling failed.
|
// Error message(s). If non-empty, the extension handling failed.
|
||||||
// The extension handler process should exit with status code zero
|
// The extension handler process should exit with status code zero
|
||||||
// even if it reports an error in this way.
|
// even if it reports an error in this way.
|
||||||
//
|
//
|
||||||
@ -75,7 +78,7 @@ message ExtensionHandlerResponse {
|
|||||||
// itself -- such as the input Document being unparseable -- should be
|
// itself -- such as the input Document being unparseable -- should be
|
||||||
// reported by writing a message to stderr and exiting with a non-zero
|
// reported by writing a message to stderr and exiting with a non-zero
|
||||||
// status code.
|
// status code.
|
||||||
repeated string error = 2;
|
repeated string errors = 2;
|
||||||
|
|
||||||
// text output
|
// text output
|
||||||
google.protobuf.Any value = 3;
|
google.protobuf.Any value = 3;
|
||||||
@ -85,9 +88,9 @@ message Wrapper {
|
|||||||
// version of the OpenAPI specification in which this extension was written.
|
// version of the OpenAPI specification in which this extension was written.
|
||||||
string version = 1;
|
string version = 1;
|
||||||
|
|
||||||
// Name of the extension
|
// Name of the extension.
|
||||||
string extension_name = 2;
|
string extension_name = 2;
|
||||||
|
|
||||||
// Must be a valid yaml for the proto
|
// YAML-formatted extension value.
|
||||||
string yaml = 3;
|
string yaml = 3;
|
||||||
}
|
}
|
||||||
|
68
vendor/github.com/googleapis/gnostic/extensions/extensions.go
generated
vendored
68
vendor/github.com/googleapis/gnostic/extensions/extensions.go
generated
vendored
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2017 Google Inc. All Rights Reserved.
|
// Copyright 2017 Google LLC. All Rights Reserved.
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
@ -12,71 +12,53 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
package openapiextension_v1
|
package gnostic_extension_v1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
"github.com/golang/protobuf/ptypes"
|
"github.com/golang/protobuf/ptypes"
|
||||||
)
|
)
|
||||||
|
|
||||||
type documentHandler func(version string, extensionName string, document string)
|
|
||||||
type extensionHandler func(name string, yamlInput string) (bool, proto.Message, error)
|
type extensionHandler func(name string, yamlInput string) (bool, proto.Message, error)
|
||||||
|
|
||||||
func forInputYamlFromOpenapic(handler documentHandler) {
|
// Main implements the main program of an extension handler.
|
||||||
|
func Main(handler extensionHandler) {
|
||||||
|
// unpack the request
|
||||||
data, err := ioutil.ReadAll(os.Stdin)
|
data, err := ioutil.ReadAll(os.Stdin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("File error:", err.Error())
|
log.Println("File error:", err.Error())
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
if len(data) == 0 {
|
if len(data) == 0 {
|
||||||
fmt.Println("No input data.")
|
log.Println("No input data.")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
request := &ExtensionHandlerRequest{}
|
request := &ExtensionHandlerRequest{}
|
||||||
err = proto.Unmarshal(data, request)
|
err = proto.Unmarshal(data, request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Input error:", err.Error())
|
log.Println("Input error:", err.Error())
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
handler(request.Wrapper.Version, request.Wrapper.ExtensionName, request.Wrapper.Yaml)
|
// call the handler
|
||||||
}
|
handled, output, err := handler(request.Wrapper.ExtensionName, request.Wrapper.Yaml)
|
||||||
|
// respond with the output of the handler
|
||||||
// ProcessExtension calles the handler for a specified extension.
|
response := &ExtensionHandlerResponse{
|
||||||
func ProcessExtension(handleExtension extensionHandler) {
|
Handled: false, // default assumption
|
||||||
response := &ExtensionHandlerResponse{}
|
Errors: make([]string, 0),
|
||||||
forInputYamlFromOpenapic(
|
}
|
||||||
func(version string, extensionName string, yamlInput string) {
|
if err != nil {
|
||||||
var newObject proto.Message
|
response.Errors = append(response.Errors, err.Error())
|
||||||
var err error
|
} else if handled {
|
||||||
|
response.Handled = true
|
||||||
handled, newObject, err := handleExtension(extensionName, yamlInput)
|
response.Value, err = ptypes.MarshalAny(output)
|
||||||
if !handled {
|
if err != nil {
|
||||||
responseBytes, _ := proto.Marshal(response)
|
response.Errors = append(response.Errors, err.Error())
|
||||||
os.Stdout.Write(responseBytes)
|
}
|
||||||
os.Exit(0)
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// If we reach here, then the extension is handled
|
|
||||||
response.Handled = true
|
|
||||||
if err != nil {
|
|
||||||
response.Error = append(response.Error, err.Error())
|
|
||||||
responseBytes, _ := proto.Marshal(response)
|
|
||||||
os.Stdout.Write(responseBytes)
|
|
||||||
os.Exit(0)
|
|
||||||
}
|
|
||||||
response.Value, err = ptypes.MarshalAny(newObject)
|
|
||||||
if err != nil {
|
|
||||||
response.Error = append(response.Error, err.Error())
|
|
||||||
responseBytes, _ := proto.Marshal(response)
|
|
||||||
os.Stdout.Write(responseBytes)
|
|
||||||
os.Exit(0)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
responseBytes, _ := proto.Marshal(response)
|
responseBytes, _ := proto.Marshal(response)
|
||||||
os.Stdout.Write(responseBytes)
|
os.Stdout.Write(responseBytes)
|
||||||
}
|
}
|
||||||
|
4
vendor/github.com/googleapis/gnostic/jsonschema/README.md
generated
vendored
Normal file
4
vendor/github.com/googleapis/gnostic/jsonschema/README.md
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
# jsonschema
|
||||||
|
|
||||||
|
This directory contains code for reading, writing, and manipulating JSON
|
||||||
|
schemas.
|
84
vendor/github.com/googleapis/gnostic/jsonschema/base.go
generated
vendored
Normal file
84
vendor/github.com/googleapis/gnostic/jsonschema/base.go
generated
vendored
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
|
||||||
|
// THIS FILE IS AUTOMATICALLY GENERATED.
|
||||||
|
|
||||||
|
package jsonschema
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/base64"
|
||||||
|
)
|
||||||
|
|
||||||
|
func baseSchemaBytes() ([]byte, error){
|
||||||
|
return base64.StdEncoding.DecodeString(
|
||||||
|
`ewogICAgImlkIjogImh0dHA6Ly9qc29uLXNjaGVtYS5vcmcvZHJhZnQtMDQvc2NoZW1hIyIsCiAgICAi
|
||||||
|
JHNjaGVtYSI6ICJodHRwOi8vanNvbi1zY2hlbWEub3JnL2RyYWZ0LTA0L3NjaGVtYSMiLAogICAgImRl
|
||||||
|
c2NyaXB0aW9uIjogIkNvcmUgc2NoZW1hIG1ldGEtc2NoZW1hIiwKICAgICJkZWZpbml0aW9ucyI6IHsK
|
||||||
|
ICAgICAgICAic2NoZW1hQXJyYXkiOiB7CiAgICAgICAgICAgICJ0eXBlIjogImFycmF5IiwKICAgICAg
|
||||||
|
ICAgICAgIm1pbkl0ZW1zIjogMSwKICAgICAgICAgICAgIml0ZW1zIjogeyAiJHJlZiI6ICIjIiB9CiAg
|
||||||
|
ICAgICAgfSwKICAgICAgICAicG9zaXRpdmVJbnRlZ2VyIjogewogICAgICAgICAgICAidHlwZSI6ICJp
|
||||||
|
bnRlZ2VyIiwKICAgICAgICAgICAgIm1pbmltdW0iOiAwCiAgICAgICAgfSwKICAgICAgICAicG9zaXRp
|
||||||
|
dmVJbnRlZ2VyRGVmYXVsdDAiOiB7CiAgICAgICAgICAgICJhbGxPZiI6IFsgeyAiJHJlZiI6ICIjL2Rl
|
||||||
|
ZmluaXRpb25zL3Bvc2l0aXZlSW50ZWdlciIgfSwgeyAiZGVmYXVsdCI6IDAgfSBdCiAgICAgICAgfSwK
|
||||||
|
ICAgICAgICAic2ltcGxlVHlwZXMiOiB7CiAgICAgICAgICAgICJlbnVtIjogWyAiYXJyYXkiLCAiYm9v
|
||||||
|
bGVhbiIsICJpbnRlZ2VyIiwgIm51bGwiLCAibnVtYmVyIiwgIm9iamVjdCIsICJzdHJpbmciIF0KICAg
|
||||||
|
ICAgICB9LAogICAgICAgICJzdHJpbmdBcnJheSI6IHsKICAgICAgICAgICAgInR5cGUiOiAiYXJyYXki
|
||||||
|
LAogICAgICAgICAgICAiaXRlbXMiOiB7ICJ0eXBlIjogInN0cmluZyIgfSwKICAgICAgICAgICAgIm1p
|
||||||
|
bkl0ZW1zIjogMSwKICAgICAgICAgICAgInVuaXF1ZUl0ZW1zIjogdHJ1ZQogICAgICAgIH0KICAgIH0s
|
||||||
|
CiAgICAidHlwZSI6ICJvYmplY3QiLAogICAgInByb3BlcnRpZXMiOiB7CiAgICAgICAgImlkIjogewog
|
||||||
|
ICAgICAgICAgICAidHlwZSI6ICJzdHJpbmciLAogICAgICAgICAgICAiZm9ybWF0IjogInVyaSIKICAg
|
||||||
|
ICAgICB9LAogICAgICAgICIkc2NoZW1hIjogewogICAgICAgICAgICAidHlwZSI6ICJzdHJpbmciLAog
|
||||||
|
ICAgICAgICAgICAiZm9ybWF0IjogInVyaSIKICAgICAgICB9LAogICAgICAgICJ0aXRsZSI6IHsKICAg
|
||||||
|
ICAgICAgICAgInR5cGUiOiAic3RyaW5nIgogICAgICAgIH0sCiAgICAgICAgImRlc2NyaXB0aW9uIjog
|
||||||
|
ewogICAgICAgICAgICAidHlwZSI6ICJzdHJpbmciCiAgICAgICAgfSwKICAgICAgICAiZGVmYXVsdCI6
|
||||||
|
IHt9LAogICAgICAgICJtdWx0aXBsZU9mIjogewogICAgICAgICAgICAidHlwZSI6ICJudW1iZXIiLAog
|
||||||
|
ICAgICAgICAgICAibWluaW11bSI6IDAsCiAgICAgICAgICAgICJleGNsdXNpdmVNaW5pbXVtIjogdHJ1
|
||||||
|
ZQogICAgICAgIH0sCiAgICAgICAgIm1heGltdW0iOiB7CiAgICAgICAgICAgICJ0eXBlIjogIm51bWJl
|
||||||
|
ciIKICAgICAgICB9LAogICAgICAgICJleGNsdXNpdmVNYXhpbXVtIjogewogICAgICAgICAgICAidHlw
|
||||||
|
ZSI6ICJib29sZWFuIiwKICAgICAgICAgICAgImRlZmF1bHQiOiBmYWxzZQogICAgICAgIH0sCiAgICAg
|
||||||
|
ICAgIm1pbmltdW0iOiB7CiAgICAgICAgICAgICJ0eXBlIjogIm51bWJlciIKICAgICAgICB9LAogICAg
|
||||||
|
ICAgICJleGNsdXNpdmVNaW5pbXVtIjogewogICAgICAgICAgICAidHlwZSI6ICJib29sZWFuIiwKICAg
|
||||||
|
ICAgICAgICAgImRlZmF1bHQiOiBmYWxzZQogICAgICAgIH0sCiAgICAgICAgIm1heExlbmd0aCI6IHsg
|
||||||
|
IiRyZWYiOiAiIy9kZWZpbml0aW9ucy9wb3NpdGl2ZUludGVnZXIiIH0sCiAgICAgICAgIm1pbkxlbmd0
|
||||||
|
aCI6IHsgIiRyZWYiOiAiIy9kZWZpbml0aW9ucy9wb3NpdGl2ZUludGVnZXJEZWZhdWx0MCIgfSwKICAg
|
||||||
|
ICAgICAicGF0dGVybiI6IHsKICAgICAgICAgICAgInR5cGUiOiAic3RyaW5nIiwKICAgICAgICAgICAg
|
||||||
|
ImZvcm1hdCI6ICJyZWdleCIKICAgICAgICB9LAogICAgICAgICJhZGRpdGlvbmFsSXRlbXMiOiB7CiAg
|
||||||
|
ICAgICAgICAgICJhbnlPZiI6IFsKICAgICAgICAgICAgICAgIHsgInR5cGUiOiAiYm9vbGVhbiIgfSwK
|
||||||
|
ICAgICAgICAgICAgICAgIHsgIiRyZWYiOiAiIyIgfQogICAgICAgICAgICBdLAogICAgICAgICAgICAi
|
||||||
|
ZGVmYXVsdCI6IHt9CiAgICAgICAgfSwKICAgICAgICAiaXRlbXMiOiB7CiAgICAgICAgICAgICJhbnlP
|
||||||
|
ZiI6IFsKICAgICAgICAgICAgICAgIHsgIiRyZWYiOiAiIyIgfSwKICAgICAgICAgICAgICAgIHsgIiRy
|
||||||
|
ZWYiOiAiIy9kZWZpbml0aW9ucy9zY2hlbWFBcnJheSIgfQogICAgICAgICAgICBdLAogICAgICAgICAg
|
||||||
|
ICAiZGVmYXVsdCI6IHt9CiAgICAgICAgfSwKICAgICAgICAibWF4SXRlbXMiOiB7ICIkcmVmIjogIiMv
|
||||||
|
ZGVmaW5pdGlvbnMvcG9zaXRpdmVJbnRlZ2VyIiB9LAogICAgICAgICJtaW5JdGVtcyI6IHsgIiRyZWYi
|
||||||
|
OiAiIy9kZWZpbml0aW9ucy9wb3NpdGl2ZUludGVnZXJEZWZhdWx0MCIgfSwKICAgICAgICAidW5pcXVl
|
||||||
|
SXRlbXMiOiB7CiAgICAgICAgICAgICJ0eXBlIjogImJvb2xlYW4iLAogICAgICAgICAgICAiZGVmYXVs
|
||||||
|
dCI6IGZhbHNlCiAgICAgICAgfSwKICAgICAgICAibWF4UHJvcGVydGllcyI6IHsgIiRyZWYiOiAiIy9k
|
||||||
|
ZWZpbml0aW9ucy9wb3NpdGl2ZUludGVnZXIiIH0sCiAgICAgICAgIm1pblByb3BlcnRpZXMiOiB7ICIk
|
||||||
|
cmVmIjogIiMvZGVmaW5pdGlvbnMvcG9zaXRpdmVJbnRlZ2VyRGVmYXVsdDAiIH0sCiAgICAgICAgInJl
|
||||||
|
cXVpcmVkIjogeyAiJHJlZiI6ICIjL2RlZmluaXRpb25zL3N0cmluZ0FycmF5IiB9LAogICAgICAgICJh
|
||||||
|
ZGRpdGlvbmFsUHJvcGVydGllcyI6IHsKICAgICAgICAgICAgImFueU9mIjogWwogICAgICAgICAgICAg
|
||||||
|
ICAgeyAidHlwZSI6ICJib29sZWFuIiB9LAogICAgICAgICAgICAgICAgeyAiJHJlZiI6ICIjIiB9CiAg
|
||||||
|
ICAgICAgICAgIF0sCiAgICAgICAgICAgICJkZWZhdWx0Ijoge30KICAgICAgICB9LAogICAgICAgICJk
|
||||||
|
ZWZpbml0aW9ucyI6IHsKICAgICAgICAgICAgInR5cGUiOiAib2JqZWN0IiwKICAgICAgICAgICAgImFk
|
||||||
|
ZGl0aW9uYWxQcm9wZXJ0aWVzIjogeyAiJHJlZiI6ICIjIiB9LAogICAgICAgICAgICAiZGVmYXVsdCI6
|
||||||
|
IHt9CiAgICAgICAgfSwKICAgICAgICAicHJvcGVydGllcyI6IHsKICAgICAgICAgICAgInR5cGUiOiAi
|
||||||
|
b2JqZWN0IiwKICAgICAgICAgICAgImFkZGl0aW9uYWxQcm9wZXJ0aWVzIjogeyAiJHJlZiI6ICIjIiB9
|
||||||
|
LAogICAgICAgICAgICAiZGVmYXVsdCI6IHt9CiAgICAgICAgfSwKICAgICAgICAicGF0dGVyblByb3Bl
|
||||||
|
cnRpZXMiOiB7CiAgICAgICAgICAgICJ0eXBlIjogIm9iamVjdCIsCiAgICAgICAgICAgICJhZGRpdGlv
|
||||||
|
bmFsUHJvcGVydGllcyI6IHsgIiRyZWYiOiAiIyIgfSwKICAgICAgICAgICAgImRlZmF1bHQiOiB7fQog
|
||||||
|
ICAgICAgIH0sCiAgICAgICAgImRlcGVuZGVuY2llcyI6IHsKICAgICAgICAgICAgInR5cGUiOiAib2Jq
|
||||||
|
ZWN0IiwKICAgICAgICAgICAgImFkZGl0aW9uYWxQcm9wZXJ0aWVzIjogewogICAgICAgICAgICAgICAg
|
||||||
|
ImFueU9mIjogWwogICAgICAgICAgICAgICAgICAgIHsgIiRyZWYiOiAiIyIgfSwKICAgICAgICAgICAg
|
||||||
|
ICAgICAgICB7ICIkcmVmIjogIiMvZGVmaW5pdGlvbnMvc3RyaW5nQXJyYXkiIH0KICAgICAgICAgICAg
|
||||||
|
ICAgIF0KICAgICAgICAgICAgfQogICAgICAgIH0sCiAgICAgICAgImVudW0iOiB7CiAgICAgICAgICAg
|
||||||
|
ICJ0eXBlIjogImFycmF5IiwKICAgICAgICAgICAgIm1pbkl0ZW1zIjogMSwKICAgICAgICAgICAgInVu
|
||||||
|
aXF1ZUl0ZW1zIjogdHJ1ZQogICAgICAgIH0sCiAgICAgICAgInR5cGUiOiB7CiAgICAgICAgICAgICJh
|
||||||
|
bnlPZiI6IFsKICAgICAgICAgICAgICAgIHsgIiRyZWYiOiAiIy9kZWZpbml0aW9ucy9zaW1wbGVUeXBl
|
||||||
|
cyIgfSwKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAidHlwZSI6ICJhcnJheSIs
|
||||||
|
CiAgICAgICAgICAgICAgICAgICAgIml0ZW1zIjogeyAiJHJlZiI6ICIjL2RlZmluaXRpb25zL3NpbXBs
|
||||||
|
ZVR5cGVzIiB9LAogICAgICAgICAgICAgICAgICAgICJtaW5JdGVtcyI6IDEsCiAgICAgICAgICAgICAg
|
||||||
|
ICAgICAgInVuaXF1ZUl0ZW1zIjogdHJ1ZQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICBdCiAg
|
||||||
|
ICAgICAgfSwKICAgICAgICAiYWxsT2YiOiB7ICIkcmVmIjogIiMvZGVmaW5pdGlvbnMvc2NoZW1hQXJy
|
||||||
|
YXkiIH0sCiAgICAgICAgImFueU9mIjogeyAiJHJlZiI6ICIjL2RlZmluaXRpb25zL3NjaGVtYUFycmF5
|
||||||
|
IiB9LAogICAgICAgICJvbmVPZiI6IHsgIiRyZWYiOiAiIy9kZWZpbml0aW9ucy9zY2hlbWFBcnJheSIg
|
||||||
|
fSwKICAgICAgICAibm90IjogeyAiJHJlZiI6ICIjIiB9CiAgICB9LAogICAgImRlcGVuZGVuY2llcyI6
|
||||||
|
IHsKICAgICAgICAiZXhjbHVzaXZlTWF4aW11bSI6IFsgIm1heGltdW0iIF0sCiAgICAgICAgImV4Y2x1
|
||||||
|
c2l2ZU1pbmltdW0iOiBbICJtaW5pbXVtIiBdCiAgICB9LAogICAgImRlZmF1bHQiOiB7fQp9Cg==`)}
|
229
vendor/github.com/googleapis/gnostic/jsonschema/display.go
generated
vendored
Normal file
229
vendor/github.com/googleapis/gnostic/jsonschema/display.go
generated
vendored
Normal file
@ -0,0 +1,229 @@
|
|||||||
|
// Copyright 2017 Google LLC. All Rights Reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package jsonschema
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
//
|
||||||
|
// DISPLAY
|
||||||
|
// The following methods display Schemas.
|
||||||
|
//
|
||||||
|
|
||||||
|
// Description returns a string representation of a string or string array.
|
||||||
|
func (s *StringOrStringArray) Description() string {
|
||||||
|
if s.String != nil {
|
||||||
|
return *s.String
|
||||||
|
}
|
||||||
|
if s.StringArray != nil {
|
||||||
|
return strings.Join(*s.StringArray, ", ")
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns a string representation of a Schema.
|
||||||
|
func (schema *Schema) String() string {
|
||||||
|
return schema.describeSchema("")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper: Returns a string representation of a Schema indented by a specified string.
|
||||||
|
func (schema *Schema) describeSchema(indent string) string {
|
||||||
|
result := ""
|
||||||
|
if schema.Schema != nil {
|
||||||
|
result += indent + "$schema: " + *(schema.Schema) + "\n"
|
||||||
|
}
|
||||||
|
if schema.ID != nil {
|
||||||
|
result += indent + "id: " + *(schema.ID) + "\n"
|
||||||
|
}
|
||||||
|
if schema.MultipleOf != nil {
|
||||||
|
result += indent + fmt.Sprintf("multipleOf: %+v\n", *(schema.MultipleOf))
|
||||||
|
}
|
||||||
|
if schema.Maximum != nil {
|
||||||
|
result += indent + fmt.Sprintf("maximum: %+v\n", *(schema.Maximum))
|
||||||
|
}
|
||||||
|
if schema.ExclusiveMaximum != nil {
|
||||||
|
result += indent + fmt.Sprintf("exclusiveMaximum: %+v\n", *(schema.ExclusiveMaximum))
|
||||||
|
}
|
||||||
|
if schema.Minimum != nil {
|
||||||
|
result += indent + fmt.Sprintf("minimum: %+v\n", *(schema.Minimum))
|
||||||
|
}
|
||||||
|
if schema.ExclusiveMinimum != nil {
|
||||||
|
result += indent + fmt.Sprintf("exclusiveMinimum: %+v\n", *(schema.ExclusiveMinimum))
|
||||||
|
}
|
||||||
|
if schema.MaxLength != nil {
|
||||||
|
result += indent + fmt.Sprintf("maxLength: %+v\n", *(schema.MaxLength))
|
||||||
|
}
|
||||||
|
if schema.MinLength != nil {
|
||||||
|
result += indent + fmt.Sprintf("minLength: %+v\n", *(schema.MinLength))
|
||||||
|
}
|
||||||
|
if schema.Pattern != nil {
|
||||||
|
result += indent + fmt.Sprintf("pattern: %+v\n", *(schema.Pattern))
|
||||||
|
}
|
||||||
|
if schema.AdditionalItems != nil {
|
||||||
|
s := schema.AdditionalItems.Schema
|
||||||
|
if s != nil {
|
||||||
|
result += indent + "additionalItems:\n"
|
||||||
|
result += s.describeSchema(indent + " ")
|
||||||
|
} else {
|
||||||
|
b := *(schema.AdditionalItems.Boolean)
|
||||||
|
result += indent + fmt.Sprintf("additionalItems: %+v\n", b)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if schema.Items != nil {
|
||||||
|
result += indent + "items:\n"
|
||||||
|
items := schema.Items
|
||||||
|
if items.SchemaArray != nil {
|
||||||
|
for i, s := range *(items.SchemaArray) {
|
||||||
|
result += indent + " " + fmt.Sprintf("%d", i) + ":\n"
|
||||||
|
result += s.describeSchema(indent + " " + " ")
|
||||||
|
}
|
||||||
|
} else if items.Schema != nil {
|
||||||
|
result += items.Schema.describeSchema(indent + " " + " ")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if schema.MaxItems != nil {
|
||||||
|
result += indent + fmt.Sprintf("maxItems: %+v\n", *(schema.MaxItems))
|
||||||
|
}
|
||||||
|
if schema.MinItems != nil {
|
||||||
|
result += indent + fmt.Sprintf("minItems: %+v\n", *(schema.MinItems))
|
||||||
|
}
|
||||||
|
if schema.UniqueItems != nil {
|
||||||
|
result += indent + fmt.Sprintf("uniqueItems: %+v\n", *(schema.UniqueItems))
|
||||||
|
}
|
||||||
|
if schema.MaxProperties != nil {
|
||||||
|
result += indent + fmt.Sprintf("maxProperties: %+v\n", *(schema.MaxProperties))
|
||||||
|
}
|
||||||
|
if schema.MinProperties != nil {
|
||||||
|
result += indent + fmt.Sprintf("minProperties: %+v\n", *(schema.MinProperties))
|
||||||
|
}
|
||||||
|
if schema.Required != nil {
|
||||||
|
result += indent + fmt.Sprintf("required: %+v\n", *(schema.Required))
|
||||||
|
}
|
||||||
|
if schema.AdditionalProperties != nil {
|
||||||
|
s := schema.AdditionalProperties.Schema
|
||||||
|
if s != nil {
|
||||||
|
result += indent + "additionalProperties:\n"
|
||||||
|
result += s.describeSchema(indent + " ")
|
||||||
|
} else {
|
||||||
|
b := *(schema.AdditionalProperties.Boolean)
|
||||||
|
result += indent + fmt.Sprintf("additionalProperties: %+v\n", b)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if schema.Properties != nil {
|
||||||
|
result += indent + "properties:\n"
|
||||||
|
for _, pair := range *(schema.Properties) {
|
||||||
|
name := pair.Name
|
||||||
|
s := pair.Value
|
||||||
|
result += indent + " " + name + ":\n"
|
||||||
|
result += s.describeSchema(indent + " " + " ")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if schema.PatternProperties != nil {
|
||||||
|
result += indent + "patternProperties:\n"
|
||||||
|
for _, pair := range *(schema.PatternProperties) {
|
||||||
|
name := pair.Name
|
||||||
|
s := pair.Value
|
||||||
|
result += indent + " " + name + ":\n"
|
||||||
|
result += s.describeSchema(indent + " " + " ")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if schema.Dependencies != nil {
|
||||||
|
result += indent + "dependencies:\n"
|
||||||
|
for _, pair := range *(schema.Dependencies) {
|
||||||
|
name := pair.Name
|
||||||
|
schemaOrStringArray := pair.Value
|
||||||
|
s := schemaOrStringArray.Schema
|
||||||
|
if s != nil {
|
||||||
|
result += indent + " " + name + ":\n"
|
||||||
|
result += s.describeSchema(indent + " " + " ")
|
||||||
|
} else {
|
||||||
|
a := schemaOrStringArray.StringArray
|
||||||
|
if a != nil {
|
||||||
|
result += indent + " " + name + ":\n"
|
||||||
|
for _, s2 := range *a {
|
||||||
|
result += indent + " " + " " + s2 + "\n"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if schema.Enumeration != nil {
|
||||||
|
result += indent + "enumeration:\n"
|
||||||
|
for _, value := range *(schema.Enumeration) {
|
||||||
|
if value.String != nil {
|
||||||
|
result += indent + " " + fmt.Sprintf("%+v\n", *value.String)
|
||||||
|
} else {
|
||||||
|
result += indent + " " + fmt.Sprintf("%+v\n", *value.Bool)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if schema.Type != nil {
|
||||||
|
result += indent + fmt.Sprintf("type: %+v\n", schema.Type.Description())
|
||||||
|
}
|
||||||
|
if schema.AllOf != nil {
|
||||||
|
result += indent + "allOf:\n"
|
||||||
|
for _, s := range *(schema.AllOf) {
|
||||||
|
result += s.describeSchema(indent + " ")
|
||||||
|
result += indent + "-\n"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if schema.AnyOf != nil {
|
||||||
|
result += indent + "anyOf:\n"
|
||||||
|
for _, s := range *(schema.AnyOf) {
|
||||||
|
result += s.describeSchema(indent + " ")
|
||||||
|
result += indent + "-\n"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if schema.OneOf != nil {
|
||||||
|
result += indent + "oneOf:\n"
|
||||||
|
for _, s := range *(schema.OneOf) {
|
||||||
|
result += s.describeSchema(indent + " ")
|
||||||
|
result += indent + "-\n"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if schema.Not != nil {
|
||||||
|
result += indent + "not:\n"
|
||||||
|
result += schema.Not.describeSchema(indent + " ")
|
||||||
|
}
|
||||||
|
if schema.Definitions != nil {
|
||||||
|
result += indent + "definitions:\n"
|
||||||
|
for _, pair := range *(schema.Definitions) {
|
||||||
|
name := pair.Name
|
||||||
|
s := pair.Value
|
||||||
|
result += indent + " " + name + ":\n"
|
||||||
|
result += s.describeSchema(indent + " " + " ")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if schema.Title != nil {
|
||||||
|
result += indent + "title: " + *(schema.Title) + "\n"
|
||||||
|
}
|
||||||
|
if schema.Description != nil {
|
||||||
|
result += indent + "description: " + *(schema.Description) + "\n"
|
||||||
|
}
|
||||||
|
if schema.Default != nil {
|
||||||
|
result += indent + "default:\n"
|
||||||
|
result += indent + fmt.Sprintf(" %+v\n", *(schema.Default))
|
||||||
|
}
|
||||||
|
if schema.Format != nil {
|
||||||
|
result += indent + "format: " + *(schema.Format) + "\n"
|
||||||
|
}
|
||||||
|
if schema.Ref != nil {
|
||||||
|
result += indent + "$ref: " + *(schema.Ref) + "\n"
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
228
vendor/github.com/googleapis/gnostic/jsonschema/models.go
generated
vendored
Normal file
228
vendor/github.com/googleapis/gnostic/jsonschema/models.go
generated
vendored
Normal file
@ -0,0 +1,228 @@
|
|||||||
|
// Copyright 2017 Google LLC. All Rights Reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
// Package jsonschema supports the reading, writing, and manipulation
|
||||||
|
// of JSON Schemas.
|
||||||
|
package jsonschema
|
||||||
|
|
||||||
|
import "gopkg.in/yaml.v3"
|
||||||
|
|
||||||
|
// The Schema struct models a JSON Schema and, because schemas are
|
||||||
|
// defined hierarchically, contains many references to itself.
|
||||||
|
// All fields are pointers and are nil if the associated values
|
||||||
|
// are not specified.
|
||||||
|
type Schema struct {
|
||||||
|
Schema *string // $schema
|
||||||
|
ID *string // id keyword used for $ref resolution scope
|
||||||
|
Ref *string // $ref, i.e. JSON Pointers
|
||||||
|
|
||||||
|
// http://json-schema.org/latest/json-schema-validation.html
|
||||||
|
// 5.1. Validation keywords for numeric instances (number and integer)
|
||||||
|
MultipleOf *SchemaNumber
|
||||||
|
Maximum *SchemaNumber
|
||||||
|
ExclusiveMaximum *bool
|
||||||
|
Minimum *SchemaNumber
|
||||||
|
ExclusiveMinimum *bool
|
||||||
|
|
||||||
|
// 5.2. Validation keywords for strings
|
||||||
|
MaxLength *int64
|
||||||
|
MinLength *int64
|
||||||
|
Pattern *string
|
||||||
|
|
||||||
|
// 5.3. Validation keywords for arrays
|
||||||
|
AdditionalItems *SchemaOrBoolean
|
||||||
|
Items *SchemaOrSchemaArray
|
||||||
|
MaxItems *int64
|
||||||
|
MinItems *int64
|
||||||
|
UniqueItems *bool
|
||||||
|
|
||||||
|
// 5.4. Validation keywords for objects
|
||||||
|
MaxProperties *int64
|
||||||
|
MinProperties *int64
|
||||||
|
Required *[]string
|
||||||
|
AdditionalProperties *SchemaOrBoolean
|
||||||
|
Properties *[]*NamedSchema
|
||||||
|
PatternProperties *[]*NamedSchema
|
||||||
|
Dependencies *[]*NamedSchemaOrStringArray
|
||||||
|
|
||||||
|
// 5.5. Validation keywords for any instance type
|
||||||
|
Enumeration *[]SchemaEnumValue
|
||||||
|
Type *StringOrStringArray
|
||||||
|
AllOf *[]*Schema
|
||||||
|
AnyOf *[]*Schema
|
||||||
|
OneOf *[]*Schema
|
||||||
|
Not *Schema
|
||||||
|
Definitions *[]*NamedSchema
|
||||||
|
|
||||||
|
// 6. Metadata keywords
|
||||||
|
Title *string
|
||||||
|
Description *string
|
||||||
|
Default *yaml.Node
|
||||||
|
|
||||||
|
// 7. Semantic validation with "format"
|
||||||
|
Format *string
|
||||||
|
}
|
||||||
|
|
||||||
|
// These helper structs represent "combination" types that generally can
|
||||||
|
// have values of one type or another. All are used to represent parts
|
||||||
|
// of Schemas.
|
||||||
|
|
||||||
|
// SchemaNumber represents a value that can be either an Integer or a Float.
|
||||||
|
type SchemaNumber struct {
|
||||||
|
Integer *int64
|
||||||
|
Float *float64
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewSchemaNumberWithInteger creates and returns a new object
|
||||||
|
func NewSchemaNumberWithInteger(i int64) *SchemaNumber {
|
||||||
|
result := &SchemaNumber{}
|
||||||
|
result.Integer = &i
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewSchemaNumberWithFloat creates and returns a new object
|
||||||
|
func NewSchemaNumberWithFloat(f float64) *SchemaNumber {
|
||||||
|
result := &SchemaNumber{}
|
||||||
|
result.Float = &f
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
// SchemaOrBoolean represents a value that can be either a Schema or a Boolean.
|
||||||
|
type SchemaOrBoolean struct {
|
||||||
|
Schema *Schema
|
||||||
|
Boolean *bool
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewSchemaOrBooleanWithSchema creates and returns a new object
|
||||||
|
func NewSchemaOrBooleanWithSchema(s *Schema) *SchemaOrBoolean {
|
||||||
|
result := &SchemaOrBoolean{}
|
||||||
|
result.Schema = s
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewSchemaOrBooleanWithBoolean creates and returns a new object
|
||||||
|
func NewSchemaOrBooleanWithBoolean(b bool) *SchemaOrBoolean {
|
||||||
|
result := &SchemaOrBoolean{}
|
||||||
|
result.Boolean = &b
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
// StringOrStringArray represents a value that can be either
|
||||||
|
// a String or an Array of Strings.
|
||||||
|
type StringOrStringArray struct {
|
||||||
|
String *string
|
||||||
|
StringArray *[]string
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewStringOrStringArrayWithString creates and returns a new object
|
||||||
|
func NewStringOrStringArrayWithString(s string) *StringOrStringArray {
|
||||||
|
result := &StringOrStringArray{}
|
||||||
|
result.String = &s
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewStringOrStringArrayWithStringArray creates and returns a new object
|
||||||
|
func NewStringOrStringArrayWithStringArray(a []string) *StringOrStringArray {
|
||||||
|
result := &StringOrStringArray{}
|
||||||
|
result.StringArray = &a
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
// SchemaOrStringArray represents a value that can be either
|
||||||
|
// a Schema or an Array of Strings.
|
||||||
|
type SchemaOrStringArray struct {
|
||||||
|
Schema *Schema
|
||||||
|
StringArray *[]string
|
||||||
|
}
|
||||||
|
|
||||||
|
// SchemaOrSchemaArray represents a value that can be either
|
||||||
|
// a Schema or an Array of Schemas.
|
||||||
|
type SchemaOrSchemaArray struct {
|
||||||
|
Schema *Schema
|
||||||
|
SchemaArray *[]*Schema
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewSchemaOrSchemaArrayWithSchema creates and returns a new object
|
||||||
|
func NewSchemaOrSchemaArrayWithSchema(s *Schema) *SchemaOrSchemaArray {
|
||||||
|
result := &SchemaOrSchemaArray{}
|
||||||
|
result.Schema = s
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewSchemaOrSchemaArrayWithSchemaArray creates and returns a new object
|
||||||
|
func NewSchemaOrSchemaArrayWithSchemaArray(a []*Schema) *SchemaOrSchemaArray {
|
||||||
|
result := &SchemaOrSchemaArray{}
|
||||||
|
result.SchemaArray = &a
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
// SchemaEnumValue represents a value that can be part of an
|
||||||
|
// enumeration in a Schema.
|
||||||
|
type SchemaEnumValue struct {
|
||||||
|
String *string
|
||||||
|
Bool *bool
|
||||||
|
}
|
||||||
|
|
||||||
|
// NamedSchema is a name-value pair that is used to emulate maps
|
||||||
|
// with ordered keys.
|
||||||
|
type NamedSchema struct {
|
||||||
|
Name string
|
||||||
|
Value *Schema
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewNamedSchema creates and returns a new object
|
||||||
|
func NewNamedSchema(name string, value *Schema) *NamedSchema {
|
||||||
|
return &NamedSchema{Name: name, Value: value}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NamedSchemaOrStringArray is a name-value pair that is used
|
||||||
|
// to emulate maps with ordered keys.
|
||||||
|
type NamedSchemaOrStringArray struct {
|
||||||
|
Name string
|
||||||
|
Value *SchemaOrStringArray
|
||||||
|
}
|
||||||
|
|
||||||
|
// Access named subschemas by name
|
||||||
|
|
||||||
|
func namedSchemaArrayElementWithName(array *[]*NamedSchema, name string) *Schema {
|
||||||
|
if array == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
for _, pair := range *array {
|
||||||
|
if pair.Name == name {
|
||||||
|
return pair.Value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// PropertyWithName returns the selected element.
|
||||||
|
func (s *Schema) PropertyWithName(name string) *Schema {
|
||||||
|
return namedSchemaArrayElementWithName(s.Properties, name)
|
||||||
|
}
|
||||||
|
|
||||||
|
// PatternPropertyWithName returns the selected element.
|
||||||
|
func (s *Schema) PatternPropertyWithName(name string) *Schema {
|
||||||
|
return namedSchemaArrayElementWithName(s.PatternProperties, name)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DefinitionWithName returns the selected element.
|
||||||
|
func (s *Schema) DefinitionWithName(name string) *Schema {
|
||||||
|
return namedSchemaArrayElementWithName(s.Definitions, name)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddProperty adds a named property.
|
||||||
|
func (s *Schema) AddProperty(name string, property *Schema) {
|
||||||
|
*s.Properties = append(*s.Properties, NewNamedSchema(name, property))
|
||||||
|
}
|
394
vendor/github.com/googleapis/gnostic/jsonschema/operations.go
generated
vendored
Normal file
394
vendor/github.com/googleapis/gnostic/jsonschema/operations.go
generated
vendored
Normal file
@ -0,0 +1,394 @@
|
|||||||
|
// Copyright 2017 Google LLC. All Rights Reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package jsonschema
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"log"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
//
|
||||||
|
// OPERATIONS
|
||||||
|
// The following methods perform operations on Schemas.
|
||||||
|
//
|
||||||
|
|
||||||
|
// IsEmpty returns true if no members of the Schema are specified.
|
||||||
|
func (schema *Schema) IsEmpty() bool {
|
||||||
|
return (schema.Schema == nil) &&
|
||||||
|
(schema.ID == nil) &&
|
||||||
|
(schema.MultipleOf == nil) &&
|
||||||
|
(schema.Maximum == nil) &&
|
||||||
|
(schema.ExclusiveMaximum == nil) &&
|
||||||
|
(schema.Minimum == nil) &&
|
||||||
|
(schema.ExclusiveMinimum == nil) &&
|
||||||
|
(schema.MaxLength == nil) &&
|
||||||
|
(schema.MinLength == nil) &&
|
||||||
|
(schema.Pattern == nil) &&
|
||||||
|
(schema.AdditionalItems == nil) &&
|
||||||
|
(schema.Items == nil) &&
|
||||||
|
(schema.MaxItems == nil) &&
|
||||||
|
(schema.MinItems == nil) &&
|
||||||
|
(schema.UniqueItems == nil) &&
|
||||||
|
(schema.MaxProperties == nil) &&
|
||||||
|
(schema.MinProperties == nil) &&
|
||||||
|
(schema.Required == nil) &&
|
||||||
|
(schema.AdditionalProperties == nil) &&
|
||||||
|
(schema.Properties == nil) &&
|
||||||
|
(schema.PatternProperties == nil) &&
|
||||||
|
(schema.Dependencies == nil) &&
|
||||||
|
(schema.Enumeration == nil) &&
|
||||||
|
(schema.Type == nil) &&
|
||||||
|
(schema.AllOf == nil) &&
|
||||||
|
(schema.AnyOf == nil) &&
|
||||||
|
(schema.OneOf == nil) &&
|
||||||
|
(schema.Not == nil) &&
|
||||||
|
(schema.Definitions == nil) &&
|
||||||
|
(schema.Title == nil) &&
|
||||||
|
(schema.Description == nil) &&
|
||||||
|
(schema.Default == nil) &&
|
||||||
|
(schema.Format == nil) &&
|
||||||
|
(schema.Ref == nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsEqual returns true if two schemas are equal.
|
||||||
|
func (schema *Schema) IsEqual(schema2 *Schema) bool {
|
||||||
|
return schema.String() == schema2.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
// SchemaOperation represents a function that can be applied to a Schema.
|
||||||
|
type SchemaOperation func(schema *Schema, context string)
|
||||||
|
|
||||||
|
// Applies a specified function to a Schema and all of the Schemas that it contains.
|
||||||
|
func (schema *Schema) applyToSchemas(operation SchemaOperation, context string) {
|
||||||
|
|
||||||
|
if schema.AdditionalItems != nil {
|
||||||
|
s := schema.AdditionalItems.Schema
|
||||||
|
if s != nil {
|
||||||
|
s.applyToSchemas(operation, "AdditionalItems")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if schema.Items != nil {
|
||||||
|
if schema.Items.SchemaArray != nil {
|
||||||
|
for _, s := range *(schema.Items.SchemaArray) {
|
||||||
|
s.applyToSchemas(operation, "Items.SchemaArray")
|
||||||
|
}
|
||||||
|
} else if schema.Items.Schema != nil {
|
||||||
|
schema.Items.Schema.applyToSchemas(operation, "Items.Schema")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if schema.AdditionalProperties != nil {
|
||||||
|
s := schema.AdditionalProperties.Schema
|
||||||
|
if s != nil {
|
||||||
|
s.applyToSchemas(operation, "AdditionalProperties")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if schema.Properties != nil {
|
||||||
|
for _, pair := range *(schema.Properties) {
|
||||||
|
s := pair.Value
|
||||||
|
s.applyToSchemas(operation, "Properties")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if schema.PatternProperties != nil {
|
||||||
|
for _, pair := range *(schema.PatternProperties) {
|
||||||
|
s := pair.Value
|
||||||
|
s.applyToSchemas(operation, "PatternProperties")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if schema.Dependencies != nil {
|
||||||
|
for _, pair := range *(schema.Dependencies) {
|
||||||
|
schemaOrStringArray := pair.Value
|
||||||
|
s := schemaOrStringArray.Schema
|
||||||
|
if s != nil {
|
||||||
|
s.applyToSchemas(operation, "Dependencies")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if schema.AllOf != nil {
|
||||||
|
for _, s := range *(schema.AllOf) {
|
||||||
|
s.applyToSchemas(operation, "AllOf")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if schema.AnyOf != nil {
|
||||||
|
for _, s := range *(schema.AnyOf) {
|
||||||
|
s.applyToSchemas(operation, "AnyOf")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if schema.OneOf != nil {
|
||||||
|
for _, s := range *(schema.OneOf) {
|
||||||
|
s.applyToSchemas(operation, "OneOf")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if schema.Not != nil {
|
||||||
|
schema.Not.applyToSchemas(operation, "Not")
|
||||||
|
}
|
||||||
|
|
||||||
|
if schema.Definitions != nil {
|
||||||
|
for _, pair := range *(schema.Definitions) {
|
||||||
|
s := pair.Value
|
||||||
|
s.applyToSchemas(operation, "Definitions")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
operation(schema, context)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CopyProperties copies all non-nil properties from the source Schema to the schema Schema.
|
||||||
|
func (schema *Schema) CopyProperties(source *Schema) {
|
||||||
|
if source.Schema != nil {
|
||||||
|
schema.Schema = source.Schema
|
||||||
|
}
|
||||||
|
if source.ID != nil {
|
||||||
|
schema.ID = source.ID
|
||||||
|
}
|
||||||
|
if source.MultipleOf != nil {
|
||||||
|
schema.MultipleOf = source.MultipleOf
|
||||||
|
}
|
||||||
|
if source.Maximum != nil {
|
||||||
|
schema.Maximum = source.Maximum
|
||||||
|
}
|
||||||
|
if source.ExclusiveMaximum != nil {
|
||||||
|
schema.ExclusiveMaximum = source.ExclusiveMaximum
|
||||||
|
}
|
||||||
|
if source.Minimum != nil {
|
||||||
|
schema.Minimum = source.Minimum
|
||||||
|
}
|
||||||
|
if source.ExclusiveMinimum != nil {
|
||||||
|
schema.ExclusiveMinimum = source.ExclusiveMinimum
|
||||||
|
}
|
||||||
|
if source.MaxLength != nil {
|
||||||
|
schema.MaxLength = source.MaxLength
|
||||||
|
}
|
||||||
|
if source.MinLength != nil {
|
||||||
|
schema.MinLength = source.MinLength
|
||||||
|
}
|
||||||
|
if source.Pattern != nil {
|
||||||
|
schema.Pattern = source.Pattern
|
||||||
|
}
|
||||||
|
if source.AdditionalItems != nil {
|
||||||
|
schema.AdditionalItems = source.AdditionalItems
|
||||||
|
}
|
||||||
|
if source.Items != nil {
|
||||||
|
schema.Items = source.Items
|
||||||
|
}
|
||||||
|
if source.MaxItems != nil {
|
||||||
|
schema.MaxItems = source.MaxItems
|
||||||
|
}
|
||||||
|
if source.MinItems != nil {
|
||||||
|
schema.MinItems = source.MinItems
|
||||||
|
}
|
||||||
|
if source.UniqueItems != nil {
|
||||||
|
schema.UniqueItems = source.UniqueItems
|
||||||
|
}
|
||||||
|
if source.MaxProperties != nil {
|
||||||
|
schema.MaxProperties = source.MaxProperties
|
||||||
|
}
|
||||||
|
if source.MinProperties != nil {
|
||||||
|
schema.MinProperties = source.MinProperties
|
||||||
|
}
|
||||||
|
if source.Required != nil {
|
||||||
|
schema.Required = source.Required
|
||||||
|
}
|
||||||
|
if source.AdditionalProperties != nil {
|
||||||
|
schema.AdditionalProperties = source.AdditionalProperties
|
||||||
|
}
|
||||||
|
if source.Properties != nil {
|
||||||
|
schema.Properties = source.Properties
|
||||||
|
}
|
||||||
|
if source.PatternProperties != nil {
|
||||||
|
schema.PatternProperties = source.PatternProperties
|
||||||
|
}
|
||||||
|
if source.Dependencies != nil {
|
||||||
|
schema.Dependencies = source.Dependencies
|
||||||
|
}
|
||||||
|
if source.Enumeration != nil {
|
||||||
|
schema.Enumeration = source.Enumeration
|
||||||
|
}
|
||||||
|
if source.Type != nil {
|
||||||
|
schema.Type = source.Type
|
||||||
|
}
|
||||||
|
if source.AllOf != nil {
|
||||||
|
schema.AllOf = source.AllOf
|
||||||
|
}
|
||||||
|
if source.AnyOf != nil {
|
||||||
|
schema.AnyOf = source.AnyOf
|
||||||
|
}
|
||||||
|
if source.OneOf != nil {
|
||||||
|
schema.OneOf = source.OneOf
|
||||||
|
}
|
||||||
|
if source.Not != nil {
|
||||||
|
schema.Not = source.Not
|
||||||
|
}
|
||||||
|
if source.Definitions != nil {
|
||||||
|
schema.Definitions = source.Definitions
|
||||||
|
}
|
||||||
|
if source.Title != nil {
|
||||||
|
schema.Title = source.Title
|
||||||
|
}
|
||||||
|
if source.Description != nil {
|
||||||
|
schema.Description = source.Description
|
||||||
|
}
|
||||||
|
if source.Default != nil {
|
||||||
|
schema.Default = source.Default
|
||||||
|
}
|
||||||
|
if source.Format != nil {
|
||||||
|
schema.Format = source.Format
|
||||||
|
}
|
||||||
|
if source.Ref != nil {
|
||||||
|
schema.Ref = source.Ref
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TypeIs returns true if the Type of a Schema includes the specified type
|
||||||
|
func (schema *Schema) TypeIs(typeName string) bool {
|
||||||
|
if schema.Type != nil {
|
||||||
|
// the schema Type is either a string or an array of strings
|
||||||
|
if schema.Type.String != nil {
|
||||||
|
return (*(schema.Type.String) == typeName)
|
||||||
|
} else if schema.Type.StringArray != nil {
|
||||||
|
for _, n := range *(schema.Type.StringArray) {
|
||||||
|
if n == typeName {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// ResolveRefs resolves "$ref" elements in a Schema and its children.
|
||||||
|
// But if a reference refers to an object type, is inside a oneOf, or contains a oneOf,
|
||||||
|
// the reference is kept and we expect downstream tools to separately model these
|
||||||
|
// referenced schemas.
|
||||||
|
func (schema *Schema) ResolveRefs() {
|
||||||
|
rootSchema := schema
|
||||||
|
count := 1
|
||||||
|
for count > 0 {
|
||||||
|
count = 0
|
||||||
|
schema.applyToSchemas(
|
||||||
|
func(schema *Schema, context string) {
|
||||||
|
if schema.Ref != nil {
|
||||||
|
resolvedRef, err := rootSchema.resolveJSONPointer(*(schema.Ref))
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("%+v", err)
|
||||||
|
} else if resolvedRef.TypeIs("object") {
|
||||||
|
// don't substitute for objects, we'll model the referenced schema with a class
|
||||||
|
} else if context == "OneOf" {
|
||||||
|
// don't substitute for references inside oneOf declarations
|
||||||
|
} else if resolvedRef.OneOf != nil {
|
||||||
|
// don't substitute for references that contain oneOf declarations
|
||||||
|
} else if resolvedRef.AdditionalProperties != nil {
|
||||||
|
// don't substitute for references that look like objects
|
||||||
|
} else {
|
||||||
|
schema.Ref = nil
|
||||||
|
schema.CopyProperties(resolvedRef)
|
||||||
|
count++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, "")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// resolveJSONPointer resolves JSON pointers.
|
||||||
|
// This current implementation is very crude and custom for OpenAPI 2.0 schemas.
|
||||||
|
// It panics for any pointer that it is unable to resolve.
|
||||||
|
func (schema *Schema) resolveJSONPointer(ref string) (result *Schema, err error) {
|
||||||
|
parts := strings.Split(ref, "#")
|
||||||
|
if len(parts) == 2 {
|
||||||
|
documentName := parts[0] + "#"
|
||||||
|
if documentName == "#" && schema.ID != nil {
|
||||||
|
documentName = *(schema.ID)
|
||||||
|
}
|
||||||
|
path := parts[1]
|
||||||
|
document := schemas[documentName]
|
||||||
|
pathParts := strings.Split(path, "/")
|
||||||
|
|
||||||
|
// we currently do a very limited (hard-coded) resolution of certain paths and log errors for missed cases
|
||||||
|
if len(pathParts) == 1 {
|
||||||
|
return document, nil
|
||||||
|
} else if len(pathParts) == 3 {
|
||||||
|
switch pathParts[1] {
|
||||||
|
case "definitions":
|
||||||
|
dictionary := document.Definitions
|
||||||
|
for _, pair := range *dictionary {
|
||||||
|
if pair.Name == pathParts[2] {
|
||||||
|
result = pair.Value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case "properties":
|
||||||
|
dictionary := document.Properties
|
||||||
|
for _, pair := range *dictionary {
|
||||||
|
if pair.Name == pathParts[2] {
|
||||||
|
result = pair.Value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if result == nil {
|
||||||
|
return nil, fmt.Errorf("unresolved pointer: %+v", ref)
|
||||||
|
}
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ResolveAllOfs replaces "allOf" elements by merging their properties into the parent Schema.
|
||||||
|
func (schema *Schema) ResolveAllOfs() {
|
||||||
|
schema.applyToSchemas(
|
||||||
|
func(schema *Schema, context string) {
|
||||||
|
if schema.AllOf != nil {
|
||||||
|
for _, allOf := range *(schema.AllOf) {
|
||||||
|
schema.CopyProperties(allOf)
|
||||||
|
}
|
||||||
|
schema.AllOf = nil
|
||||||
|
}
|
||||||
|
}, "resolveAllOfs")
|
||||||
|
}
|
||||||
|
|
||||||
|
// ResolveAnyOfs replaces all "anyOf" elements with "oneOf".
|
||||||
|
func (schema *Schema) ResolveAnyOfs() {
|
||||||
|
schema.applyToSchemas(
|
||||||
|
func(schema *Schema, context string) {
|
||||||
|
if schema.AnyOf != nil {
|
||||||
|
schema.OneOf = schema.AnyOf
|
||||||
|
schema.AnyOf = nil
|
||||||
|
}
|
||||||
|
}, "resolveAnyOfs")
|
||||||
|
}
|
||||||
|
|
||||||
|
// return a pointer to a copy of a passed-in string
|
||||||
|
func stringptr(input string) (output *string) {
|
||||||
|
return &input
|
||||||
|
}
|
||||||
|
|
||||||
|
// CopyOfficialSchemaProperty copies a named property from the official JSON Schema definition
|
||||||
|
func (schema *Schema) CopyOfficialSchemaProperty(name string) {
|
||||||
|
*schema.Properties = append(*schema.Properties,
|
||||||
|
NewNamedSchema(name,
|
||||||
|
&Schema{Ref: stringptr("http://json-schema.org/draft-04/schema#/properties/" + name)}))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CopyOfficialSchemaProperties copies named properties from the official JSON Schema definition
|
||||||
|
func (schema *Schema) CopyOfficialSchemaProperties(names []string) {
|
||||||
|
for _, name := range names {
|
||||||
|
schema.CopyOfficialSchemaProperty(name)
|
||||||
|
}
|
||||||
|
}
|
442
vendor/github.com/googleapis/gnostic/jsonschema/reader.go
generated
vendored
Normal file
442
vendor/github.com/googleapis/gnostic/jsonschema/reader.go
generated
vendored
Normal file
@ -0,0 +1,442 @@
|
|||||||
|
// Copyright 2017 Google LLC. All Rights Reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
//go:generate go run generate-base.go
|
||||||
|
|
||||||
|
package jsonschema
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"gopkg.in/yaml.v3"
|
||||||
|
)
|
||||||
|
|
||||||
|
// This is a global map of all known Schemas.
|
||||||
|
// It is initialized when the first Schema is created and inserted.
|
||||||
|
var schemas map[string]*Schema
|
||||||
|
|
||||||
|
// NewBaseSchema builds a schema object from an embedded json representation.
|
||||||
|
func NewBaseSchema() (schema *Schema, err error) {
|
||||||
|
b, err := baseSchemaBytes()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
var node yaml.Node
|
||||||
|
err = yaml.Unmarshal(b, &node)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return NewSchemaFromObject(&node), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewSchemaFromFile reads a schema from a file.
|
||||||
|
// Currently this assumes that schemas are stored in the source distribution of this project.
|
||||||
|
func NewSchemaFromFile(filename string) (schema *Schema, err error) {
|
||||||
|
file, err := ioutil.ReadFile(filename)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
var node yaml.Node
|
||||||
|
err = yaml.Unmarshal(file, &node)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return NewSchemaFromObject(&node), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewSchemaFromObject constructs a schema from a parsed JSON object.
|
||||||
|
// Due to the complexity of the schema representation, this is a
|
||||||
|
// custom reader and not the standard Go JSON reader (encoding/json).
|
||||||
|
func NewSchemaFromObject(jsonData *yaml.Node) *Schema {
|
||||||
|
switch jsonData.Kind {
|
||||||
|
case yaml.DocumentNode:
|
||||||
|
return NewSchemaFromObject(jsonData.Content[0])
|
||||||
|
case yaml.MappingNode:
|
||||||
|
schema := &Schema{}
|
||||||
|
|
||||||
|
for i := 0; i < len(jsonData.Content); i += 2 {
|
||||||
|
k := jsonData.Content[i].Value
|
||||||
|
v := jsonData.Content[i+1]
|
||||||
|
|
||||||
|
switch k {
|
||||||
|
case "$schema":
|
||||||
|
schema.Schema = schema.stringValue(v)
|
||||||
|
case "id":
|
||||||
|
schema.ID = schema.stringValue(v)
|
||||||
|
|
||||||
|
case "multipleOf":
|
||||||
|
schema.MultipleOf = schema.numberValue(v)
|
||||||
|
case "maximum":
|
||||||
|
schema.Maximum = schema.numberValue(v)
|
||||||
|
case "exclusiveMaximum":
|
||||||
|
schema.ExclusiveMaximum = schema.boolValue(v)
|
||||||
|
case "minimum":
|
||||||
|
schema.Minimum = schema.numberValue(v)
|
||||||
|
case "exclusiveMinimum":
|
||||||
|
schema.ExclusiveMinimum = schema.boolValue(v)
|
||||||
|
|
||||||
|
case "maxLength":
|
||||||
|
schema.MaxLength = schema.intValue(v)
|
||||||
|
case "minLength":
|
||||||
|
schema.MinLength = schema.intValue(v)
|
||||||
|
case "pattern":
|
||||||
|
schema.Pattern = schema.stringValue(v)
|
||||||
|
|
||||||
|
case "additionalItems":
|
||||||
|
schema.AdditionalItems = schema.schemaOrBooleanValue(v)
|
||||||
|
case "items":
|
||||||
|
schema.Items = schema.schemaOrSchemaArrayValue(v)
|
||||||
|
case "maxItems":
|
||||||
|
schema.MaxItems = schema.intValue(v)
|
||||||
|
case "minItems":
|
||||||
|
schema.MinItems = schema.intValue(v)
|
||||||
|
case "uniqueItems":
|
||||||
|
schema.UniqueItems = schema.boolValue(v)
|
||||||
|
|
||||||
|
case "maxProperties":
|
||||||
|
schema.MaxProperties = schema.intValue(v)
|
||||||
|
case "minProperties":
|
||||||
|
schema.MinProperties = schema.intValue(v)
|
||||||
|
case "required":
|
||||||
|
schema.Required = schema.arrayOfStringsValue(v)
|
||||||
|
case "additionalProperties":
|
||||||
|
schema.AdditionalProperties = schema.schemaOrBooleanValue(v)
|
||||||
|
case "properties":
|
||||||
|
schema.Properties = schema.mapOfSchemasValue(v)
|
||||||
|
case "patternProperties":
|
||||||
|
schema.PatternProperties = schema.mapOfSchemasValue(v)
|
||||||
|
case "dependencies":
|
||||||
|
schema.Dependencies = schema.mapOfSchemasOrStringArraysValue(v)
|
||||||
|
|
||||||
|
case "enum":
|
||||||
|
schema.Enumeration = schema.arrayOfEnumValuesValue(v)
|
||||||
|
|
||||||
|
case "type":
|
||||||
|
schema.Type = schema.stringOrStringArrayValue(v)
|
||||||
|
case "allOf":
|
||||||
|
schema.AllOf = schema.arrayOfSchemasValue(v)
|
||||||
|
case "anyOf":
|
||||||
|
schema.AnyOf = schema.arrayOfSchemasValue(v)
|
||||||
|
case "oneOf":
|
||||||
|
schema.OneOf = schema.arrayOfSchemasValue(v)
|
||||||
|
case "not":
|
||||||
|
schema.Not = NewSchemaFromObject(v)
|
||||||
|
case "definitions":
|
||||||
|
schema.Definitions = schema.mapOfSchemasValue(v)
|
||||||
|
|
||||||
|
case "title":
|
||||||
|
schema.Title = schema.stringValue(v)
|
||||||
|
case "description":
|
||||||
|
schema.Description = schema.stringValue(v)
|
||||||
|
|
||||||
|
case "default":
|
||||||
|
schema.Default = v
|
||||||
|
|
||||||
|
case "format":
|
||||||
|
schema.Format = schema.stringValue(v)
|
||||||
|
case "$ref":
|
||||||
|
schema.Ref = schema.stringValue(v)
|
||||||
|
default:
|
||||||
|
fmt.Printf("UNSUPPORTED (%s)\n", k)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// insert schema in global map
|
||||||
|
if schema.ID != nil {
|
||||||
|
if schemas == nil {
|
||||||
|
schemas = make(map[string]*Schema, 0)
|
||||||
|
}
|
||||||
|
schemas[*(schema.ID)] = schema
|
||||||
|
}
|
||||||
|
return schema
|
||||||
|
|
||||||
|
default:
|
||||||
|
fmt.Printf("schemaValue: unexpected node %+v\n", jsonData)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// BUILDERS
|
||||||
|
// The following methods build elements of Schemas from interface{} values.
|
||||||
|
// Each returns nil if it is unable to build the desired element.
|
||||||
|
//
|
||||||
|
|
||||||
|
// Gets the string value of an interface{} value if possible.
|
||||||
|
func (schema *Schema) stringValue(v *yaml.Node) *string {
|
||||||
|
switch v.Kind {
|
||||||
|
case yaml.ScalarNode:
|
||||||
|
return &v.Value
|
||||||
|
default:
|
||||||
|
fmt.Printf("stringValue: unexpected node %+v\n", v)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Gets the numeric value of an interface{} value if possible.
|
||||||
|
func (schema *Schema) numberValue(v *yaml.Node) *SchemaNumber {
|
||||||
|
number := &SchemaNumber{}
|
||||||
|
switch v.Kind {
|
||||||
|
case yaml.ScalarNode:
|
||||||
|
switch v.Tag {
|
||||||
|
case "!!float":
|
||||||
|
v2, _ := strconv.ParseFloat(v.Value, 64)
|
||||||
|
number.Float = &v2
|
||||||
|
return number
|
||||||
|
case "!!int":
|
||||||
|
v2, _ := strconv.ParseInt(v.Value, 10, 64)
|
||||||
|
number.Integer = &v2
|
||||||
|
return number
|
||||||
|
default:
|
||||||
|
fmt.Printf("stringValue: unexpected node %+v\n", v)
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
fmt.Printf("stringValue: unexpected node %+v\n", v)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Gets the integer value of an interface{} value if possible.
|
||||||
|
func (schema *Schema) intValue(v *yaml.Node) *int64 {
|
||||||
|
switch v.Kind {
|
||||||
|
case yaml.ScalarNode:
|
||||||
|
switch v.Tag {
|
||||||
|
case "!!float":
|
||||||
|
v2, _ := strconv.ParseFloat(v.Value, 64)
|
||||||
|
v3 := int64(v2)
|
||||||
|
return &v3
|
||||||
|
case "!!int":
|
||||||
|
v2, _ := strconv.ParseInt(v.Value, 10, 64)
|
||||||
|
return &v2
|
||||||
|
default:
|
||||||
|
fmt.Printf("intValue: unexpected node %+v\n", v)
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
fmt.Printf("intValue: unexpected node %+v\n", v)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Gets the bool value of an interface{} value if possible.
|
||||||
|
func (schema *Schema) boolValue(v *yaml.Node) *bool {
|
||||||
|
switch v.Kind {
|
||||||
|
case yaml.ScalarNode:
|
||||||
|
switch v.Tag {
|
||||||
|
case "!!bool":
|
||||||
|
v2, _ := strconv.ParseBool(v.Value)
|
||||||
|
return &v2
|
||||||
|
default:
|
||||||
|
fmt.Printf("boolValue: unexpected node %+v\n", v)
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
fmt.Printf("boolValue: unexpected node %+v\n", v)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Gets a map of Schemas from an interface{} value if possible.
|
||||||
|
func (schema *Schema) mapOfSchemasValue(v *yaml.Node) *[]*NamedSchema {
|
||||||
|
switch v.Kind {
|
||||||
|
case yaml.MappingNode:
|
||||||
|
m := make([]*NamedSchema, 0)
|
||||||
|
for i := 0; i < len(v.Content); i += 2 {
|
||||||
|
k2 := v.Content[i].Value
|
||||||
|
v2 := v.Content[i+1]
|
||||||
|
pair := &NamedSchema{Name: k2, Value: NewSchemaFromObject(v2)}
|
||||||
|
m = append(m, pair)
|
||||||
|
}
|
||||||
|
return &m
|
||||||
|
default:
|
||||||
|
fmt.Printf("mapOfSchemasValue: unexpected node %+v\n", v)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Gets an array of Schemas from an interface{} value if possible.
|
||||||
|
func (schema *Schema) arrayOfSchemasValue(v *yaml.Node) *[]*Schema {
|
||||||
|
switch v.Kind {
|
||||||
|
case yaml.SequenceNode:
|
||||||
|
m := make([]*Schema, 0)
|
||||||
|
for _, v2 := range v.Content {
|
||||||
|
switch v2.Kind {
|
||||||
|
case yaml.MappingNode:
|
||||||
|
s := NewSchemaFromObject(v2)
|
||||||
|
m = append(m, s)
|
||||||
|
default:
|
||||||
|
fmt.Printf("arrayOfSchemasValue: unexpected node %+v\n", v2)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return &m
|
||||||
|
case yaml.MappingNode:
|
||||||
|
m := make([]*Schema, 0)
|
||||||
|
s := NewSchemaFromObject(v)
|
||||||
|
m = append(m, s)
|
||||||
|
return &m
|
||||||
|
default:
|
||||||
|
fmt.Printf("arrayOfSchemasValue: unexpected node %+v\n", v)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Gets a Schema or an array of Schemas from an interface{} value if possible.
|
||||||
|
func (schema *Schema) schemaOrSchemaArrayValue(v *yaml.Node) *SchemaOrSchemaArray {
|
||||||
|
switch v.Kind {
|
||||||
|
case yaml.SequenceNode:
|
||||||
|
m := make([]*Schema, 0)
|
||||||
|
for _, v2 := range v.Content {
|
||||||
|
switch v2.Kind {
|
||||||
|
case yaml.MappingNode:
|
||||||
|
s := NewSchemaFromObject(v2)
|
||||||
|
m = append(m, s)
|
||||||
|
default:
|
||||||
|
fmt.Printf("schemaOrSchemaArrayValue: unexpected node %+v\n", v2)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return &SchemaOrSchemaArray{SchemaArray: &m}
|
||||||
|
case yaml.MappingNode:
|
||||||
|
s := NewSchemaFromObject(v)
|
||||||
|
return &SchemaOrSchemaArray{Schema: s}
|
||||||
|
default:
|
||||||
|
fmt.Printf("schemaOrSchemaArrayValue: unexpected node %+v\n", v)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Gets an array of strings from an interface{} value if possible.
|
||||||
|
func (schema *Schema) arrayOfStringsValue(v *yaml.Node) *[]string {
|
||||||
|
switch v.Kind {
|
||||||
|
case yaml.ScalarNode:
|
||||||
|
a := []string{v.Value}
|
||||||
|
return &a
|
||||||
|
case yaml.SequenceNode:
|
||||||
|
a := make([]string, 0)
|
||||||
|
for _, v2 := range v.Content {
|
||||||
|
switch v2.Kind {
|
||||||
|
case yaml.ScalarNode:
|
||||||
|
a = append(a, v2.Value)
|
||||||
|
default:
|
||||||
|
fmt.Printf("arrayOfStringsValue: unexpected node %+v\n", v2)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return &a
|
||||||
|
default:
|
||||||
|
fmt.Printf("arrayOfStringsValue: unexpected node %+v\n", v)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Gets a string or an array of strings from an interface{} value if possible.
|
||||||
|
func (schema *Schema) stringOrStringArrayValue(v *yaml.Node) *StringOrStringArray {
|
||||||
|
switch v.Kind {
|
||||||
|
case yaml.ScalarNode:
|
||||||
|
s := &StringOrStringArray{}
|
||||||
|
s.String = &v.Value
|
||||||
|
return s
|
||||||
|
case yaml.SequenceNode:
|
||||||
|
a := make([]string, 0)
|
||||||
|
for _, v2 := range v.Content {
|
||||||
|
switch v2.Kind {
|
||||||
|
case yaml.ScalarNode:
|
||||||
|
a = append(a, v2.Value)
|
||||||
|
default:
|
||||||
|
fmt.Printf("arrayOfStringsValue: unexpected node %+v\n", v2)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
s := &StringOrStringArray{}
|
||||||
|
s.StringArray = &a
|
||||||
|
return s
|
||||||
|
default:
|
||||||
|
fmt.Printf("arrayOfStringsValue: unexpected node %+v\n", v)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Gets an array of enum values from an interface{} value if possible.
|
||||||
|
func (schema *Schema) arrayOfEnumValuesValue(v *yaml.Node) *[]SchemaEnumValue {
|
||||||
|
a := make([]SchemaEnumValue, 0)
|
||||||
|
switch v.Kind {
|
||||||
|
case yaml.SequenceNode:
|
||||||
|
for _, v2 := range v.Content {
|
||||||
|
switch v2.Kind {
|
||||||
|
case yaml.ScalarNode:
|
||||||
|
switch v2.Tag {
|
||||||
|
case "!!str":
|
||||||
|
a = append(a, SchemaEnumValue{String: &v2.Value})
|
||||||
|
case "!!bool":
|
||||||
|
v3, _ := strconv.ParseBool(v2.Value)
|
||||||
|
a = append(a, SchemaEnumValue{Bool: &v3})
|
||||||
|
default:
|
||||||
|
fmt.Printf("arrayOfEnumValuesValue: unexpected type %s\n", v2.Tag)
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
fmt.Printf("arrayOfEnumValuesValue: unexpected node %+v\n", v2)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
fmt.Printf("arrayOfEnumValuesValue: unexpected node %+v\n", v)
|
||||||
|
}
|
||||||
|
return &a
|
||||||
|
}
|
||||||
|
|
||||||
|
// Gets a map of schemas or string arrays from an interface{} value if possible.
|
||||||
|
func (schema *Schema) mapOfSchemasOrStringArraysValue(v *yaml.Node) *[]*NamedSchemaOrStringArray {
|
||||||
|
m := make([]*NamedSchemaOrStringArray, 0)
|
||||||
|
switch v.Kind {
|
||||||
|
case yaml.MappingNode:
|
||||||
|
for i := 0; i < len(v.Content); i += 2 {
|
||||||
|
k2 := v.Content[i].Value
|
||||||
|
v2 := v.Content[i+1]
|
||||||
|
switch v2.Kind {
|
||||||
|
case yaml.SequenceNode:
|
||||||
|
a := make([]string, 0)
|
||||||
|
for _, v3 := range v2.Content {
|
||||||
|
switch v3.Kind {
|
||||||
|
case yaml.ScalarNode:
|
||||||
|
a = append(a, v3.Value)
|
||||||
|
default:
|
||||||
|
fmt.Printf("mapOfSchemasOrStringArraysValue: unexpected node %+v\n", v3)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
s := &SchemaOrStringArray{}
|
||||||
|
s.StringArray = &a
|
||||||
|
pair := &NamedSchemaOrStringArray{Name: k2, Value: s}
|
||||||
|
m = append(m, pair)
|
||||||
|
default:
|
||||||
|
fmt.Printf("mapOfSchemasOrStringArraysValue: unexpected node %+v\n", v2)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
fmt.Printf("mapOfSchemasOrStringArraysValue: unexpected node %+v\n", v)
|
||||||
|
}
|
||||||
|
return &m
|
||||||
|
}
|
||||||
|
|
||||||
|
// Gets a schema or a boolean value from an interface{} value if possible.
|
||||||
|
func (schema *Schema) schemaOrBooleanValue(v *yaml.Node) *SchemaOrBoolean {
|
||||||
|
schemaOrBoolean := &SchemaOrBoolean{}
|
||||||
|
switch v.Kind {
|
||||||
|
case yaml.ScalarNode:
|
||||||
|
v2, _ := strconv.ParseBool(v.Value)
|
||||||
|
schemaOrBoolean.Boolean = &v2
|
||||||
|
case yaml.MappingNode:
|
||||||
|
schemaOrBoolean.Schema = NewSchemaFromObject(v)
|
||||||
|
default:
|
||||||
|
fmt.Printf("schemaOrBooleanValue: unexpected node %+v\n", v)
|
||||||
|
}
|
||||||
|
return schemaOrBoolean
|
||||||
|
}
|
150
vendor/github.com/googleapis/gnostic/jsonschema/schema.json
generated
vendored
Normal file
150
vendor/github.com/googleapis/gnostic/jsonschema/schema.json
generated
vendored
Normal file
@ -0,0 +1,150 @@
|
|||||||
|
{
|
||||||
|
"id": "http://json-schema.org/draft-04/schema#",
|
||||||
|
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||||
|
"description": "Core schema meta-schema",
|
||||||
|
"definitions": {
|
||||||
|
"schemaArray": {
|
||||||
|
"type": "array",
|
||||||
|
"minItems": 1,
|
||||||
|
"items": { "$ref": "#" }
|
||||||
|
},
|
||||||
|
"positiveInteger": {
|
||||||
|
"type": "integer",
|
||||||
|
"minimum": 0
|
||||||
|
},
|
||||||
|
"positiveIntegerDefault0": {
|
||||||
|
"allOf": [ { "$ref": "#/definitions/positiveInteger" }, { "default": 0 } ]
|
||||||
|
},
|
||||||
|
"simpleTypes": {
|
||||||
|
"enum": [ "array", "boolean", "integer", "null", "number", "object", "string" ]
|
||||||
|
},
|
||||||
|
"stringArray": {
|
||||||
|
"type": "array",
|
||||||
|
"items": { "type": "string" },
|
||||||
|
"minItems": 1,
|
||||||
|
"uniqueItems": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"id": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "uri"
|
||||||
|
},
|
||||||
|
"$schema": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "uri"
|
||||||
|
},
|
||||||
|
"title": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"description": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"default": {},
|
||||||
|
"multipleOf": {
|
||||||
|
"type": "number",
|
||||||
|
"minimum": 0,
|
||||||
|
"exclusiveMinimum": true
|
||||||
|
},
|
||||||
|
"maximum": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"exclusiveMaximum": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false
|
||||||
|
},
|
||||||
|
"minimum": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"exclusiveMinimum": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false
|
||||||
|
},
|
||||||
|
"maxLength": { "$ref": "#/definitions/positiveInteger" },
|
||||||
|
"minLength": { "$ref": "#/definitions/positiveIntegerDefault0" },
|
||||||
|
"pattern": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "regex"
|
||||||
|
},
|
||||||
|
"additionalItems": {
|
||||||
|
"anyOf": [
|
||||||
|
{ "type": "boolean" },
|
||||||
|
{ "$ref": "#" }
|
||||||
|
],
|
||||||
|
"default": {}
|
||||||
|
},
|
||||||
|
"items": {
|
||||||
|
"anyOf": [
|
||||||
|
{ "$ref": "#" },
|
||||||
|
{ "$ref": "#/definitions/schemaArray" }
|
||||||
|
],
|
||||||
|
"default": {}
|
||||||
|
},
|
||||||
|
"maxItems": { "$ref": "#/definitions/positiveInteger" },
|
||||||
|
"minItems": { "$ref": "#/definitions/positiveIntegerDefault0" },
|
||||||
|
"uniqueItems": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false
|
||||||
|
},
|
||||||
|
"maxProperties": { "$ref": "#/definitions/positiveInteger" },
|
||||||
|
"minProperties": { "$ref": "#/definitions/positiveIntegerDefault0" },
|
||||||
|
"required": { "$ref": "#/definitions/stringArray" },
|
||||||
|
"additionalProperties": {
|
||||||
|
"anyOf": [
|
||||||
|
{ "type": "boolean" },
|
||||||
|
{ "$ref": "#" }
|
||||||
|
],
|
||||||
|
"default": {}
|
||||||
|
},
|
||||||
|
"definitions": {
|
||||||
|
"type": "object",
|
||||||
|
"additionalProperties": { "$ref": "#" },
|
||||||
|
"default": {}
|
||||||
|
},
|
||||||
|
"properties": {
|
||||||
|
"type": "object",
|
||||||
|
"additionalProperties": { "$ref": "#" },
|
||||||
|
"default": {}
|
||||||
|
},
|
||||||
|
"patternProperties": {
|
||||||
|
"type": "object",
|
||||||
|
"additionalProperties": { "$ref": "#" },
|
||||||
|
"default": {}
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"type": "object",
|
||||||
|
"additionalProperties": {
|
||||||
|
"anyOf": [
|
||||||
|
{ "$ref": "#" },
|
||||||
|
{ "$ref": "#/definitions/stringArray" }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"enum": {
|
||||||
|
"type": "array",
|
||||||
|
"minItems": 1,
|
||||||
|
"uniqueItems": true
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
"anyOf": [
|
||||||
|
{ "$ref": "#/definitions/simpleTypes" },
|
||||||
|
{
|
||||||
|
"type": "array",
|
||||||
|
"items": { "$ref": "#/definitions/simpleTypes" },
|
||||||
|
"minItems": 1,
|
||||||
|
"uniqueItems": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"allOf": { "$ref": "#/definitions/schemaArray" },
|
||||||
|
"anyOf": { "$ref": "#/definitions/schemaArray" },
|
||||||
|
"oneOf": { "$ref": "#/definitions/schemaArray" },
|
||||||
|
"not": { "$ref": "#" }
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"exclusiveMaximum": [ "maximum" ],
|
||||||
|
"exclusiveMinimum": [ "minimum" ]
|
||||||
|
},
|
||||||
|
"default": {}
|
||||||
|
}
|
369
vendor/github.com/googleapis/gnostic/jsonschema/writer.go
generated
vendored
Normal file
369
vendor/github.com/googleapis/gnostic/jsonschema/writer.go
generated
vendored
Normal file
@ -0,0 +1,369 @@
|
|||||||
|
// Copyright 2017 Google LLC. All Rights Reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package jsonschema
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"gopkg.in/yaml.v3"
|
||||||
|
)
|
||||||
|
|
||||||
|
const indentation = " "
|
||||||
|
|
||||||
|
func renderMappingNode(node *yaml.Node, indent string) (result string) {
|
||||||
|
result = "{\n"
|
||||||
|
innerIndent := indent + indentation
|
||||||
|
for i := 0; i < len(node.Content); i += 2 {
|
||||||
|
// first print the key
|
||||||
|
key := node.Content[i].Value
|
||||||
|
result += fmt.Sprintf("%s\"%+v\": ", innerIndent, key)
|
||||||
|
// then the value
|
||||||
|
value := node.Content[i+1]
|
||||||
|
switch value.Kind {
|
||||||
|
case yaml.ScalarNode:
|
||||||
|
result += "\"" + value.Value + "\""
|
||||||
|
case yaml.MappingNode:
|
||||||
|
result += renderMappingNode(value, innerIndent)
|
||||||
|
case yaml.SequenceNode:
|
||||||
|
result += renderSequenceNode(value, innerIndent)
|
||||||
|
default:
|
||||||
|
result += fmt.Sprintf("???MapItem(Key:%+v, Value:%T)", value, value)
|
||||||
|
}
|
||||||
|
if i < len(node.Content)-2 {
|
||||||
|
result += ","
|
||||||
|
}
|
||||||
|
result += "\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
result += indent + "}"
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
func renderSequenceNode(node *yaml.Node, indent string) (result string) {
|
||||||
|
result = "[\n"
|
||||||
|
innerIndent := indent + indentation
|
||||||
|
for i := 0; i < len(node.Content); i++ {
|
||||||
|
item := node.Content[i]
|
||||||
|
switch item.Kind {
|
||||||
|
case yaml.ScalarNode:
|
||||||
|
result += innerIndent + "\"" + item.Value + "\""
|
||||||
|
case yaml.MappingNode:
|
||||||
|
result += innerIndent + renderMappingNode(item, innerIndent) + ""
|
||||||
|
default:
|
||||||
|
result += innerIndent + fmt.Sprintf("???ArrayItem(%+v)", item)
|
||||||
|
}
|
||||||
|
if i < len(node.Content)-1 {
|
||||||
|
result += ","
|
||||||
|
}
|
||||||
|
result += "\n"
|
||||||
|
}
|
||||||
|
result += indent + "]"
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
func renderStringArray(array []string, indent string) (result string) {
|
||||||
|
result = "[\n"
|
||||||
|
innerIndent := indent + indentation
|
||||||
|
for i, item := range array {
|
||||||
|
result += innerIndent + "\"" + item + "\""
|
||||||
|
if i < len(array)-1 {
|
||||||
|
result += ","
|
||||||
|
}
|
||||||
|
result += "\n"
|
||||||
|
}
|
||||||
|
result += indent + "]"
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
// Render renders a yaml.Node as JSON
|
||||||
|
func Render(node *yaml.Node) string {
|
||||||
|
if node.Kind == yaml.DocumentNode {
|
||||||
|
if len(node.Content) == 1 {
|
||||||
|
return Render(node.Content[0])
|
||||||
|
}
|
||||||
|
} else if node.Kind == yaml.MappingNode {
|
||||||
|
return renderMappingNode(node, "") + "\n"
|
||||||
|
} else if node.Kind == yaml.SequenceNode {
|
||||||
|
return renderSequenceNode(node, "") + "\n"
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (object *SchemaNumber) nodeValue() *yaml.Node {
|
||||||
|
if object.Integer != nil {
|
||||||
|
return nodeForInt64(*object.Integer)
|
||||||
|
} else if object.Float != nil {
|
||||||
|
return nodeForFloat64(*object.Float)
|
||||||
|
} else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (object *SchemaOrBoolean) nodeValue() *yaml.Node {
|
||||||
|
if object.Schema != nil {
|
||||||
|
return object.Schema.nodeValue()
|
||||||
|
} else if object.Boolean != nil {
|
||||||
|
return nodeForBoolean(*object.Boolean)
|
||||||
|
} else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func nodeForStringArray(array []string) *yaml.Node {
|
||||||
|
content := make([]*yaml.Node, 0)
|
||||||
|
for _, item := range array {
|
||||||
|
content = append(content, nodeForString(item))
|
||||||
|
}
|
||||||
|
return nodeForSequence(content)
|
||||||
|
}
|
||||||
|
|
||||||
|
func nodeForSchemaArray(array []*Schema) *yaml.Node {
|
||||||
|
content := make([]*yaml.Node, 0)
|
||||||
|
for _, item := range array {
|
||||||
|
content = append(content, item.nodeValue())
|
||||||
|
}
|
||||||
|
return nodeForSequence(content)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (object *StringOrStringArray) nodeValue() *yaml.Node {
|
||||||
|
if object.String != nil {
|
||||||
|
return nodeForString(*object.String)
|
||||||
|
} else if object.StringArray != nil {
|
||||||
|
return nodeForStringArray(*(object.StringArray))
|
||||||
|
} else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (object *SchemaOrStringArray) nodeValue() *yaml.Node {
|
||||||
|
if object.Schema != nil {
|
||||||
|
return object.Schema.nodeValue()
|
||||||
|
} else if object.StringArray != nil {
|
||||||
|
return nodeForStringArray(*(object.StringArray))
|
||||||
|
} else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (object *SchemaOrSchemaArray) nodeValue() *yaml.Node {
|
||||||
|
if object.Schema != nil {
|
||||||
|
return object.Schema.nodeValue()
|
||||||
|
} else if object.SchemaArray != nil {
|
||||||
|
return nodeForSchemaArray(*(object.SchemaArray))
|
||||||
|
} else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (object *SchemaEnumValue) nodeValue() *yaml.Node {
|
||||||
|
if object.String != nil {
|
||||||
|
return nodeForString(*object.String)
|
||||||
|
} else if object.Bool != nil {
|
||||||
|
return nodeForBoolean(*object.Bool)
|
||||||
|
} else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func nodeForNamedSchemaArray(array *[]*NamedSchema) *yaml.Node {
|
||||||
|
content := make([]*yaml.Node, 0)
|
||||||
|
for _, pair := range *(array) {
|
||||||
|
content = appendPair(content, pair.Name, pair.Value.nodeValue())
|
||||||
|
}
|
||||||
|
return nodeForMapping(content)
|
||||||
|
}
|
||||||
|
|
||||||
|
func nodeForNamedSchemaOrStringArray(array *[]*NamedSchemaOrStringArray) *yaml.Node {
|
||||||
|
content := make([]*yaml.Node, 0)
|
||||||
|
for _, pair := range *(array) {
|
||||||
|
content = appendPair(content, pair.Name, pair.Value.nodeValue())
|
||||||
|
}
|
||||||
|
return nodeForMapping(content)
|
||||||
|
}
|
||||||
|
|
||||||
|
func nodeForSchemaEnumArray(array *[]SchemaEnumValue) *yaml.Node {
|
||||||
|
content := make([]*yaml.Node, 0)
|
||||||
|
for _, item := range *array {
|
||||||
|
content = append(content, item.nodeValue())
|
||||||
|
}
|
||||||
|
return nodeForSequence(content)
|
||||||
|
}
|
||||||
|
|
||||||
|
func nodeForMapping(content []*yaml.Node) *yaml.Node {
|
||||||
|
return &yaml.Node{
|
||||||
|
Kind: yaml.MappingNode,
|
||||||
|
Content: content,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func nodeForSequence(content []*yaml.Node) *yaml.Node {
|
||||||
|
return &yaml.Node{
|
||||||
|
Kind: yaml.SequenceNode,
|
||||||
|
Content: content,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func nodeForString(value string) *yaml.Node {
|
||||||
|
return &yaml.Node{
|
||||||
|
Kind: yaml.ScalarNode,
|
||||||
|
Tag: "!!str",
|
||||||
|
Value: value,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func nodeForBoolean(value bool) *yaml.Node {
|
||||||
|
return &yaml.Node{
|
||||||
|
Kind: yaml.ScalarNode,
|
||||||
|
Tag: "!!bool",
|
||||||
|
Value: fmt.Sprintf("%t", value),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func nodeForInt64(value int64) *yaml.Node {
|
||||||
|
return &yaml.Node{
|
||||||
|
Kind: yaml.ScalarNode,
|
||||||
|
Tag: "!!int",
|
||||||
|
Value: fmt.Sprintf("%d", value),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func nodeForFloat64(value float64) *yaml.Node {
|
||||||
|
return &yaml.Node{
|
||||||
|
Kind: yaml.ScalarNode,
|
||||||
|
Tag: "!!float",
|
||||||
|
Value: fmt.Sprintf("%f", value),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func appendPair(nodes []*yaml.Node, name string, value *yaml.Node) []*yaml.Node {
|
||||||
|
nodes = append(nodes, nodeForString(name))
|
||||||
|
nodes = append(nodes, value)
|
||||||
|
return nodes
|
||||||
|
}
|
||||||
|
|
||||||
|
func (schema *Schema) nodeValue() *yaml.Node {
|
||||||
|
n := &yaml.Node{Kind: yaml.MappingNode}
|
||||||
|
content := make([]*yaml.Node, 0)
|
||||||
|
if schema.Title != nil {
|
||||||
|
content = appendPair(content, "title", nodeForString(*schema.Title))
|
||||||
|
}
|
||||||
|
if schema.ID != nil {
|
||||||
|
content = appendPair(content, "id", nodeForString(*schema.ID))
|
||||||
|
}
|
||||||
|
if schema.Schema != nil {
|
||||||
|
content = appendPair(content, "$schema", nodeForString(*schema.Schema))
|
||||||
|
}
|
||||||
|
if schema.Type != nil {
|
||||||
|
content = appendPair(content, "type", schema.Type.nodeValue())
|
||||||
|
}
|
||||||
|
if schema.Items != nil {
|
||||||
|
content = appendPair(content, "items", schema.Items.nodeValue())
|
||||||
|
}
|
||||||
|
if schema.Description != nil {
|
||||||
|
content = appendPair(content, "description", nodeForString(*schema.Description))
|
||||||
|
}
|
||||||
|
if schema.Required != nil {
|
||||||
|
content = appendPair(content, "required", nodeForStringArray(*schema.Required))
|
||||||
|
}
|
||||||
|
if schema.AdditionalProperties != nil {
|
||||||
|
content = appendPair(content, "additionalProperties", schema.AdditionalProperties.nodeValue())
|
||||||
|
}
|
||||||
|
if schema.PatternProperties != nil {
|
||||||
|
content = appendPair(content, "patternProperties", nodeForNamedSchemaArray(schema.PatternProperties))
|
||||||
|
}
|
||||||
|
if schema.Properties != nil {
|
||||||
|
content = appendPair(content, "properties", nodeForNamedSchemaArray(schema.Properties))
|
||||||
|
}
|
||||||
|
if schema.Dependencies != nil {
|
||||||
|
content = appendPair(content, "dependencies", nodeForNamedSchemaOrStringArray(schema.Dependencies))
|
||||||
|
}
|
||||||
|
if schema.Ref != nil {
|
||||||
|
content = appendPair(content, "$ref", nodeForString(*schema.Ref))
|
||||||
|
}
|
||||||
|
if schema.MultipleOf != nil {
|
||||||
|
content = appendPair(content, "multipleOf", schema.MultipleOf.nodeValue())
|
||||||
|
}
|
||||||
|
if schema.Maximum != nil {
|
||||||
|
content = appendPair(content, "maximum", schema.Maximum.nodeValue())
|
||||||
|
}
|
||||||
|
if schema.ExclusiveMaximum != nil {
|
||||||
|
content = appendPair(content, "exclusiveMaximum", nodeForBoolean(*schema.ExclusiveMaximum))
|
||||||
|
}
|
||||||
|
if schema.Minimum != nil {
|
||||||
|
content = appendPair(content, "minimum", schema.Minimum.nodeValue())
|
||||||
|
}
|
||||||
|
if schema.ExclusiveMinimum != nil {
|
||||||
|
content = appendPair(content, "exclusiveMinimum", nodeForBoolean(*schema.ExclusiveMinimum))
|
||||||
|
}
|
||||||
|
if schema.MaxLength != nil {
|
||||||
|
content = appendPair(content, "maxLength", nodeForInt64(*schema.MaxLength))
|
||||||
|
}
|
||||||
|
if schema.MinLength != nil {
|
||||||
|
content = appendPair(content, "minLength", nodeForInt64(*schema.MinLength))
|
||||||
|
}
|
||||||
|
if schema.Pattern != nil {
|
||||||
|
content = appendPair(content, "pattern", nodeForString(*schema.Pattern))
|
||||||
|
}
|
||||||
|
if schema.AdditionalItems != nil {
|
||||||
|
content = appendPair(content, "additionalItems", schema.AdditionalItems.nodeValue())
|
||||||
|
}
|
||||||
|
if schema.MaxItems != nil {
|
||||||
|
content = appendPair(content, "maxItems", nodeForInt64(*schema.MaxItems))
|
||||||
|
}
|
||||||
|
if schema.MinItems != nil {
|
||||||
|
content = appendPair(content, "minItems", nodeForInt64(*schema.MinItems))
|
||||||
|
}
|
||||||
|
if schema.UniqueItems != nil {
|
||||||
|
content = appendPair(content, "uniqueItems", nodeForBoolean(*schema.UniqueItems))
|
||||||
|
}
|
||||||
|
if schema.MaxProperties != nil {
|
||||||
|
content = appendPair(content, "maxProperties", nodeForInt64(*schema.MaxProperties))
|
||||||
|
}
|
||||||
|
if schema.MinProperties != nil {
|
||||||
|
content = appendPair(content, "minProperties", nodeForInt64(*schema.MinProperties))
|
||||||
|
}
|
||||||
|
if schema.Enumeration != nil {
|
||||||
|
content = appendPair(content, "enum", nodeForSchemaEnumArray(schema.Enumeration))
|
||||||
|
}
|
||||||
|
if schema.AllOf != nil {
|
||||||
|
content = appendPair(content, "allOf", nodeForSchemaArray(*schema.AllOf))
|
||||||
|
}
|
||||||
|
if schema.AnyOf != nil {
|
||||||
|
content = appendPair(content, "anyOf", nodeForSchemaArray(*schema.AnyOf))
|
||||||
|
}
|
||||||
|
if schema.OneOf != nil {
|
||||||
|
content = appendPair(content, "oneOf", nodeForSchemaArray(*schema.OneOf))
|
||||||
|
}
|
||||||
|
if schema.Not != nil {
|
||||||
|
content = appendPair(content, "not", schema.Not.nodeValue())
|
||||||
|
}
|
||||||
|
if schema.Definitions != nil {
|
||||||
|
content = appendPair(content, "definitions", nodeForNamedSchemaArray(schema.Definitions))
|
||||||
|
}
|
||||||
|
if schema.Default != nil {
|
||||||
|
// m = append(m, yaml.MapItem{Key: "default", Value: *schema.Default})
|
||||||
|
}
|
||||||
|
if schema.Format != nil {
|
||||||
|
content = appendPair(content, "format", nodeForString(*schema.Format))
|
||||||
|
}
|
||||||
|
n.Content = content
|
||||||
|
return n
|
||||||
|
}
|
||||||
|
|
||||||
|
// JSONString returns a json representation of a schema.
|
||||||
|
func (schema *Schema) JSONString() string {
|
||||||
|
node := schema.nodeValue()
|
||||||
|
return Render(node)
|
||||||
|
}
|
11
vendor/modules.txt
vendored
11
vendor/modules.txt
vendored
@ -26,17 +26,16 @@ github.com/golang/protobuf/ptypes/timestamp
|
|||||||
## explicit
|
## explicit
|
||||||
github.com/google/gofuzz
|
github.com/google/gofuzz
|
||||||
github.com/google/gofuzz/bytesource
|
github.com/google/gofuzz/bytesource
|
||||||
# github.com/googleapis/gnostic v0.4.1 => github.com/googleapis/gnostic v0.4.0
|
# github.com/googleapis/gnostic v0.4.1 => github.com/googleapis/gnostic v0.5.3
|
||||||
github.com/googleapis/gnostic/compiler
|
github.com/googleapis/gnostic/compiler
|
||||||
github.com/googleapis/gnostic/extensions
|
github.com/googleapis/gnostic/extensions
|
||||||
|
github.com/googleapis/gnostic/jsonschema
|
||||||
github.com/googleapis/gnostic/openapiv2
|
github.com/googleapis/gnostic/openapiv2
|
||||||
# github.com/imdario/mergo v0.3.11
|
# github.com/imdario/mergo v0.3.11
|
||||||
## explicit
|
## explicit
|
||||||
github.com/imdario/mergo
|
github.com/imdario/mergo
|
||||||
# github.com/json-iterator/go v1.1.10
|
# github.com/json-iterator/go v1.1.10
|
||||||
github.com/json-iterator/go
|
github.com/json-iterator/go
|
||||||
# github.com/kr/pretty v0.2.0
|
|
||||||
## explicit
|
|
||||||
# github.com/matttproud/golang_protobuf_extensions v1.0.1
|
# github.com/matttproud/golang_protobuf_extensions v1.0.1
|
||||||
github.com/matttproud/golang_protobuf_extensions/pbutil
|
github.com/matttproud/golang_protobuf_extensions/pbutil
|
||||||
# github.com/miekg/dns v1.1.35
|
# github.com/miekg/dns v1.1.35
|
||||||
@ -152,6 +151,8 @@ gopkg.in/inf.v0
|
|||||||
# gopkg.in/yaml.v2 v2.4.0
|
# gopkg.in/yaml.v2 v2.4.0
|
||||||
## explicit
|
## explicit
|
||||||
gopkg.in/yaml.v2
|
gopkg.in/yaml.v2
|
||||||
|
# gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776
|
||||||
|
gopkg.in/yaml.v3
|
||||||
# k8s.io/api v0.19.6
|
# k8s.io/api v0.19.6
|
||||||
## explicit
|
## explicit
|
||||||
k8s.io/api/admissionregistration/v1
|
k8s.io/api/admissionregistration/v1
|
||||||
@ -232,7 +233,7 @@ k8s.io/apimachinery/pkg/util/yaml
|
|||||||
k8s.io/apimachinery/pkg/version
|
k8s.io/apimachinery/pkg/version
|
||||||
k8s.io/apimachinery/pkg/watch
|
k8s.io/apimachinery/pkg/watch
|
||||||
k8s.io/apimachinery/third_party/forked/golang/reflect
|
k8s.io/apimachinery/third_party/forked/golang/reflect
|
||||||
# k8s.io/client-go v0.19.6 => k8s.io/client-go v0.19.6
|
# k8s.io/client-go v0.0.0-00010101000000-000000000000 => k8s.io/client-go v0.19.6
|
||||||
## explicit
|
## explicit
|
||||||
k8s.io/client-go/discovery
|
k8s.io/client-go/discovery
|
||||||
k8s.io/client-go/kubernetes
|
k8s.io/client-go/kubernetes
|
||||||
@ -311,4 +312,4 @@ sigs.k8s.io/structured-merge-diff/v4/value
|
|||||||
# sigs.k8s.io/yaml v1.2.0
|
# sigs.k8s.io/yaml v1.2.0
|
||||||
sigs.k8s.io/yaml
|
sigs.k8s.io/yaml
|
||||||
# k8s.io/client-go => k8s.io/client-go v0.19.6
|
# k8s.io/client-go => k8s.io/client-go v0.19.6
|
||||||
# github.com/googleapis/gnostic => github.com/googleapis/gnostic v0.4.0
|
# github.com/googleapis/gnostic => github.com/googleapis/gnostic v0.5.3
|
||||||
|
Loading…
x
Reference in New Issue
Block a user