Closed foxmale007 closed 6 months ago
采用form表单格式的参数,好像生成的前端文档Param定义为空的。 @ApiImplicitParams({ @ApiImplicitParam(name = "loginId", value = "管理员登录ID [maxlength=18]", required = true, dataTypeClass = String.class, paramType = "body"), @ApiImplicitParam(name = "userPsw", value = "用户密码 [maxlength=20]", required = true, paramType = "body"), @ApiImplicitParam(name = "validateCode", value = "页面验证码 [maxlength=4]", required = true, paramType = "body"), @ApiImplicitParam(name = "sid", value = "页面会话ID,建议由uuid请求生成或者页面随机算法生成uuid,需要与页面验证码servlet请求的一致", required = true, paramType = "body") })
public String doLogin(String loginId, String userPsw, String validateCode, String sid,@ApiIgnore RequestSite adminSite, HttpServletResponse response) { 。。。 }
生成的api文档没有Param部分,POST请求的话paramType 是form或body都没有生成,只有query方式可以。另外如果controller采用对象的方式也可以,不知道怎样才能正确支持form post格式
使用的是swagger2.9
我又写了个更简单的例子: @PostMapping("testPost") @ApiOperation(value = "后台管理员登录aaaa") public String testPost( @ApiParam("登录ID--》") String loginId, String userPsw, String validateCode, String sid,@ApiIgnore RequestSite adminSite, HttpServletResponse response){ return loginId + " " + userPsw; }
生成结果: /**
/admin/common/testPost */ export namespace testPost { export class Params { / sid */ sid?: string /* userPsw / userPsw?: string / validateCode */ validateCode?: string }
export type Response = string
export const init: Response
export function request(params: Params, body: string, options?: any): Promise } 其中使用@ApiOperation标注的参数生成不了,我不想每个请求都定义一个request对象,有的请求比较简单,我希望直接传参数到controller方法发现这种方式的参数不会带入Param部分
找到问题了,pont的param这里只处理query类型的参数,原来是这个问题导致
采用form表单格式的参数,好像生成的前端文档Param定义为空的。 @ApiImplicitParams({ @ApiImplicitParam(name = "loginId", value = "管理员登录ID [maxlength=18]", required = true, dataTypeClass = String.class, paramType = "body"), @ApiImplicitParam(name = "userPsw", value = "用户密码 [maxlength=20]", required = true, paramType = "body"), @ApiImplicitParam(name = "validateCode", value = "页面验证码 [maxlength=4]", required = true, paramType = "body"), @ApiImplicitParam(name = "sid", value = "页面会话ID,建议由uuid请求生成或者页面随机算法生成uuid,需要与页面验证码servlet请求的一致", required = true, paramType = "body") })
public String doLogin(String loginId, String userPsw, String validateCode, String sid,@ApiIgnore RequestSite adminSite, HttpServletResponse response) { 。。。 }
生成的api文档没有Param部分,POST请求的话paramType 是form或body都没有生成,只有query方式可以。另外如果controller采用对象的方式也可以,不知道怎样才能正确支持form post格式
使用的是swagger2.9
我又写了个更简单的例子: @PostMapping("testPost") @ApiOperation(value = "后台管理员登录aaaa") public String testPost( @ApiParam("登录ID--》") String loginId, String userPsw, String validateCode, String sid,@ApiIgnore RequestSite adminSite, HttpServletResponse response){ return loginId + " " + userPsw; }
生成结果: /**
/admin/common/testPost */ export namespace testPost { export class Params { / sid */ sid?: string /* userPsw / userPsw?: string / validateCode */ validateCode?: string }
export type Response = string
export const init: Response
export function request(params: Params, body: string, options?: any): Promise
}
其中使用@ApiOperation标注的参数生成不了,我不想每个请求都定义一个request对象,有的请求比较简单,我希望直接传参数到controller方法发现这种方式的参数不会带入Param部分