mirror of https://github.com/k3s-io/k3s
Merge pull request #59844 from mikedanese/openapi
Automatic merge from submit-queue (batch tested with PRs 60196, 59844, 60255, 60254, 60251). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. godeps: bump go-openapi This might help https://github.com/kubernetes/kubernetes/issues/59450 See https://github.com/go-openapi/spec/pull/61 This cuts ~25 seconds off of TestValidOpenAPISpec on my workstation. ```release-note NONE ```pull/6/head
commit
186b04d59b
|
@ -1262,7 +1262,7 @@
|
|||
},
|
||||
{
|
||||
"ImportPath": "github.com/go-openapi/spec",
|
||||
"Rev": "7abd5745472fff5eb3685386d5fb8bf38683154d"
|
||||
"Rev": "1de3e0542de65ad8d75452a595886fdd0befb363"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/go-openapi/strfmt",
|
||||
|
|
|
@ -404,7 +404,7 @@
|
|||
},
|
||||
{
|
||||
"ImportPath": "github.com/go-openapi/spec",
|
||||
"Rev": "7abd5745472fff5eb3685386d5fb8bf38683154d"
|
||||
"Rev": "1de3e0542de65ad8d75452a595886fdd0befb363"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/go-openapi/strfmt",
|
||||
|
|
|
@ -388,7 +388,7 @@
|
|||
},
|
||||
{
|
||||
"ImportPath": "github.com/go-openapi/spec",
|
||||
"Rev": "7abd5745472fff5eb3685386d5fb8bf38683154d"
|
||||
"Rev": "1de3e0542de65ad8d75452a595886fdd0befb363"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/go-openapi/swag",
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
},
|
||||
{
|
||||
"ImportPath": "github.com/go-openapi/spec",
|
||||
"Rev": "7abd5745472fff5eb3685386d5fb8bf38683154d"
|
||||
"Rev": "1de3e0542de65ad8d75452a595886fdd0befb363"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/go-openapi/swag",
|
||||
|
|
|
@ -128,7 +128,7 @@
|
|||
},
|
||||
{
|
||||
"ImportPath": "github.com/go-openapi/spec",
|
||||
"Rev": "7abd5745472fff5eb3685386d5fb8bf38683154d"
|
||||
"Rev": "1de3e0542de65ad8d75452a595886fdd0befb363"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/go-openapi/swag",
|
||||
|
|
|
@ -120,7 +120,7 @@
|
|||
},
|
||||
{
|
||||
"ImportPath": "github.com/go-openapi/spec",
|
||||
"Rev": "7abd5745472fff5eb3685386d5fb8bf38683154d"
|
||||
"Rev": "1de3e0542de65ad8d75452a595886fdd0befb363"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/go-openapi/swag",
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -28,6 +28,7 @@ type SimpleSchema struct {
|
|||
Items *Items `json:"items,omitempty"`
|
||||
CollectionFormat string `json:"collectionFormat,omitempty"`
|
||||
Default interface{} `json:"default,omitempty"`
|
||||
Example interface{} `json:"example,omitempty"`
|
||||
}
|
||||
|
||||
func (s *SimpleSchema) TypeName() string {
|
||||
|
@ -178,9 +179,14 @@ func (i *Items) UnmarshalJSON(data []byte) error {
|
|||
if err := json.Unmarshal(data, &simpleSchema); err != nil {
|
||||
return err
|
||||
}
|
||||
var vendorExtensible VendorExtensible
|
||||
if err := json.Unmarshal(data, &vendorExtensible); err != nil {
|
||||
return err
|
||||
}
|
||||
i.Refable = ref
|
||||
i.CommonValidations = validations
|
||||
i.SimpleSchema = simpleSchema
|
||||
i.VendorExtensible = vendorExtensible
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -198,7 +204,11 @@ func (i Items) MarshalJSON() ([]byte, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return swag.ConcatJSON(b3, b1, b2), nil
|
||||
b4, err := json.Marshal(i.VendorExtensible)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return swag.ConcatJSON(b4, b3, b1, b2), nil
|
||||
}
|
||||
|
||||
// JSONLookup look up a value by the json property name
|
||||
|
|
|
@ -31,11 +31,36 @@ type OperationProps struct {
|
|||
ExternalDocs *ExternalDocumentation `json:"externalDocs,omitempty"`
|
||||
ID string `json:"operationId,omitempty"`
|
||||
Deprecated bool `json:"deprecated,omitempty"`
|
||||
Security []map[string][]string `json:"security,omitempty"`
|
||||
Security []map[string][]string `json:"security,omitempty"` //Special case, see MarshalJSON function
|
||||
Parameters []Parameter `json:"parameters,omitempty"`
|
||||
Responses *Responses `json:"responses,omitempty"`
|
||||
}
|
||||
|
||||
// MarshalJSON takes care of serializing operation properties to JSON
|
||||
//
|
||||
// We use a custom marhaller here to handle a special cases related
|
||||
// the Security field. We need to preserve zero length slice
|
||||
// while omiting the field when the value is nil/unset.
|
||||
func (op OperationProps) MarshalJSON() ([]byte, error) {
|
||||
type Alias OperationProps
|
||||
if op.Security == nil {
|
||||
return json.Marshal(&struct {
|
||||
Security []map[string][]string `json:"security,omitempty"`
|
||||
*Alias
|
||||
}{
|
||||
Security: op.Security,
|
||||
Alias: (*Alias)(&op),
|
||||
})
|
||||
}
|
||||
return json.Marshal(&struct {
|
||||
Security []map[string][]string `json:"security"`
|
||||
*Alias
|
||||
}{
|
||||
Security: op.Security,
|
||||
Alias: (*Alias)(&op),
|
||||
})
|
||||
}
|
||||
|
||||
// Operation describes a single API operation on a path.
|
||||
//
|
||||
// For more information: http://goo.gl/8us55a#operationObject
|
||||
|
|
|
@ -145,7 +145,10 @@ func (r *Ref) UnmarshalJSON(d []byte) error {
|
|||
if err := json.Unmarshal(d, &v); err != nil {
|
||||
return err
|
||||
}
|
||||
return r.fromMap(v)
|
||||
}
|
||||
|
||||
func (r *Ref) fromMap(v map[string]interface{}) error {
|
||||
if v == nil {
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -135,6 +135,10 @@ func (r *SchemaURL) UnmarshalJSON(data []byte) error {
|
|||
if err := json.Unmarshal(data, &v); err != nil {
|
||||
return err
|
||||
}
|
||||
return r.fromMap(v)
|
||||
}
|
||||
|
||||
func (r *SchemaURL) fromMap(v map[string]interface{}) error {
|
||||
if v == nil {
|
||||
return nil
|
||||
}
|
||||
|
@ -582,18 +586,17 @@ func (s Schema) MarshalJSON() ([]byte, error) {
|
|||
|
||||
// UnmarshalJSON marshal this from JSON
|
||||
func (s *Schema) UnmarshalJSON(data []byte) error {
|
||||
var sch Schema
|
||||
if err := json.Unmarshal(data, &sch.SchemaProps); err != nil {
|
||||
props := struct {
|
||||
SchemaProps
|
||||
SwaggerSchemaProps
|
||||
}{}
|
||||
if err := json.Unmarshal(data, &props); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := json.Unmarshal(data, &sch.Ref); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := json.Unmarshal(data, &sch.Schema); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := json.Unmarshal(data, &sch.SwaggerSchemaProps); err != nil {
|
||||
return err
|
||||
|
||||
sch := Schema{
|
||||
SchemaProps: props.SchemaProps,
|
||||
SwaggerSchemaProps: props.SwaggerSchemaProps,
|
||||
}
|
||||
|
||||
var d map[string]interface{}
|
||||
|
@ -601,6 +604,9 @@ func (s *Schema) UnmarshalJSON(data []byte) error {
|
|||
return err
|
||||
}
|
||||
|
||||
sch.Ref.fromMap(d)
|
||||
sch.Schema.fromMap(d)
|
||||
|
||||
delete(d, "$ref")
|
||||
delete(d, "$schema")
|
||||
for _, pn := range swag.DefaultJSONNameProvider.GetJSONNames(s) {
|
||||
|
|
Loading…
Reference in New Issue