Added docs, more tests and cleanup.

Signed-off-by: Quobix <dave@quobix.com>
This commit is contained in:
Quobix
2023-08-30 08:44:30 -04:00
committed by quobix
parent 2ddc147906
commit 5faa24e333
4 changed files with 143 additions and 33 deletions

View File

@@ -989,6 +989,36 @@ properties:
assert.Equal(t, `{"name":"pb33f"}`, string(rendered))
}
func TestRenderSchema_WithEnum_Float(t *testing.T) {
testObject := `type: [object]
properties:
count:
type: number
enum: [9934.223]`
compiled := getSchema([]byte(testObject))
schema := make(map[string]any)
wr := createSchemaRenderer()
wr.DiveIntoSchema(compiled, "pb33f", schema, 0)
rendered, _ := json.Marshal(schema["pb33f"])
assert.Equal(t, `{"count":9934.223}`, string(rendered))
}
func TestRenderSchema_WithEnum_Integer(t *testing.T) {
testObject := `type: [object]
properties:
count:
type: number
enum: [9934]`
compiled := getSchema([]byte(testObject))
schema := make(map[string]any)
wr := createSchemaRenderer()
wr.DiveIntoSchema(compiled, "pb33f", schema, 0)
rendered, _ := json.Marshal(schema["pb33f"])
assert.Equal(t, `{"count":9934}`, string(rendered))
}
func TestCreateRendererUsingDefaultDictionary(t *testing.T) {
assert.NotNil(t, CreateRendererUsingDefaultDictionary())
}