[英]How we can add the request parameter in with url in swagger tool
我想在swagger ui中自定义输入文本框并测试其余服务,但在输入文本框中发送请求参数时,请求参数未附加服务ulr,例如curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' 'http://localhost:8765/COMMONAPI/V2.0/gameList'
请求param没有被添加,因此我得到空指针异常在此处 输入图像描述
我想要如下的确切要求
curl -X POST "http://localhost:8765/COMMONAPI/V2.0/gameList" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"timeStamp\": \"2019-03-18T05:11:15\", \"hashKey\": \"c0849bbf6eb17e48a72b92aa8f67650f\", \"apiKey\": \"72uyhsu87sf3\", \"apiId\": 6, \"sessionKey\": \"SdPpZI4LFTlux\"}"
在SwaggerConfiguration中,您可以定义用于传递参数的globalOperationParameters
。 像下面的东西。
@Bean
public Docket productApi() {
return new Docket(DocumentationType.SWAGGER_2)
.globalOperationParameters(Arrays.asList(new ParameterBuilder()
.name("token")
.description("Authentication token obtained after authentication.")
.modelRef(new ModelRef("string"))
.parameterType("header")
.required(true)
.build()))
.select()
.apis(RequestHandlerSelectors.basePackage("com.mypackage"))
.build();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.