API需要额外的
header
method.additional.header={name: "Authorization",value: "",desc: "认证Token",required:true, example:""}
package com.itangcent.common.annotation;
/**
* 声明接口为公开接口
*/
@Documented
@Retention(RUNTIME)
@Target({TYPE, METHOD})
public @interface Public {
}
method.additional.header[!@com.itangcent.common.annotation.Public]={name: "Authorization",value: "",desc: "认证Token",required:true}
method.additional.header[groovy:!it.hasAnn("com.itangcent.common.annotation.Public")]={name: "Authorization",value: "",desc: "认证Token",required:true}
/**
* Mock Apis
*/
@RestController
@RequestMapping(value = "mock")
public class MockCtrl {
/**
* public api
* Token is not required
*/
@Public
@GetMapping("/apiWithoutToken")
public Result<String> apiWithoutToken() {
return Result.success("no token");
}
/**
* private api
* Token is required
*/
@GetMapping("/apiWithToken")
public Result<String> apiWithToken() {
return Result.success("wow,you got a token");
}
}
method.additional.header[groovy:it.containingClass().name().startsWith("com.test.api")]={name: "Authorization",value: "",desc: "认证Token",required:true}
method.additional.header[groovy:!it.containingClass().name().startsWith("com.test.api")]={name: "Authorization",value: "",desc: "认证Token",required:true}
method.additional.header[groovy:it.containingClass().name().startsWith("com.test.api")]={name: "a",value: "",desc: "",required:true}
method.additional.header[groovy:it.containingClass().name().startsWith("com.test.api")]={name: "b",value: "",desc: "",required:true}