Fork me on GitHub

Integration with Micronaut JSON Schema Generator

This plugins integrates with Micronaut JSON Schema in order to provide support for generating beans from JSON Schema.

The mn:generate-jsonschema goal is integrated into the generate-sources lifecycle phase and, if enabled, will generate sources in the target directory.

In order to generate Java Beans, the minimal thing to do is enable the goal and specify an input source.

<properties>
   ...
   <micronaut.jsonschema.generator.enabled>true</micronaut.jsonschema.generator.enabled>
   <micronaut.jsonschema.generator.input-file>=src/main/resources/animal.schema.json</micronaut.jsonschema.generator.input-file>
</properties>

Some important notes on configuration settings:

  • Default generation language is JAVA which can be modified. However, only the languages supported by Micronaut SourceGen are supported.

  • The available input values are input-url, input-file, and input-directory. At least one type of input values needs to be provided. If more than one input value is given, only the first non-null value will be used in the aforementioned order.

  • The generator supports all remote references that obey at least one of the pattern rules given in accepted-url-patterns parameter. This parameter is configurable, and it’s default value is ["^https://./..json"].

The full list of configuration properties can be found in the goal documentation.