doucou1892 2016-09-19 16:32
浏览 1361
已采纳

在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:

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

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

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

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.

  • 写回答

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:

    window.swaggerUi.api.setBasePath('/api');

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?