-
Notifications
You must be signed in to change notification settings - Fork 1.5k
@ApiModelProperty throwing NumberFormatException if example value is not set #2265
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
Comments
@dilipkrish for this annotation @APIModelProperty we are receiving another exception ClassNotFound. ClassNotFoundException stack trace
|
@nikunjundhad That seems like you've got an |
@nikunjundhad what version of springfox are u using? |
I suspect this is fixed. Would you mind testing with 2.8.0-SNAPSHOT and reporting back. Im closing this issue for now. If its not fixed please re-open this issue |
@dilipkrish i am using latest version 2.8.0 |
Would be great if you could try 2.8.1-SNAPSHOT and confirm if its fixed. |
I'm experiencing the exact same thing as the OP with the NumberFormatException in 2.8.1-SNAPSHOT. Is there a fix in the works for this or should I just ignore the warning via my log config? It feels like this is some sort of regression since it was supposed to be fixed here: |
Possibly a slightly different stack trace? Or perhaps a breaking test would be useful. I have a feeling It should be fixed @kyleki |
Here's the stacktrace I'm getting: Stack trace
|
@kyleki Oh I assumed it was an exception that was thrown... I didnt realize you meant a warning log message with stack trace. Is the issue that we want to not show the stack trace? |
I'd prefer that the empty example is properly handled rather than attempting to cast it to a number. However, in lieu of that, just showing the warning without the stack trace would be nice. In the meantime, I've added the following to my application.properties file to hide the warning and stack trace: |
@kyleki I dug into that some, unfortunately thats not in the library we control. Its probably better that the swagger-core library handles it appropriately, or we have to use your solution. I'd rather not have a bunch of code in this library that conditionally sets the example. |
Yeah, they claim it was fixed back in 2016: Unfortunately it seems like it's still not fixed or was broken in a subsequent change. I'll log the issue over there to see if anything can be done with it in swagger-core. Thanks @dilipkrish ! |
I encountered this problem after I upgraded springfox from 2.8.0 to 2.9.2. |
@HADB this is not a problem with springfox as I've outlined above |
Hi everybody, I solved this issue removing old swagger version (1.5.20) and add new one. In pom.xml <dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
<exclusions>
<exclusion>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
</exclusion>
<exclusion>
<groupId>io.swagger</groupId>
<artifactId>swagger-models</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>1.5.21</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-models</artifactId>
<version>1.5.21</version>
</dependency> |
@ajcRodrigues Thanks! |
@ajcRodrigues It works! Greate job! |
@ajcRodrigues, Thanks 👍 |
@ajcRodrigues Thanks! It works like a charm 🍸 For Gradle's users: compile("io.springfox:springfox-swagger2:2.9.2") {
exclude module: 'swagger-annotations'
exclude module: 'swagger-models'
}
compile("io.swagger:swagger-annotations:1.5.21")
compile("io.swagger:swagger-models:1.5.21") |
an issue of old-version of swagger @ApiParam throwing NumberFormatException (related to NcsRest.java). Find a solution to remove the old version of swagger from springfox from springfox/springfox#2265
an issue of old-version of swagger @ApiParam throwing NumberFormatException (related to NcsRest.java). Find a solution to remove the old version of swagger from springfox from springfox/springfox#2265
@ajcRodrigues Thanks! |
@ajcRodrigues Thank you very much, works great. |
Thank you 👍 It was nice solution to me. |
What's an example @apimodel property that causes this issue? Can we developers fix up our annotations to silence this? I checked all of mine on Integer and Long type, all have an example value that's a valid number, yet the warning messages still appear in my app's log. Alternately, if I understood this correctly, springfox version 2.9.2 references swagger-models and swagger-annotations libraries at version 1.5.20; to squelch this annoying warning springfox POM needs to use versions 1.15.21 instead. Did I get that right? Is this change scheduled for a future version of springfox? |
@ajcRodrigues Thanks!!! 👍 |
JFYI, this issue was resolved at swagger-api/swagger-core#2865 |
@ajcRodrigues Thanks! |
@ajcRodrigues Thanks! 2.9.2 the version still 1.5.20 |
Hello @dilipkrish ! Will there be a newer version of springfox that will include 1.5.21 version of swagger-annotations and swagger-models? |
See: swagger-api/swagger-core#2979 and springfox/springfox#2265 Upgrading to swagger-models 1.5.21 is the long term fix.
This problem still exists in springfox 3.0.0 |
Uh oh!
There was an error while loading. Please reload this page.
Hi,
When we don't set example value in @ApiModelProperty for Wrapper class, its try to set empty string ("") as an example and during parsing its throw NumberFormatException, can't we have something which set default value for those wrapper class like for Integer it set 0 in JSON example.
We are facing this issue for IntegerProperty, DecimalProperty, BaseIntegerProperty.
Below i attached Exception log,
NumberFormatException stack trace
The text was updated successfully, but these errors were encountered: