Skip to content

How to Generate a JSON Schema for a Method? #525

Answered by CarstenWickner
damo asked this question in Q&A
Discussion options

You must be logged in to vote

HI @damo,

That sounds more like a job for OpenAPI/Swagger than for JSON Schema.

While the JSON Schema Generator is capable of documenting methods, it does not explicitly document the expected input parameters. By excluding the Option.SCHEMA_VERSION_INDICATOR, you also don't have to move around any $schema properties.
For example, the following piece of code

SchemaGeneratorConfigBuilder configBuilder = new SchemaGeneratorConfigBuilder(SchemaVersion.DRAFT_2020_12, OptionPreset.JAVA_OBJECT);
SchemaGenerator generator = new SchemaGenerator(configBuilder.build());
ObjectNode schema = generator.generateSchema(Example.class);

considering this target type:

interface Example {
    Example getSelf(…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@damo
Comment options

Answer selected by damo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants