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

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

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

报告相同问题?