I created Swagger UI docs using Swagger Editor for my APIs which are hosted on a private AWS EC2 instance. The VM is private and Swagger isn't able to validate my URL and hence I'm getting this error on my Swagger UI webpage:
{"schemaValidationMessages":[{"level":"error","message":"Can't read from file https://xx.xx.xxx.xx:9001/static/swagger.json"}]}
I converted the YAML that got generated from Swagger Editor into swagger.json and used the flask_swagger_ui
Python library to link the swagger.json with my API code. This swagger.json is the only Swagger-related file I have and I didn't use any .html or .config files. I realised if I set ValidatorURL: null
then the abovementioned error will stop but where do I add that flag/parameter in the swagger.json (Swagger YAML design) file? Other resources mention adding ValidatorURL: null
in the .html file but I don't have any such file. What do I do?
CodePudding user response:
validatorUrl
is a Swagger UI config option. In flask_swagger_ui
, you can set this option as follows:
swaggerui_blueprint = get_swaggerui_blueprint(
SWAGGER_URL,
API_URL,
config={
'validatorUrl': 'none'
},
...
)