a-h / generate

Generates Go (golang) Structs from JSON schema.
MIT License
444 stars 137 forks source link

Top-level objects do not support additionalProperties #46

Closed antoineco closed 6 years ago

antoineco commented 6 years ago

Issue description

additionalProperties is only supported for nested schemas.

example ```json { "$schema": "http://json-schema.org/draft-07/schema#", "$id": "http://example.com/parameters.jschema", "title": "parameters", "type": "object", "properties": { "field": { "type": "object", "additionalProperties": { "type": "string" } } } } ``` generates ```golang package main // Parameters type Parameters struct { Field map[string]string `json:"field,omitempty"` } ```


I would expect top-level schemas to also support additionalProperties.

example ```json { "$schema": "http://json-schema.org/draft-07/schema#", "$id": "http://example.com/parameters.jschema", "title": "parameters", "type": "object", "additionalProperties": { "type": "string" } } ``` generates ```golang package main /* expected */ // Root /* // Field */ type Root string /* type Field map[string]string */ ```
antoineco commented 6 years ago

This should be a simple addition to #40, I'm working on it.