setters 2.0

This commit is contained in:
Phillip Wittrock
2020-02-10 12:32:07 -08:00
parent ebcc49d064
commit 7097013426
9 changed files with 981 additions and 4 deletions

View File

@@ -49,6 +49,11 @@ func AddSchema(s []byte) (*spec.Schema, error) {
return parse(s)
}
// ResetOpenAPI resets the openapi data to empty
func ResetOpenAPI() {
globalSchema = openapiData{}
}
// AddDefinitions adds the definitions to the global schema.
func AddDefinitions(definitions spec.Definitions) {
// initialize values if they have not yet been set
@@ -123,7 +128,7 @@ func GetSchema(s string) (*ResourceSchema, error) {
// schema as part of the global schema.
// Must be called before the schema is used.
func SuppressBuiltInSchemaUse() {
globalSchema.noUseBuiltInSchema = false
globalSchema.noUseBuiltInSchema = true
}
// Elements returns the Schema for the elements of an array.

View File

@@ -40,7 +40,7 @@ func TestNoUseBuiltInSchema_AddSchema(t *testing.T) {
t.FailNow()
}
s, err := GetSchema(`{"$ref": "#/definitions/io.k8s.config.setters.replicas"}`)
if !assert.Greater(t, len(globalSchema.schema.Definitions), 1) {
if !assert.Equal(t, len(globalSchema.schema.Definitions), 1) {
t.FailNow()
}
if !assert.NoError(t, err) {