Generate code for basic models from JSON schema.
- Java
- Groovy
- Kotlin
- TypeScript
- T-SQL
- unit tests for java and groovy before moving on
- generate build files in directories
- Constants / final properties ?
- Serialization
- Builder methods
- hashCode, toString, and equals methods
- Parameterized constructor using 'required' on object properties
- On a similar note, call parameterized super constructor
A couple of new properties were added to add more functionality.
extends
- extend from other object in another schemaprimitive
- array: T[] or List ; numbers: Float or float; Integer or intparseTo
- attempt a parse to non-standard JSON schema types (BigDecimal, Long, Byte, etc)- If parsing fails on a field, it falls back to whatever is specified in
type
- If parsing fails on a field, it falls back to whatever is specified in
{
"id": "http://json-schema.org/thing",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Book",
"description": "A book",
"type": "object",
"extends": {
"$ref": "Common/Thing.json" // relative to schema directory
},
"properties": {
"genres": {
"type": "array",
"items": {
"type": "string", // String.class
"maxItems": 10, // String[10] init in constructor
"primitive": true // true= T[], false/null= List<T>
}
},
"pageLength": {
"type": "integer", // Integer.class
"parseTo": "Long", // attempt parse to Long.class
"default": 25 // default value to 25 in constructor
},
"isbn": {
"type": "string"
},
"author": {
"$ref": "Common/Person.json" // Person.class relative to schema directory
},
"price": {
"type": "number", // Float.class
"parseTo": "decimal" // attempt parse to BigDecimal for currency handling, falls back to Float if failed
}
}
}
- Run tests
python -m unittest