-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot override model as a primitive type #573
Comments
The model overriding is meant to be used to override they way models are On Wed, May 21, 2014 at 2:02 AM, Dan Jackson [email protected]:
|
I don't think that'll work, I want to replace the type for all requests, parameters and responses, and I can't do it through annotations. Dates are a great example. Our (third-party provided) schema specifies that the date fields have type XMLGregorianCalendar. We've told Jackson (the json serialization library we're using) that it should produce and consume strings with a certain format (yyyy-MM-dd...) for all XMLGregorianCalendar fields. I need Swagger to reflect this fact. And a very similar story for BigDecimal. Because it's a global override, there's no way I want to find and annotate each field with the target type, even if we could. Can this be the specific issue to provide this feature? Is there some other way I can word it to be more clear? Thanks! |
We're actually working on a stronger integration between Jackson and On Wed, May 21, 2014 at 8:03 PM, Dan Jackson [email protected]:
|
I'm confused why this isn't working. Did you look here? https://github.com/wordnik/swagger-core/wiki/overriding-models |
@webron I can't figure out how someone would use Swagger with types like BigDecimal and not need this, unless they're solely going from Java to Java. My API client should not send me scale and precision (the internal representation of BigDecimal on Java) it should send me the value as a string (since any other JSON representation could lose precision). Date classes are another good example, I think. @fehguy I thought my initial message explained why. Did I get something wrong, or explain my issue incorrectly? Thanks again for the help. |
Hi, take a look at #588 for a solution to this issue. |
I can't figure out how to override a class and specify that it should be a primitive type
For example, given:
How do I make swagger think that Dates should be strings, such that swagger-ui (and other clients following the spec) thinks that this is a valid Foo object:
I've tried this: https://github.com/wordnik/swagger-core/wiki/overriding-models
However, that results in clients expecting that Foo objects look like this:
I also want to attach a description (for example) to the date class that specify recognized formats.
So far I want this for things like dates (XMLGregorianCalendar), BigDecimal, and BigInteger, where our JSON serialization knows how to serialize/deserialize as strings in a particular format.
Thanks!
The text was updated successfully, but these errors were encountered: