question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Example object with RequestBody support

See original GitHub issue
  • Question. I know ‘defaultValue’ property is no more supported for RequestBody. Is ‘Example’ property works for ‘RequestBody’? I do not see any sample in docs for it. Tried using SpringFox 2.9.2, following code for reference:
@ApiParam(name = "body",value = "Request body in JSON format...",required=true,
					examples = @io.swagger.annotations.Example(value= @ExampleProperty( mediaType = MediaType.APPLICATION_JSON_VALUE,
				      value = "{foo: whatever, bar: whatever2}"))
				  ) @RequestBody String body, 

I would like to display one large JSON as example value for request body and clicking on ‘Try it out’ application should show same in edit mode. Please refer to following URL for my expectation behavior []https://petstore.swagger.io/#/store/placeOrder Also note that I am not passing any objects in parameters to method, it is simple ‘String’ type request body as I have mentioned above in my code snippet. Please suggest.

_Originally posted by @vaibhavn in https://github.com/springfox/springfox/issues/853#issuecomment-438263148_

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:3
  • Comments:13 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
Prasaddiwalkarcommented, Jan 29, 2019

I am also facing the same problem, In my case our legacy REST API payload is very complicated. If we do not provide sample then our Open APIs are of no use.

0reactions
ysfAskricommented, Mar 30, 2020

any updates?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Spring's RequestBody and ResponseBody Annotations
In this quick tutorial, we provide a concise overview of the Spring @RequestBody and @ResponseBody annotations.
Read more >
The @RequestBody Annotation - Spring Framework Guru
The @RequestBody annotation tells Spring to deserialize an incoming request body into an object passed as a parameter to the handler method.
Read more >
Spring boot @RequestBody annotation example - B2 Tech
@RequestBody annotation is used to indicating a method parameter should be bind to the body of the HTTP request. Internally, this annotation ...
Read more >
Using @RequestBody and @ResponseBody with Spring MVC
The @RequestBody annotation tells Spring MVC to read the request body and assign the value to the annotated method parameter. As the first...
Read more >
@PostMapping and @RequestBody Example in Spring Boot ...
In this Spring Boot REST tutorial, you will learn how to use the @PostMapping annotation to make your RESTful Web Service Endpoint able...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found