mbknor / mbknor-jackson-jsonSchema

Generate JSON Schema with Polymorphism using Jackson annotations
MIT License
234 stars 79 forks source link

@JsonProperty(defaultValue="...") does not allow float/double values #152

Open almson opened 3 years ago

almson commented 3 years ago

Title is self-explanatory, more details here https://github.com/mbknor/mbknor-jackson-jsonSchema/issues/73#issuecomment-794332684

almson commented 3 years ago

I changed https://github.com/mbknor/mbknor-jackson-jsonSchema/blob/e370f80d5dd20eb9396455ab2ddfd7083d0e25fb/src/main/scala/com/kjetland/jackson/jsonSchema/JsonSchemaGenerator.scala#L703 to node.put("default", value.toDouble) and things work. Doubles are doubles and ints are ints. FYI, a double can represent all ints exactly and most longs, up to 2^53. There would be problems however if the default value is something like MAX_LONG (which of course the current implementation doesn't support either).