Added support for decimal and bigint format schema rendering

Want big numbers? you got it. https://github.com/pb33f/wiretap/issues/93
This commit is contained in:
quobix
2024-04-30 21:21:48 -04:00
parent 2999542014
commit f636dc939b
2 changed files with 60 additions and 1 deletions

View File

@@ -1082,6 +1082,35 @@ properties:
assert.Equal(t, `{"args":{"arrParam":"test,test2","arrParamExploded":["1","2"]}}`, string(rendered))
}
// https://github.com/pb33f/wiretap/issues/93
func TestRenderSchema_NonStandard_Format(t *testing.T) {
testObject := `type: object
properties:
bigint:
type: integer
format: bigint
example: 8821239038968084
bigintStr:
type: string
format: bigint
example: "9223372036854775808"
decimal:
type: number
format: decimal
example: 3.141592653589793
decimalStr:
type: string
format: decimal
example: "3.14159265358979344719667586"`
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, `{"bigint":8821239038968084,"bigintStr":"9223372036854775808","decimal":3.141592653589793,"decimalStr":"3.14159265358979344719667586"}`, string(rendered))
}
func TestCreateRendererUsingDefaultDictionary(t *testing.T) {
assert.NotNil(t, CreateRendererUsingDefaultDictionary())
}