-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Maven plugin with Jackson and ACCEPT_SINGLE_VALUE_AS_ARRAY #458
Comments
Hi @Boereck, But I've created an example of how this can be easily achieved through configuration (for use via the Maven plugin, you'd have to wrap it in a Basically you can do this: configBuilder.forFields()
.withTargetTypeOverridesResolver(scope -> scope.isContainerType() && !scope.isFakeContainerItemScope()
Arrays.asList(scope.getContainerItemType(), scope.getType()) : null); For a data type like this: class Example {
public List<ArrayItem> someArray;
}
class ArrayItem {
public String value;
} The generated schema ends up with an {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$defs": {
"ArrayItem": {
"type": "object",
"properties": {
"value": {
"type": "string"
}
}
}
},
"type": "object",
"properties": {
"someArray": {
"anyOf": [
{
"$ref": "#/$defs/ArrayItem"
}, {
"type": "array",
"items": {
"$ref": "#/$defs/ArrayItem"
}
}
]
}
}
} We could add a standard |
Wow, that was fast! Thank you so much! |
The release of v4.36.0 was also done. |
Awesome! Works like a charm. Thanks again! |
Hi,
I am using the
jsonschema-maven-plugin
to generate a JSON Schema for Jackson annotated classes. On the ObjectMapper in the code I set the propertycom.fasterxml.jackson.databind.DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY
totrue
. I cannot find a configuration option for the Jackson module of the maven plugin. Is there an option I missed, or is it not (yet) possible to configure such feature on the maven plugin?Thanks for the work on this projekt, and best regards,
Max
The text was updated successfully, but these errors were encountered: