Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Top-level objects do not support additionalProperties #46

Closed
antoineco opened this issue Jun 25, 2018 · 1 comment
Closed

Top-level objects do not support additionalProperties #46

antoineco opened this issue Jun 25, 2018 · 1 comment

Comments

@antoineco
Copy link
Contributor

Issue description

additionalProperties is only supported for nested schemas.

example
{
    "$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

package main

// Parameters 
type Parameters struct {
    Field map[string]string `json:"field,omitempty"`
}

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

example
{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "$id": "http://example.com/parameters.jschema",
    "title": "parameters",
    "type": "object",
    "additionalProperties": { "type": "string" }
}

generates

package main
                   /*                          expected */
// Root            /*    // Field                       */
type Root string   /*    type Field map[string]string   */
@antoineco antoineco changed the title Top-level objects do support additionalProperties Top-level objects do not support additionalProperties Jun 25, 2018
@antoineco
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant