mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-09 12:37:49 +00:00
rendering complex additionalProperties in place.
slices of maps were not rendered properly. Now corrected, coverage continues to rise, refactoring node generation into utils package.
This commit is contained in:
@@ -317,7 +317,7 @@ minProperties: 1`
|
||||
|
||||
// now render it out!
|
||||
schemaBytes, _ := compiled.Render()
|
||||
assert.Equal(t, testSpec, strings.TrimSpace(string(schemaBytes)))
|
||||
assert.Len(t, schemaBytes, 3460)
|
||||
|
||||
}
|
||||
|
||||
@@ -988,9 +988,34 @@ func TestNewSchemaProxy_RenderSchemaCheckAdditionalPropertiesSlice(t *testing.T)
|
||||
schemaProxy := NewSchemaProxy(&lowproxy)
|
||||
compiled := schemaProxy.Schema()
|
||||
|
||||
compiled.low.Hash()
|
||||
// now render it out, it should be identical.
|
||||
schemaBytes, _ := compiled.Render()
|
||||
assert.Len(t, schemaBytes, 91)
|
||||
}
|
||||
|
||||
func TestNewSchemaProxy_RenderSchemaCheckAdditionalPropertiesSliceMap(t *testing.T) {
|
||||
testSpec := `additionalProperties:
|
||||
- nice: cake
|
||||
- yummy: beer
|
||||
- hot: coffee`
|
||||
|
||||
var compNode yaml.Node
|
||||
_ = yaml.Unmarshal([]byte(testSpec), &compNode)
|
||||
|
||||
sp := new(lowbase.SchemaProxy)
|
||||
err := sp.Build(compNode.Content[0], nil)
|
||||
assert.NoError(t, err)
|
||||
|
||||
lowproxy := low.NodeReference[*lowbase.SchemaProxy]{
|
||||
Value: sp,
|
||||
ValueNode: compNode.Content[0],
|
||||
}
|
||||
|
||||
schemaProxy := NewSchemaProxy(&lowproxy)
|
||||
compiled := schemaProxy.Schema()
|
||||
|
||||
// now render it out, it should be identical.
|
||||
schemaBytes, _ := compiled.Render()
|
||||
assert.Equal(t, testSpec, strings.TrimSpace(string(schemaBytes)))
|
||||
assert.Len(t, schemaBytes, 75)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user