mirror of https://github.com/k3s-io/k3s
Fix yet another bug in OpenAPI extension generation
parent
c083871b68
commit
bcd0288e60
|
@ -132,7 +132,9 @@ func (o *openAPI) buildDefinitionRecursively(name string) error {
|
||||||
SwaggerSchemaProps: item.Schema.SwaggerSchemaProps,
|
SwaggerSchemaProps: item.Schema.SwaggerSchemaProps,
|
||||||
}
|
}
|
||||||
if extensions != nil {
|
if extensions != nil {
|
||||||
schema.Extensions = spec.Extensions{}
|
if schema.Extensions == nil {
|
||||||
|
schema.Extensions = spec.Extensions{}
|
||||||
|
}
|
||||||
for k, v := range extensions {
|
for k, v := range extensions {
|
||||||
schema.Extensions[k] = v
|
schema.Extensions[k] = v
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
||||||
package openapi
|
package openapi
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -203,7 +204,7 @@ func getConfig(fullMethods bool) (*openapi.Config, *restful.Container) {
|
||||||
if strings.HasPrefix(friendlyName, "go_default_test") {
|
if strings.HasPrefix(friendlyName, "go_default_test") {
|
||||||
friendlyName = "openapi" + friendlyName[len("go_default_test"):]
|
friendlyName = "openapi" + friendlyName[len("go_default_test"):]
|
||||||
}
|
}
|
||||||
return friendlyName, nil
|
return friendlyName, spec.Extensions{"x-test2": "test2"}
|
||||||
},
|
},
|
||||||
}, container
|
}, container
|
||||||
}
|
}
|
||||||
|
@ -388,7 +389,8 @@ func getTestInputDefinition() spec.Schema {
|
||||||
},
|
},
|
||||||
VendorExtensible: spec.VendorExtensible{
|
VendorExtensible: spec.VendorExtensible{
|
||||||
Extensions: spec.Extensions{
|
Extensions: spec.Extensions{
|
||||||
"x-test": "test",
|
"x-test": "test",
|
||||||
|
"x-test2": "test2",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -414,6 +416,11 @@ func getTestOutputDefinition() spec.Schema {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
VendorExtensible: spec.VendorExtensible{
|
||||||
|
Extensions: spec.Extensions{
|
||||||
|
"x-test2": "test2",
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -441,7 +448,16 @@ func TestBuildSwaggerSpec(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
err := o.init(container.RegisteredWebServices())
|
err := o.init(container.RegisteredWebServices())
|
||||||
if assert.NoError(err) {
|
if !assert.NoError(err) {
|
||||||
assert.Equal(expected, o.swagger)
|
return
|
||||||
}
|
}
|
||||||
|
expected_json, err := json.Marshal(expected)
|
||||||
|
if !assert.NoError(err) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
actual_json, err := json.Marshal(o.swagger)
|
||||||
|
if !assert.NoError(err) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
assert.Equal(string(expected_json), string(actual_json))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue