Sending dynamic custom headers in swagger UI try outs

最后都变了- 提交于 2020-01-01 02:41:29

问题


I am using swagger in java.

I am reading a header called callerId through requestAttributes in the code. I am not using the header through the annotation @HeaderParam.

because of this reason, the header section is not showing up in the swagger UI for try outs.

How can I make this header show up in the try out form.

Is there any way I can achieve this without hard coding the header value.

Thanks in advance.


回答1:


You can add parameters to an operation using @ApiImplicitParams and @ApiImplicitParam.

The following wiki documentation should provide you with an explanation on how to use these annotations - https://github.com/swagger-api/swagger-core/wiki/Annotations#apiimplicitparam-apiimplicitparams

Keep in mind I assume here that this is not a security header but actually part of the API (at least based on the description you gave). If you're looking for a security header, there's an alternative method. Please leave a comment and I'll edit this response.



来源:https://stackoverflow.com/questions/26742521/sending-dynamic-custom-headers-in-swagger-ui-try-outs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!