adding the class id field to jsonschema for enums

72 views Asked by At

Is there a way to add the id property when generating jsonschema? Using the jackson databind, I am:

ObjectMapper mapper = new ObjectMapper();
SchemaFactoryWrapper visitor = new SchemaFactoryWrapper();
JsonSchemaGenerator jsg = new JsonSchemaGenerator(mapper, visitor);
JsonSchema jsonSchema = jsg.generateSchema(Status.class);

On the following enum:

public enum Status {
    ON,
    OFF;
}

It generates:

{
  "type" : "string",
  "enum" : [ "ON", "OFF" ]
}

However, if would like it to include the id:

{
  "id"   : "urn:jsonschema:com:example:enums:Status"
  "type" : "string",
  "enum" : [ "ON", "OFF" ]
}

Is this possible?

0

There are 0 answers