FasterXML / jackson-module-jsonSchema

Module for generating JSON Schema (v3) definitions from POJOs
371 stars 135 forks source link

Required Fields #63

Closed mherb63 closed 9 years ago

mherb63 commented 9 years ago

JSON Schema has the ability to mark fields as required. This module supports this via the @JsonProperty(required = true) field annotation.

This is not working for me. My object has the following field:

 @XmlAttribute(name = "clientRequestId", required = true)
  protected String clientRequestId;

and the generated output is :

    "clientRequestId" : {
      "type" : "string"
    },

I'm using

    <dependency>
        <groupId>com.fasterxml.jackson.module</groupId>
        <artifactId>jackson-module-jsonSchema</artifactId>
        <version>2.5.1</version>
    </dependency>
cowtowncoder commented 9 years ago

Have you registered JAXB module? Otherwise Jackson does not make use of JAXB annotations, and can not propagate information (since it does not detect it) to schema generator.

mherb63 commented 9 years ago

Thanks, that fixed the issue.