springfox: @ExampleProperty/value is getting ignored

What version of the library are you using?

2.9.2

What kind of issue is this?

Bug

Example Repository

https://github.com/napolev/springfox-swagger2-issue

How to recreate the issue

$ git clone https://github.com/napolev/springfox-swagger2-issue
$ cd springfox-swagger2-issue
$ gradle bootRun

Description of the issue

On the repository pointed above there is a very simple project which contains the following file:

/src/main/java/com/example/demo/car/CarController.java

Preview

The issue is that the @ExampleProperty / value is getting ignored as you can see on the image below:

Preview

Other than that, everything works fine. For example, for the following payload the response is correct:

Preview

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 13
  • Comments: 24 (2 by maintainers)

Most upvoted comments

@dilipkrish Any update on this issue? The examples are not working in 2.9.2. For us examples are a must for documentation. Please help!

Bingo! Finally on this commit I was able to find the way to make Sprinfox Swagger to auto populate the values on the Swagger UI:

https://github.com/napolev/springfox-swagger2-issue/commit/7e2591d07fc5d8e83282f01bd7e8ce5e2475c761

Here you have a screenshot of it:

image

Thank you guys for all your help including @indicasta.

Hi! @nikosvaggalis I have tried what you suggested before about changing the JSON file produced by Springfox , replacing the “x-examples” by:

"schema":{ "type":"string", "example" : { "property":"this is a test" }}

For this purpose I took the first example in this issue provided by @napolev, first of all I changed the Springfox version from 2.9.2 to 3.0.0-SNAPSHOT and reduced the JSON file obtained with this last version, then I converted the JSON file to YML using the swagger editor. You can find the result in https://github.com/indicasta/springfox-swagger2-issue/blob/master/api-docs-reduced.yml. Finally with this reduction I got the expected result shown in the image below.

image

Do you have any idea on how can I get that result by using Springfox automatically?

Just in case here you have the repo I created for this purpose:

https://github.com/indicasta/springfox-swagger2-issue

Thanks!