inaka / cowboy_swagger

Swagger integration for Cowboy (built on trails)
http://inaka.net/blog/2015/08/19/cowboy-swagger/
Apache License 2.0
122 stars 58 forks source link

Open API servers field & swagger basePath filed #134

Closed DDDHuang closed 3 years ago

DDDHuang commented 3 years ago

Use GlobalSpec like

GlobalSpec = #{
        swagger => "2.0",
        info => #{title => "EMQ X API", version => "5.0.0"},
        basePath => "/v5/api"
}

or

GlobalSpec = #{
        openapi => "3.0.0",
        info => #{title => "EMQ X API", version => "5.0.0"},
        servers => [#{url => "http://localhost:8081/v5/api"}]
}

and trails as

trails() ->
    Metadata = #{get => #{any => any}},
    [{"/v5/api/my_api", Metadata}].

In swagger, execute will like

curl -X GET "http://localhost:8081/api/v5/api/v5/my_api"

The "/api/v5/api/v5" is double. Path should trans to without basePath or url def in GlobalSpec.

PR is in coming.