jackson-module-jsonSchema icon indicating copy to clipboard operation
jackson-module-jsonSchema copied to clipboard

Generate json schema which should rejects all additional content

Open jsunsoftware opened this issue 7 years ago • 2 comments

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);

jsunsoftware avatar Feb 28 '18 07:02 jsunsoftware

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

cowtowncoder avatar Feb 28 '18 19:02 cowtowncoder

I made refactor in description.

jsunsoftware avatar Mar 01 '18 06:03 jsunsoftware