Open theseeker58 opened 2 years ago
Found a solution!
setting true mapSimpleTypeDef (default is false) in jaxb:globalBindings did the trick
<jaxb:globalBindings mapSimpleTypeDef="true">
Map35Text and other simpleType declarations like that are generated as Class by xjc with a value string property with restrictions.
Therefore jsonSchema generates
"Max35Text" : {
"type" : "object",
"additionalProperties" : false,
"properties" : {
"value" : {
"type" : "string",
"minLength" : 1,
"maxLength" : 35
}
}
},
I'd have preferred this simpler form without the value property
"Max35Text": {
"type": "string",
"minLenght": 1,
"maxLenght": 35
},
but I must admit that it depends on xjc and not on jsonSchema that does its job accordingly. I'm getting closer... I don't know if using Lombok those classes turn to something like c language typedef struct and so getting more practical in this context
I have an xsd schema that features many complexTypes like this
where Max35Text is just a referenced simpleType based on xs:string with some restrictions
xjc, wrapped in jaxb2-maven-plugin, automatically generates a GroupHeader78 Class where, for example, the mentioned property msgId is a String, annotated with Bean Validation @Size(min = 1, max = 35) thanks to -XJsr303Annotations switch from krasa-jaxb-tools
The generated JSON schema excerpt is the following
Instead of the in-lined string restrictions I would like to get a schema like this
where Max35Text is defined aside (in the same file), just like the simpleType in the original xsd schema
I couldn't figure out if it's possible to configure the plugin to get this done. Any help/suggestion is appreciated