mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-07 04:20:14 +00:00
Add ‘disable required check’ switch on renderer #200
Signed-off-by: quobix <dave@quobix.com>
This commit is contained in:
@@ -960,6 +960,32 @@ properties:
|
||||
assert.Nil(t, journeyMap["pb33f"].(map[string]interface{})["fries"])
|
||||
}
|
||||
|
||||
func TestRenderExample_Test_RequiredCheckDisabled(t *testing.T) {
|
||||
testObject := `type: [object]
|
||||
required:
|
||||
- drink
|
||||
properties:
|
||||
burger:
|
||||
type: string
|
||||
fries:
|
||||
type: string
|
||||
drink:
|
||||
type: string`
|
||||
|
||||
compiled := getSchema([]byte(testObject))
|
||||
|
||||
journeyMap := make(map[string]any)
|
||||
wr := createSchemaRenderer()
|
||||
wr.DisableRequiredCheck()
|
||||
wr.DiveIntoSchema(compiled, "pb33f", journeyMap, 0)
|
||||
|
||||
assert.NotNil(t, journeyMap["pb33f"])
|
||||
drink := journeyMap["pb33f"].(map[string]interface{})["drink"].(string)
|
||||
assert.NotNil(t, drink)
|
||||
assert.NotNil(t, journeyMap["pb33f"].(map[string]interface{})["burger"])
|
||||
assert.NotNil(t, journeyMap["pb33f"].(map[string]interface{})["fries"])
|
||||
}
|
||||
|
||||
func TestRenderSchema_WithExample(t *testing.T) {
|
||||
testObject := `type: [object]
|
||||
properties:
|
||||
|
||||
Reference in New Issue
Block a user