2016-09-19 16:32
浏览 985

在Swagger UI中更改Curl URL

I'm developing a new API using Slim Framework (v3). I'm trying to integrate this API with Swagger UI, but when I click "Try it" button, Swagger generates the following link.

Example link:


It's correct if I don't use Slim, but a link for Slim API is like:


What I want is that Swagger use a link to Slim API, how can I do to achieve that? I can't find a way to "translate" the link format.

I'm using Swagger-php for comments (annotations).

I hope you can help me. Thanks.

图片转代码服务由CSDN问答提供 功能建议

我正在使用Slim Framework(v3)开发一个新的API。 我正在尝试将此API与 Swagger UI,但当我点击“试试”按钮时,Swagger会生成以下链接。


  http:/  / localhost / api / public / contact?param1 = 1& param2 = 2param3 = 3 

如果我不使用Slim,那么这是正确的,但是Slim的链接 API类似于:

  http:// localhost / api / contact / 1/2/3 

我想要的是Swagger使用Slim API的链接,我该怎么做呢? 我找不到一种“翻译”链接格式的方法。


我希望你能帮助我。 谢谢。

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • doupao1978 2016-09-19 23:43

    You have a couple different options.

    First Swagger-ui won't show that link unless it's defined somewhere (i.e the basePath attribute) or left undefined. It sounds like there's something missing there.

    Next, you can always override the basePath in your API like such:


    Which should take away the /api/public section.

    It's a little difficult to debug without seeing your JSON or YAML swagger definition but those two techniques should get you over the hump.

    解决 无用
    打赏 举报

相关推荐 更多相似问题