huehnerlady
05/18/2021, 2:32 PMNikky
05/18/2021, 10:23 PMNikky
05/18/2021, 10:24 PMNikky
05/18/2021, 10:27 PMhuehnerlady
05/19/2021, 6:18 AMNikky
05/19/2021, 7:46 AMhuehnerlady
05/19/2021, 11:25 AMhuehnerlady
05/19/2021, 12:08 PM@Serializable
data class Foo(
val field1: String? = null,
val field2: FooEnum? = null,
val field3: FooEnum? = null,
)
@Serializable
enum class FooEnum {
VALUE_1, VALUE_2
}
{
"$schema": "<http://json-schema.org/draft-07/schema>",
"type": "object",
"properties": {
"field1": {
"if": {
"type": "string"
},
"else": {
"type": "null"
}
},
"field2": {
"if": {
"type": "string"
},
"else": {
"type": "null"
},
"enum": [
"VALUE_1",
"VALUE_2"
]
},
"field3": {
"if": {
"type": "string"
},
"else": {
"type": "null"
},
"enum": [
"VALUE_1",
"VALUE_2"
]
}
},
"definitions": {}
}
With definition it looks even worse as the names are auto-generated:
{
"$schema": "<http://json-schema.org/draft-07/schema>",
"$ref": "#/definitions/x1a1q3f9pvqxof",
"definitions": {
"x1a1q3f9pvqxof": {
"type": "object",
"properties": {
"field1": {
"$ref": "#/definitions/x1oxo2fpbh9ren"
},
"field2": {
"enum": [
"VALUE_1",
"VALUE_2"
],
"$ref": "#/definitions/x1u18olg46aewv"
},
"field3": {
"enum": [
"VALUE_1",
"VALUE_2"
],
"$ref": "#/definitions/x1u18olg46aewv"
}
}
},
"x1oxo2fpbh9ren": {
"if": {
"type": "string"
},
"else": {
"type": "null"
}
},
"x1u18olg46aewv": {
"if": {
"type": "string"
},
"else": {
"type": "null"
},
"enum": [
"VALUE_1",
"VALUE_2"
]
}
}
}
So I will continue with my current approach I think as at least I do not need any annotations for thisNikky
05/19/2021, 12:11 PMhuehnerlady
05/19/2021, 12:12 PMNikky
05/19/2021, 4:50 PMDariusz Kuc
05/19/2021, 9:47 PMhuehnerlady
05/20/2021, 5:58 AMpaths
variable is mandatory in the spec so it seems not to be designed to use that just for a model. so we had to discard that