Description
Please take the time to search the repository, if your question has already been asked or answered.
I am using latest version.
What kind of issue is this?
-
Question. Is this a question about how to do a certain thing?
No. -
Bug report. If you’ve found a bug, spend the time to write a failing test. Bugs with tests or
steps to reproduce get fixed faster. Here’s an example: https://gist.github.com/swankjesse/6608b4713ad80988cdc9- spring xml/java config that is relevant
- springfox specific configuration if it makes sense
- include any output you've received; logs, json snippets etc.; and what the expected output should be
- if you have a repo that demonstrates the issue for bonus points! See this example
-
Feature Request. Start by telling us what problem you’re trying to solve. Often a solution
already exists! Don’t send pull requests to implement new features without first getting our
support. Sometimes we leave features out on purpose to keep the project small.
Please do consider starring this repository if you do like this project and find it useful.
My team is using the springfox to generate the swagger documentation, it has issues when I annotated the property with only digits in the example. e.g:
@ApiModelProperty(example = "484799")
private String bsb;
Produces:
"bsb": 484799,
I am expecting the output:
"bsb": "484799",
Following are we have tried so far:
- put the escape character for double quote (example = ""484799"")
- use dataType = "java.lang.String" with example parameter
- Leave extra space in the example value.
- Single quoted the number in the annoation (example = "'484799'"), ouput is
"bsb": "'484799'",
I found the code that does the serialisation in Swagger2JacksonModule
private boolean isNotJsonString(final String value) throws IOException {
// strictly speaking, should also test for equals("null") since {"example": null} would be valid JSON
// but swagger2 does not support null values
// and an example value of "null" probably does not make much sense anyway
return value.startsWith("{") // object
|| value.startsWith("[") // array
|| "true".equals(value) // true
|| "false".equals(value) // false
|| JSON_NUMBER_PATTERN.matcher(value).matches(); // number
}
It seems the serialisation only based on the value but not the actual type and this problem is not visible in version 2.7.0
Thanks