-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
ApiResponse.examples not showing in swagger ui #2538
Comments
I think it may be a Swagger-ui thing, but the other thing to definitely try is to single quote the string example |
Same behavior when I added single quote. |
Could you share an excerpt of your swagger specification json? Wondering if it may be about where you're looking in the UI. |
hi. is there any way so that we can provide different Request URL instead of swagger hosted on. actually we are implementing gateway in between thus request will go first gateway then it will come to main server. |
Yes, you can. |
Configuration used same as in 1st post.
output json from http://localhost:8082/v2/api-docs
|
@stengvac just confirming, are you using 2.9.2? |
yup |
Same problem here. Springfox 2.9.2, Kotlin 1.2.51, SpringBoot 2.0.3.RELEASE. |
According to this test Lines 291 to 307 in ac4c54e
We see this output Lines 206 to 233 in ac4c54e
Not sure, if its something with Kotlin or springboot 2.0 |
Tried same code as provided in test example with controller written in Java and examples are not showing. so it is possible, that problem is in spring-boot? |
Hi, I am facing the same issue ApiResponse.examples not showing in swagger ui. May i know when this feature will be available. |
Hey, I need this feature also. When will this be released? |
I see that you use |
Anyone who is interested in this feature can use 3.0.0-SNAPSHOT that supports the @ExampleProperty. To convert the library from 2.9.2 to 3.0.0-SNAPSHOT, please refer to the configuration demo; You may need to include additional libraries.
|
@dilipkrish Hello! Are there any updates about that issue? |
@kduhyun Can't run demo example at https://github.com/springfox/springfox-demos/tree/master/springfox-integration-webmvc. Cannot resole io.springfox.springfox-swagger2 at version 3.0.0-SNAPSHOT. Is this version still available ? |
Is there anyone resolve the problem?? it's not working stil.... |
3.0.0 - SNAPSHOT with Kotlin not working still... |
I used @ApiResponses(..). It worked. @ApiResponses(value = { You can use it at the class level or a method level. |
@dilipkrish what version of springfox supports response examples? |
@dilipkrish As I understand, that feature will be repaired in 3.0.0 release? |
Yes absolutely... Im hoping to release in the next couple weeks |
Great! Will be waiting for it |
When do you plan to deploy the version of the issue solved? |
While trying to figure this one out, I noticed that the example response is properly returned if you give up on specifying correct media type. In other words, the example below somewhat works for me: @PostMapping
@ApiResponses({
@ApiResponse(code = 400, message = "Bad Request", examples = @Example({
@ExampleProperty(mediaType = "*/*", value = "{\"status\": \"BAD_REQUEST\"}")
}))
})
public ResponseEntity<RegistrationResource> register(@RequestBody @Valid RegistrationDTO registrationDTO) {
…
} Tested with the 3.0.0-SNAPSHOT version of Springfox. Edit: better yet, you can just specify the |
For some reason, putting .useDefaultResponseMessages(false) at the very end of the chain worked for me (and generated the x-example tags as expected). I did not have any .globalResponseMessage(xx,xx) in my Docket. |
@priyanshuwustl it should be fixed now via #2767 |
Version: springfox 2.9.2, springboot 2.0.2
What kind of issue is this?: Question.
Lang: Kotlin
Examples from ApiResponse annotations are not propagated to swagger-ui. See following code:
After spring-boot start swagger-ui present example text of response 200 as "string". So my question is whether i am missing something or it is bug. Because my expectations were, that example text will be "Example text". For more detailed info see used config and rest controller.
Thx for answering, V
Used config
RestController:
The text was updated successfully, but these errors were encountered: