Hi all,
I am trying to find any approach to generate Kotlin data models with validation annotations from XSD files to use them in JVM and JS environment as main application models.
Previously in Java I used XJC + Krasa plugin to generate JAXB classes with JSR-303 validations.
Is there any similar way for Kotlin Multi-platform?
I see one complex workaround:
- Generate JAXB+JSR303 Java classes as usual
- Copy-paste them in IDE to Kotlin classes (more than 4000 classes)
- Create expect annotation classes for XML and JSR303 annotations (javax.validation etc.)
- Create empty actual annotation classes for javax.validation in JS.
- Set Serializable annotation manually to all calsses
- Convert XSD schema to JSON Schema to be able to validate JSON objects in JS
- Serialize multi-platform model to JSON and validate it via JSON Schema.
But this approach require too much manual work as I have several thousands classes and it does not allow to validate models directly in JS, but only via JSON serialization.
Appreciated for any thoughts…