Skip to content

Commit

Permalink
fix(gen): add support for Free-form Objects when a schema definitions…
Browse files Browse the repository at this point in the history
… only specifies type: object
  • Loading branch information
k4n4ry committed May 22, 2024
1 parent bc94e89 commit 9f4ab19
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions gen/schema_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,12 +261,14 @@ func (g *schemaGen) generate2(name string, schema *jsonschema.Schema) (ret *ir.T
hasProps := len(schema.Properties) > 0
hasAdditionalProps := false
denyAdditionalProps := false
hasPatternProps := len(schema.PatternProperties) > 0
isPatternSingle := len(schema.PatternProperties) == 1
if p := schema.AdditionalProperties; p != nil {
hasAdditionalProps = *p
denyAdditionalProps = !*p
} else if !hasProps && !hasPatternProps {
hasAdditionalProps = true
}
hasPatternProps := len(schema.PatternProperties) > 0
isPatternSingle := len(schema.PatternProperties) == 1

if !hasProps {
if (!hasAdditionalProps && isPatternSingle) || (hasAdditionalProps && !hasPatternProps) {
Expand Down

0 comments on commit 9f4ab19

Please sign in to comment.