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

Generate json schema which should rejects all additional content #129

Open
jsunsoftware opened this issue Feb 28, 2018 · 2 comments
Open

Comments

@jsunsoftware
Copy link

jsunsoftware commented Feb 28, 2018

Provide JSON schema generation where "additionalProperties" : false will be applied for all classes which I have.

Suppose I have following classes:

class A{
    private String s;
    private B b;

    public String getS() {
        return s;
    }

    public B getB() {
        return b;
    }
}

class B{
    private BigDecimal bd;

    public BigDecimal getBd() {
        return bd;
    }
}

Generating schema as following like below code the schema property "additionalProperties" : false was applying only for the class A.

ObjectMapper mapper = new ObjectMapper();
JsonSchemaGenerator schemaGen = new JsonSchemaGenerator(mapper);
ObjectSchema schema = schemaGen.generateSchema(A.class).asObjectSchema();
schema.rejectAdditionalProperties();
mapper.writerWithDefaultPrettyPrinter().writeValueAsString(schema);
@cowtowncoder
Copy link
Member

This is not a user support for forum for asking questions, but issue tracker.

@jsunsoftware
Copy link
Author

I made refactor in description.

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

2 participants