swagger-api / validator-badge

Validate your Swagger JSON/YAML today!
http://swagger.io
Apache License 2.0
210 stars 85 forks source link

Get rid of downloading schema from http://swagger.io/v2/schema.json #188

Closed phamrak closed 2 years ago

phamrak commented 2 years ago

Schema file isn't accessible via browser ATM, get always redirected to https://schema.swagger.io/oauth/login.jsp. It's accessible for curl, for whatever reason. Anyway, the validation shouldn't be dependent on an external resource.

Improved exception handling. Exceptions are catched and the information is discarded. It's very hard to find out what's the root cause.

JonathanParrilla commented 2 years ago

Hello. Thank you for bringing this to our attention. We are looking into fixing this. In the mean time, both v2 and v3 schemas can be found here

https://schema.swagger.io/v2/schema.json https://schema.swagger.io/v3/schema.json

I will leave this issue open so I can update it once we've fixed swagger.io/v2/schema.json

frantuma commented 2 years ago

@phamrak thanks a lot for looking into this and for the PR. PR #189 includes and replaces this by keeping download of external schema but handling correctly schema processing with local schema.

Reason to keep attempt of loading the schema externally is to to maintain a single source of truth n terms of schemas for v2 and v3, and to match processing for v3.

As you mentioned, root cause of failure when schema URI is not/badly accessible is the schema validation library trying to access the URI (as URL) declared in id field of local schema, so even when local schema is used validation fails when online schema is not accessible at given URI, and removing the id fixes the issue.

(A more robust solution would include configuring the library providing a schema matching the URI..)

SIDE NOTE: The original cause of the error (schema URI not/badly accessible) has been fixed causing validator current version to work correctly again.

phamrak commented 2 years ago

@frantuma Thx for your effort. Have some questions

Question 1 One comment above are the 2x swagger URLs mentioned from @JonathanParrilla: https://schema.swagger.io/v2/schema.json https://schema.swagger.io/v3/schema.json

You kept the usage on http://swagger.io/v2/schema.json which is ATM redirecting to:

curl -I http://swagger.io/v2/schema.json
HTTP/1.1 301 Moved Permanently
Location: http://23.22.16.221/v2/schema.json

What URLs are now the correct one?

Question 2 Why is the swagger v3 schema loaded from file and swagger v2 loaded online?

Question 3 Could you describe more verbose what's behind:

A more robust solution would include configuring the library providing a schema matching the URI.
phamrak commented 2 years ago

@frantuma, @JonathanParrilla someone with answers to my questions above?