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.

Using @GetMapping method with custom java class parameter and parameter show error type in swagger UI .

See original GitHub issue

I’m using spring boot version 2.02 and springfox-swagger2 version 2.8.0 for develop my Restful WebApi , but i find that if I use custom java class as @GetMapping method parameter , then Swagger UI will show that method parameter is a java string type , how can i fix this? here is a simple code :

@RestController
@RequestMapping("/api/test")
public class temp  {
    @GetMapping("count")
    public void getDarenPriceCount(@RequestParam user user)
    {
        System.out.println(user.getName());
    }
}
public class user {
    public String name;
    public String age;
   // get and set
}

the result: 2018-06-29 3 04 04

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
dilipkrishcommented, Jun 29, 2018

Have you both tried 2.9.2?

0reactions
dilipkrishcommented, Jul 10, 2018

I believe you need to add CustomParam to the docket via additionalModels and it should work.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Setting Example and Description with Swagger - Baeldung
First, we'll learn how to add a description to different parts of the APIs, like methods, parameters, and error codes.
Read more >
Swagger declaration schema = @Schema(implementation ...
I have one API endpoint, the request body expects a HashMap. There is not much information on how to fix the "Example value"...
Read more >
Spring MVC @RequestMapping Annotation Example with ...
Like I always do, I will use these methods in Spring MVC application ... for URI dynamic parameter to accept only specific type...
Read more >
Spring HATEOAS - Reference Documentation
Due to Java's type erasure, we cannot actually detect that a ... that is exposed through @GetMapping annotation of the controller method, ...
Read more >
Guide to Spring Boot REST API Error Handling - Toptal
Building REST APIs with Spring became the standard approach for Java developers ... They convert Java date and time classes to JSON representation...
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