在swagger UI中发送动态自定义标头试用 [英] Sending dynamic custom headers in swagger UI try outs

查看:283
本文介绍了在swagger UI中发送动态自定义标头试用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在java中使用swagger。

I am using swagger in java.

我正在通过代码中的requestAttributes读取名为callerId的头文件。我没有通过注释@HeaderParam使用标题。

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

因为这个原因,标题部分没有显示在swagger UI中用于试用。

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.

提前致谢。

推荐答案

您可以使用@ApiImplicitParams和@ApiImplicitParam为操作添加参数。

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

以下wiki文档应该为您提供有关如何使用这些注释的说明 - https://github.com/swagger-api/swagger-core/wiki/Annotations#apiimplicitparam-apiimplicitparams

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

请记住,我在此假设这不是安全标头,但实际上是API的一部分(至少基于您给出的描述)。如果您正在寻找安全标头,那么还有另一种方法。请留言,我会编辑此回复。

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.

这篇关于在swagger UI中发送动态自定义标头试用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆