Skip to content

EnumSet Use and Configuration #303

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

You must be logged in to vote

For completeness' sake, this is what it could look like:

public class EnumSetExample303 {

    public static void main(String[] args) throws JsonProcessingException {
        SchemaGeneratorConfigBuilder builder = new SchemaGeneratorConfigBuilder(SchemaVersion.DRAFT_2020_12, OptionPreset.PLAIN_JSON);
        builder.forFields()
                .withCustomDefinitionProvider(new EnumSetFieldDefinitionProvider());
        JsonNode jsonSchema = new SchemaGenerator(builder.build()).generateSchema(SchemaTarget.class);
        System.out.println(jsonSchema.toPrettyString());
    }

    static class SchemaTarget {
        private final EnumSet<MyEnum> enumSet = EnumSet.of(MyEnum.ONE, MyEnum.THREE)…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by CarstenWickner
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