reinert / JJSchema

A generator from Java Types to JSON-Schema using Jackson.
Other
117 stars 56 forks source link

adding mapping ZonedDateTime => string #62

Closed juliengrandjean closed 7 years ago

juliengrandjean commented 7 years ago

Allow the usage of java type "java.time.ZonedDateTime as a type for a field.

@Attributes(description = "date with timezone") private ZonedDateTime myDate; => "myDate": { "type": "string", "description": "date with timezone" }

Otherwise, we get an error at execution as the ZonedDateTime Class contains a simple generic "get" method :

private String processPropertyName() {
    return (field == null) ? firstToLowerCase(method.getName()
            .replace("get", "")) : field.getName();
}

Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 0 at java.lang.String.charAt(String.java:658) at com.github.reinert.jjschema.v1.PropertyWrapper.firstToLowerCase(PropertyWrapper.java:370)

reinert commented 7 years ago

Nice! Thanks for contributing!

I noticed your PR commits are a bit messy. Could you please refork the project and add just the piece of code in "SimpleTypeMappings.java" so I can merge your patch without dirtying the git log?

Thanks.

reinert commented 7 years ago

Oh! Additionally you could map Instant and LocalDate types as reported in #60. Would that be good to you?

juliengrandjean commented 7 years ago

OK, I just saw that I made lot of "unwanted" commits, sorry for the mess. I'll restart from the begining, and will add those two types.