SpaceAPI Validator v3 API #71
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In #70 I proposed an amendment to the validator API v2 to add support for separate IPv6 and IPv4 checks as well as HTTP status codes. After some initial feedback and further thought I realized that a new major version of the validatorAPI might be the better approach. Therefore, I had closed #70 and started work on drafting a specification for a v3 API.
Even though I have already added an (so far still incomplete) implementation of the proposed v3 API, since it didn't require too much change from v2 in the server code, I would like to first focus discussion on the API specification itself.
The major changes between v2 and my proposal for v3 are:
ValidateJsonV3Responsecomponent makes themessagekey optional (see v2: Message field in response #50). However, thecheckedVersionskey becomes required (though it may be empty in case the validated JSON file did not actually declare compliance with any supported schema version)./v3/validateURLcan perform multiple validation runs using multiple parameters. The parameters currently included in my draft are:IPv6,IPv4, orany): "any" describes the same behavior as the current v2 implementation, which just leaves protocol selection up to the network stack. However, doing validation once via IPv6 and once via IPv4 allows us to discover hard to reproduce endpoint issues related to one address family only.ValidateUrlV3component adds two new keys:extendedValidation: If true, instruct the validator to perform "extended validation" (such as IP dual stack testing, or testing with different user agent strings). The exact set of additional validation scenarios is implementation dependent.withValidatedJson: If false, instruct the validator not to return the JSON body of the SpaceAPI endpoint that is being validated.ValidateUrlV3Responsecomponent: Most fields were removed from the component itself, and moved to the newly introducedValidateUrlV3Resultcomponent, which the response contains a list of. TheValidateUrlV3Resultcomponent is effectively whatValidateUrlV2Responsecurrently is in V2. EachValidateUrlV3Resultdescribes the validation result under a certain set of parameters (at the moment: IP address family and user agent). The parameters themselves are contained in the result as well asValidateUrlV3Parameters.valid,checkedVersions,message,schemaErrors) are removed fromValidateUrlV3Result, and are moved to an instance ofValidateJsonV3Responseembedded inValidateUrlV3Result.ValidateUrlV3Resultalso adds some new fields not present inValidateUrlV2Response:This PR also includes the addition of a swagger UI for the validator API.
I'm aware that this adds quite a bit of complexity to the validator API, however, I think this allows us to both improve validation and use the validator results for a few more use cases:
410 Goneconsistently for $time", or "update endpoint URLS that have served permanent redirects consistently for $time".I'd be happy to get some feedback on my proposal.
/v3/validateURLextended validation usage examplecurl -XPOST http://127.0.0.1:8080/v3/validateURL -H 'Content-Type: application/json' -d '{"url":"http://spaceapi.kabelsalat.ch","extendedValidation":true,"withValidatedJson":false}' | jq { "results": [ { "parameters": { "addressFamily": "ipv6", "userAgent": "SpaceApi Validator/1.3.0 (https://github.com/SpaceApi/validator)" }, "originalUrl": "http://spaceapi.kabelsalat.ch", "redirectedUrl": "https://spaceapi.kabelsalat.ch/", "reachable": true, "httpStatus": 200, "isHttps": false, "httpsRedirect": true, "permanentRedirect": true, "cors": true, "contentType": true, "invalidCert": false, "validation": { "valid": true, "checkedVersions": [ "14", "15", "16" ] } }, { "parameters": { "addressFamily": "ipv4", "userAgent": "SpaceApi Validator/1.3.0 (https://github.com/SpaceApi/validator)" }, "originalUrl": "http://spaceapi.kabelsalat.ch", "redirectedUrl": "https://spaceapi.kabelsalat.ch/", "reachable": true, "httpStatus": 200, "isHttps": false, "httpsRedirect": true, "permanentRedirect": true, "cors": true, "contentType": true, "invalidCert": false, "validation": { "valid": true, "checkedVersions": [ "14", "15", "16" ] } }, { "parameters": { "addressFamily": "any", "userAgent": "curl/8.16.0" }, "originalUrl": "http://spaceapi.kabelsalat.ch", "redirectedUrl": "https://spaceapi.kabelsalat.ch/", "reachable": true, "httpStatus": 200, "isHttps": false, "httpsRedirect": true, "permanentRedirect": true, "cors": true, "contentType": true, "invalidCert": false, "validation": { "valid": true, "checkedVersions": [ "14", "15", "16" ] } }, { "parameters": { "addressFamily": "any", "userAgent": "Go-http-client/1.1" }, "originalUrl": "http://spaceapi.kabelsalat.ch", "redirectedUrl": "https://spaceapi.kabelsalat.ch/", "reachable": true, "httpStatus": 200, "isHttps": false, "httpsRedirect": true, "permanentRedirect": true, "cors": true, "contentType": true, "invalidCert": false, "validation": { "valid": true, "checkedVersions": [ "14", "15", "16" ] } } ], "reachable": true, "valid": true }