apinf / platform

Apinf - Open source API management platform with multi proxy and protocol support
https://apinf.com/
European Union Public License 1.1
74 stars 33 forks source link

Base URL for swagger document is not formed correctly #3229

Open matleppa opened 6 years ago

matleppa commented 6 years ago

Background

When a swagger document is added as a documentation on API card, there is automatically formed Base URL for swagger, which is used, when swagger generates call for methods.

API is connected to a proxy

The base URL for swagger is same as the proxy base path. OK functionality: This means, that when requests are sent using swagger document, they are correctly targeted to the API.

API is not connected to a proxy

The base URL for swagger is formed depending on the documentation address. Erronous functionality: In this case the requests sent with swagger are targeted to HTTP address, from where the documentation was loaded, not to API address.

Conclusion

The Base URL for swagger should always be same as the API address, so the method calls are sent to the API in question.

matleppa commented 6 years ago

API connected to a proxy (Correct)

API address (via proxy). api_proxy_detail.PNG The base URL for swagger is formed using API address. api_proxy_swag.PNG The request is sent to API address. api_proxy_curl.PNG

matleppa commented 6 years ago

API not connected to a proxy, doc from file (forming incorrect address for requests

API: https://nightly.apinf.io/apis/aaa2-new-api

The API address api_no_proxy_detail.PNG

The Base URL is formed of the location, from where the documentation was loaded. Erroneous api_no_proxy_swag.PNG

The request is sent to address, from where the documentation was loaded, not to API address. Erronous api_no_proxy_curl.PNG

matleppa commented 6 years ago

API, no proxy, doc from other server as link (forming incorrect address for requests)

API: https://nightly.apinf.io/apis/aaa-new-api

The API is located on Nightly. api_no_proxy_detail.PNG

The documentation is linked from another server (here Staging). The Base URL for swagger is formed based on documentation location. api_no_proxy_link_swag.PNG The requests from swagger are sent to address, from where the documentation was linked, not to API address. api_no_proxy_link_curl.PNG

marla-singer commented 6 years ago

@matleppa it isn't obviously what doesn't work correctly in screens. Write expected/actual result for each one

And if you test it on nightly/staging/production then provide a link to API

marla-singer commented 6 years ago

The requests from swagger are sent to address, from where the documentation was linked, not to API address. api_no_proxy_link_curl.PNG

Actually, it works as expected. Why does it have to request to API address? I don't understand.

matleppa commented 6 years ago

My understanding is, that the point of using swagger documentation is ability to test the API functionality: The swagger UI builds the request message, sends it and displays the response, either successful or unsuccessful.

If the request message is not sent to API address, how can user verify API functionality?

marla-singer commented 6 years ago

that the point of using swagger documentation is ability to test the API functionality

In the case then API is connected to Proxy.

@kyyberi What do you think?

matleppa commented 6 years ago

What I'm saying is that Swagger should send the request to same API address, which is visible on API card, on tab Details, so it is either APIs own address or the proxy address. Nevertheless, the request should be sent to API, not to address of documentation.

Nazarah commented 6 years ago

This would be fixed simultaneously when the other documentation related changes are made in the Merged Next branch. Iceboxing for the time being.