On Tue, Oct 2, 2018 at 10:34 PM <alag...@linagora.com> wrote:
>
> Hi,
>
> Is there a simple way to generate XSD from a Java class?
>
> I successfully generated JSON with Jackson Module JsonSchema but I didn't 
> found how to do it with XSD (no module existing ?).
> I would like to be able to to it like in JSON, see this code:
>
> ObjectMapper jsonMapper = new ObjectMapper();
> JsonSchemaGenerator jsonSchemaGen = new JsonSchemaGenerator(jsonMapper);
> JsonSchema jsonSchema = jsonSchemaGen.generateSchema(ServiceModel.class);
> jsonMapper.writeValue(new File("exampleSchema.json"), jsonSchema);
>
> But with XmlMapper instead of ObjectMapper, and something instead of 
> JsonSchemaGenerator?
>
> I was able te generate JSON Schema with XML instead of JSON, but this is not 
> the same syntax as XSD.

Jackson does not offer XSD generation functionality, partly since such
generators have long existed, and because
supporting XML Schema is rather complicated and metadata Jackson can
offer is bit limited with respect to special details XML handing adds
over much simpler JSON.

There are no plans to add such support.

Others may be able to point to better tools, but traditionally
`schemagen` of JAXB:

https://stackoverflow.com/questions/9681373/utility-to-generate-xsd-from-java-class

has been the way to go.

-+ Tatu +-

-- 
You received this message because you are subscribed to the Google Groups 
"jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jackson-user+unsubscr...@googlegroups.com.
To post to this group, send email to jackson-user@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to