@ApiOperation(value = "获取用户信息", notes = "userName:用户名{必传}, password:密码{必传} \n") @ApiImplicitParams({ @ApiImplicitParam(name = "userName", value = "用户名", required = true, dataType = "String", paramType = "query"), @ApiImplicitParam(name = "password", value = "密码", required = true, dataType = "String", paramType = "query") })
添加 required = true
来指定该参数必传
附swagger-ui的扫描配置
@Configuration // 注册成ioc组件 @EnableSwagger2 //开启swagger2 public class SwaggerConfig { // 扫描所有带@ApiOperation注解的类 @Bean public Docket api() { return new Docket(DocumentationType.SWAGGER_2) .select() .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) .build(); } }