[英]How to document with Swagger @RequestParam Map<String, String>
I'm trying to document my RESTFUL API made with Spring Boot using Swagger UI, the problem is that when i open the swagger-ui.html to view my documentation. 我正在尝试使用Swagger UI记录由Spring Boot制作的RESTFUL API,问题是当我打开swagger-ui.html查看我的文档时。
When I open the controller on the swagger-ui.html to view my methods, they are blank, with only one parameter which is a Map type. 当我在swagger-ui.html上打开控制器以查看我的方法时,它们为空白,只有一个参数,即Map类型。 Obvious with this map object I fetch the parameters I need and make the request to the database or whatever. 显然,使用此映射对象,我可以获取所需的参数,并向数据库或其他对象发出请求。
I would like to know how I could tell swagger that those methods need some specific values or arguments, not just a simple Map object , i would like to tell the user with the api doc that he needs to input the key1,key2,key3 to call this method. 我想知道我该如何告诉那些方法需要一些特定的值或参数,而不仅仅是一个简单的Map对象,我想告诉具有api文档的用户他需要输入key1,key2,key3来调用此方法。
There is an example of one method 有一种方法的例子
@GetMapping("/technical/sma/**")
public ArrayList<RegistroTecnico> recuperarSMA(@RequestParam Map<String, String> queryParameters) {
return this.recuperarIndicadorAVG("sma",queryParameters);
}
I would like to tell swagger to document the parameters needed for the method manually if there is no way. 如果没有办法,我想告诉swagger手动记录该方法所需的参数。
It looks like there is no direct support from SpringFox in Spring boot application for Map type. 在Spring引导应用程序中,SpringFox似乎没有针对Map类型的直接支持。 You have to write your own custom plugin. 您必须编写自己的自定义插件。 You can get more details from this issue. 您可以从此问题中获取更多详细信息。
https://github.com/springfox/springfox/issues/1503# https://github.com/springfox/springfox/issues/1503#
I think till now there is no support for Map type parameter auto-detect doc from swagger. 我想到现在为止,还不支持swagger的Map类型参数自动检测doc。 If you need auto-detect Param from swagger just convert the map into POJO and wrap it in response body but for that you need to change request type to POST. 如果您需要从招摇中自动检测参数,只需将地图转换为POJO并将其包装在响应主体中,但是为此您需要将请求类型更改为POST。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.