测试之后发现是因为Map<Long,List<CommentVO>>的返回值类型的锅,改成Page<List<CommentVO>>即可解决。
前端使用的umiMAX的openapi,报错如下:
' originalRef: BaseResponse<<boolean>>\n' +
' "401":\n' +
' description: Unauthorized\n' +
' "403":\n' +
' description: Forbidden\n' +
' "404":\n' +
' description: Not Found\n' +
' deprecated: false\n' +
' x-order: "2147483647"\n' +
' "/api/admin/passage/reject/{passageId}":\n' +
' get:\n' +
' tags:\n' +
' - admin-passage-controller\n' +
' summary: rejectPassage\n' +
' operationId: rejectPassageUsingGET\n' +
' produces:\n' +
' - "*/*"\n' +
' parameters:\n' +
' - name: passageId\n' +
' in: path\n' +
' description: passageId\n' +
' '... 78804 more characters,
externals: [],
externalRefs: {},
rewriteRefs: true,
preserveMiro: true,
promise: { resolve: [Function (anonymous)], reject: [Function (anonymous)] },
patches: 0,
cache: {},
openapi: {
openapi: '3.0.0',
info: {
description: '无问青秋博客',
version: 'v1.0',
title: 'Serein博客API接口测试',
contact: {}
},
tags: [
{ name: 'admin-category-controller', 'x-order': '2147483647' },
{ name: 'admin-comment-controller', 'x-order': '2147483647' },
{ name: 'admin-passage-controller', 'x-order': '2147483647' },
{ name: 'admin-tag-controller', 'x-order': '2147483647' },
{ name: 'admin-user-controller', 'x-order': '2147483647' },
{ name: 'category-controller', 'x-order': '2147483647' },
{ name: 'comment-controller', 'x-order': '2147483647' },
{ name: 'passage-controller', 'x-order': '2147483647' },
{ name: 'tag-controller', 'x-order': '2147483647' },
{ name: 'user-controller', 'x-order': '2147483647' }
],
paths: {
'/api/admin/category/addCategory': {
post: {
tags: [Array],
summary: 'addCategory',
operationId: 'addCategoryUsingPOST',
requestBody: [Object],
responses: [Object],
responsesObject: [Object],
deprecated: false,
'x-order': '2147483647'
}
},
前端openapi生成接口报错
preserveMiro: true,
promise: { resolve: [Function (anonymous)], reject: [Function (anonymous)] },
patches: 0,
cache: {},
openapi: {
openapi: '3.0.0',
info: {
description: '无问青秋博客',
version: 'v1.0',
title: 'Serein博客API接口测试',
contact: {}
},
tags: [
{ name: 'admin-category-controller', 'x-order': '2147483647' },
{ name: 'admin-comment-controller', 'x-order': '2147483647' },
{ name: 'admin-passage-controller', 'x-order': '2147483647' },
{ name: 'admin-tag-controller', 'x-order': '2147483647' },
{ name: 'admin-user-controller', 'x-order': '2147483647' },
{ name: 'category-controller', 'x-order': '2147483647' },
{ name: 'comment-controller', 'x-order': '2147483647' },
{ name: 'passage-controller', 'x-order': '2147483647' },
{ name: 'tag-controller', 'x-order': '2147483647' },
{ name: 'user-controller', 'x-order': '2147483647' }
],
paths: {
'/api/admin/category/addCategory': {
post: {
tags: [Array],
summary: 'addCategory',
operationId: 'addCategoryUsingPOST',
requestBody: [Object],
responses: [Object],
responsesObject: [Object],
deprecated: false,
'x-order': '2147483647'
}
},
'/api/admin/category/delete/{categoryId}': {
put: {
tags: [Array],
summary: 'deleteCategory',
operationId: 'deleteCategoryUsingPUT',
parameters: [Array],
responses: [Object],
responsesObject: [Object],
deprecated: false,
'x-order': '2147483647'
}
},
'/api/admin/comment/getComments/': {
post: {
tags: [Array],
summary: 'getComments',
operationId: 'getCommentsUsingPOST',
requestBody: [Object],
responses: [Object],
responsesObject: [Object],
deprecated: false,
'x-order': '2147483647'
}
},
'/api/user/userInfoData': {
get: {
tags: [Array],
summary: 'getUserInfoData',
operationId: 'getUserInfoDataUsingGET',
responses: [Object],
responsesObject: [Object],
deprecated: false,
'x-order': '2147483647'
}
}
},
'x-openapi': {
'x-markdownFiles': null,
'x-setting': {
language: 'zh-CN',
enableSwaggerModels: true,
swaggerModelName: 'Swagger Models',
enableReloadCacheParameter: false,
enableAfterScript: true,
enableDocumentManage: true,
enableVersion: false,
enableRequestCache: true,
enableFilterMultipartApis: false,
enableFilterMultipartApiMethodType: 'POST',
enableHost: false,
enableHostText: '',
enableDynamicParameter: false,
enableDebug: true,
enableFooter: true,
enableFooterCustom: false,
enableSearch: true,
enableOpenApi: true,
enableHomeCustom: false,
enableGroup: true,
enableResponseCode: true
}
},
servers: [ { url: '//127.0.0.1:8081/api' } ],
components: {
requestBodies: {
QueryPageRequest: {
content: [Object],
description: 'queryPageRequest',
required: true
},
uploadPassageCoverUsingPOST: { content: [Object], required: true }
},
schemas: {
AddPassageDTO: {
type: 'object',
properties: [Object],
title: 'AddPassageDTO'
},
GetUserByIdListRequest: {
type: 'object',
properties: [Object],
title: 'GetUserByIdListRequest'
},
LoginRequest: {
type: 'object',
properties: [Object],
title: 'LoginRequest'
},
LoginUserVO: {
type: 'object',
properties: [Object],
title: 'LoginUserVO'
},
Page_List_UserVO_: {
type: 'object',
properties: [Object],
title: 'Page<<List<<UserVO>>>>'
}
}
}
},
fetch: <ref *1> [Function: fetch] {
isRedirect: [Function (anonymous)],
Promise: [Function: Promise],
default: [Circular *1],
Headers: [class Headers],
Request: [class Request],
Response: [class Response],
FetchError: [Function: FetchError]
},
resolver: { depth: 0, base: undefined, actions: [ [] ] },
refmap: {}
}
}
Node.js v20.10.0