大张旗鼓,我在POST休息时遇到这样的问题
Errors
Resolver error at paths./api/v1/getEntity/{integrationCode}.post.responses.200.schema.items.$ref
Could not resolve reference because of: Could not resolve pointer: /definitions/Map«string,object» does not exist in document
休息控制器:
@RestController
@RequestMapping("api/v1/")
public class RetrieveController {
@PostMapping(value = "getEntity/{integrationCode}", produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<List<Map<String, Object>>> getList(@PathVariable String integrationCode, @RequestBody RetrieveParam retrieveParam) throws JsonProcessingException {
List<Map<String, Object>> integration = ...
return ResponseEntity.ok(integration);
输入参数json对象看起来像
{
"fields": [
"string"
],
"filter": [
{
"comparison": "EQ",
"fieldName": "string",
"fieldValue": {},
"operation": "AND"
}
],
"pagination": {
"pageNumber": 0,
"pageSize": 0
},
"path": "string",
"sorts": [
{
"fieldName": "string",
"type": "ASC"
}
]
}
添加SwaggerConfig规则(其余返回响应实体,例如List<Map<String, Object>>
)
.alternateTypeRules(
AlternateTypeRules.newRule(
typeResolver.resolve(List.class, WildcardType.class),
typeResolver.resolve(Map.class, String.class, Object.class)
)
)
json对象看起来像
{
"fields": {
"additionalProp1": {},
"additionalProp2": {},
"additionalProp3": {}
},
"filters": {
"additionalProp1": {},
"additionalProp2": {},
"additionalProp3": {}
},
"pagination": {
"pageNumber": 0,
"pageSize": 0
},
"path": "string",
"sorts": {
"additionalProp1": {},
"additionalProp2": {},
"additionalProp3": {}
}
}
在更改SwaggerConfig规则后
typeResolver.resolve(List.class, Map.class),
typeResolver.resolve(Map.class, String.class, Object.class), Ordered.HIGHEST_PRECEDENCE
错误没有消失
遵循下一个配置规则:
typeResolver.resolve(List.class, WildcardType.class),
typeResolver.resolve(Map.class,
typeResolver.resolve(String.class, Object.class))
部署例外:
Factory method 'api' threw exception; nested exception is java.lang.IllegalArgumentException: Can not create TypeBinding for class java.lang.String with 1 type parameter: class expects 0
请帮帮我:
如何为List<Map<String, Object>>
配置规则选项?
为什么在配置中使用WildcardType
后,我的json看起来很奇怪?