On our QA and Prod networks that run our RESTful web services, port 80 is not open. Therefore, currently, when I try to get to the Swagger user interface in QA, I get this message and it just hangs:
fetching resource list: http://qa-server:80/product-catalog-api/swagger/docs/v1; Please wait.
I use Swashbuckle to configure Swagger. I also changed this line in the config, but it still does not work.
// If schemes are not explicitly provided in a Swagger 2.0 document, then the scheme used to access // the docs is taken as the default. If your API supports multiple schemes and you want to be explicit // about them, you can use the "Schemes" option as shown below. // c.Schemes(new[] { "https" });
The SSL port 443 is open, so I would like to access the Swagger interface. I can manually change http://qa-server:80/product-catalog-api/swagger/docs/v1 to https://qa-server/product-catalog-api/swagger/docs/v1 and then Swagger will be enumerate my web methods, but it freezes when I click Try it out! This is the console output: SCRIPT5: Access is denied. File: swagger-ui-min-js, Line: 10, Column: 4300 SCRIPT5: Access is denied. File: swagger-ui-min-js, Line: 10, Column: 4300
EDIT:
So, I delved even more and got a little further, but still not where I want. If I look at the source in the Swagger index.html file, I see a problem:
window.swashbuckleConfig = { rootUrl: 'http://qa-server:80/product-catalog-api', discoveryPaths: arrayFrom('swagger/docs/v1'), booleanValues: arrayFrom('true|false'), validatorUrl: stringOrNullFrom('null'), customScripts: arrayFrom(''), docExpansion: 'none', oAuth2Enabled: ('false' == 'true'), oAuth2ClientId: '', oAuth2ClientSecret: '', oAuth2Realm: '', oAuth2AppName: '', oAuth2ScopeSeperator: ' ', oAuth2AdditionalQueryStringParams: JSON.parse('{}') };
Despite the fact that I go to the site as https and have the Swashbuckle scheme set to https, it still generates rootUrl as http. I think that since I use Swashbuckle, I should use it to configure index.html because I don't have this file anywhere in my code, so I think Swashbuckle generates it on the fly.
I found out what I am missing when changing the swagger.json path. Apparently he needs a port number. Therefore, if I go to the swagger indexing page and manually change the path to the json file as https://qa-server:443/product-catalog-api/swagger/docs/v1 , everything will be fine. So now, I think I highlighted the problem before changing rootUrl in Swaggers index.html using Swashbuckle.
EDIT 2
Well, I think I configured Swashbuckle correctly because it correctly generates index.html on our dev server, but not qa, so I think the rest of the problem comes down to some difference in the environments or my package did not get installed correctly in qa.
DEV:
window.swashbuckleConfig = { rootUrl: 'https://server-dev:443/product-catalog-api', discoveryPaths: arrayFrom('swagger/docs/v1'), booleanValues: arrayFrom('true|false'), validatorUrl: stringOrNullFrom('null'), customScripts: arrayFrom(''), docExpansion: 'none', oAuth2Enabled: ('false' == 'true'), oAuth2ClientId: '', oAuth2ClientSecret: '', oAuth2Realm: '', oAuth2AppName: '', oAuth2ScopeSeperator: ' ', oAuth2AdditionalQueryStringParams: JSON.parse('{}') };
QA:
window.swashbuckleConfig = { rootUrl: 'http://qa-server:80/product-catalog-api', discoveryPaths: arrayFrom('swagger/docs/v1'), booleanValues: arrayFrom('true|false'), validatorUrl: stringOrNullFrom('null'), customScripts: arrayFrom(''), docExpansion: 'none', oAuth2Enabled: ('false' == 'true'), oAuth2ClientId: '', oAuth2ClientSecret: '', oAuth2Realm: '', oAuth2AppName: '', oAuth2ScopeSeperator: ' ', oAuth2AdditionalQueryStringParams: JSON.parse('{}') };
EDIT 3
We conducted a test to further isolate the problem. We have an A10 load balancer in our QA environment. We raised the new A10 for the development environment to find out what happened, and now we have the same problem in dev. A10 did some manipulation of the http headers that we removed to see if this was a problem, but still got the same thing. I believe that the servers are configured, SSL is uploaded to A10, and http gets into the field on which my code works. Therefore, when the Swashbuckle code works, it works under http, causing a problem. I think I need a way to make it always be https.