Using swagger documentation Tool on a private domain

Hello,

I am using the swagger documentation tool, but when I navigate to the page, my api is flagged as invalid.

Here is an example of the call that the api-tools-documentation-swagger makes, and responses with an http return code 302.

This seems to be because my development domain is not publicly accessible, and never will be. and this makes sense. I would still like to work on the documentation in my development environment first though, rather than on a publicly accessible domain.

Would anyone have any advise on if it is possible to install this validator locally, and configure api-tools to use it instead of the online one?

Why do you think it needs an online connection? Are there requests to any external resources?

Seems to be, it calls this:
https://validator.swagger.io/validator?url=
and gives a 302 as it can’t connect to my domain

I see this in swaggerui.js:

There does seem to be some way to override the validatorUrl.

@ezkimo
Can you help here?

(I do not use the laminas-api-tools.)

Seems to be a swagger configuration issue. The swagger doc says:

String="https://validator.swagger.io/validator" OR null. By default, Swagger UI attempts to validate specs against swagger.io’s online validator. You can use this parameter to set a different validator URL, for example for locally deployed validators (Validator Badge). Setting it to either none, 127.0.0.1 or localhost will disable validation.

In case you 're using locally deployed validators you have to define the right url here. If you want to disable the swagger validation set the validatorUrl to localhost or 127.0.0.1. The Validator Badge repository states out, that you can pull a docker image for local usage.

1 Like