We have an API exposed and it produces a swagger document similar to below using the following URL:
http://<server>/api
Produces:
{
“swagger”: “2.0”,
“info”: {
“version”: “1.0.0”,
“title”: “CEPAVendorSpecificInterface”
},
“basePath”: “/api”,
“consumes”: [
“application/json”
],
…
This works fine when running locally, but we’re deploying it to a server using Kubernetes and Ingress, in which case the URL becomes:
https://<server>/cepavsi/api
This returns the exact same swagger document, and our automated test software fails our tests with the error “Swagger Compliance Assertion”.
So ideally the basepath could be change to reflect the new URL. To do this, I tried the following:
server.ApiDispatcher.Path = "/cepavsi/api/";
But then the URL for accessing the server, because of Ingress, duplicates cepavsi and becomes:
https://localhost/cepavsi/cepavsi/api/
Which returns the following:
{
“swagger”: “2.0”,
“info”: {
“version”: “1.0.0”,
“title”: “CEPAVendorSpecificInterface”
},
“basePath”: “/cepavsi/api”,
“consumes”: [
“application/json”
],
…
Is there a way to change the Swagger document to match the “basePath” exposed by the Ingress controller as “/cepavsi/api” but still serve “/api”?
Tim