Skip to content

how to handle custom annotations and custom keywords(properties) #432

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

You must be logged in to vote

HI @ramlg,

If you want to add custom schema keywords/attributes, you'll be looking into what I call "Attribute Overrides" here.
E.g., https://victools.github.io/jsonschema-generator/#type-attribute-overrides
The example in the documentation is close to what you want. Adjusted for your sample case that could look like:

configBuilder.forTypesInGeneral().withTypeAttributeOverride((node, scope, context) -> {
        Class<?> erasedType = scope.getErasedType();
        ClassMetadata metadataAnnotation = erasedType.getAnnotation(ClassMetadata.class);
        if (metadataAnnotation != null && !metadataAnnotation.owner().isEmpty()) {
            node.putObject("metadata")
                    .put("…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@ramlg
Comment options

@CarstenWickner
Comment options

Answer selected by ramlg
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