-
-
Notifications
You must be signed in to change notification settings - Fork 266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BeaconAPI Spec Conformance #4063
Comments
Related to #3682 Tests should download the OpenAPI spec and assert responses follow its format |
I ended up reaching for Ajv to perform the validation of response object against the schema, but the problem is, the beacon-api spec does not have any of the properties of the response objects as required. This makes it impossible (or convoluted) to perform a strict validation because a response object that misses any of the properties would still pass the validation check. Does anyone know if it was a conscious design choice not marking the properties of the response object? |
@dadepo SSZ fromJson already does property validation for all important data structures on the ingress side at runtime To ensure we conform with the spec on output, just generate testers from the OpenAPI schema and via tests check that we conform to that spec at test runtime |
@dapplion do you by chance have any tool in mind that does this? The ones I see are for either generating client libraries from the OpenAPI schema, or this paid tool that offers help with testing. The only way I found to validate the response is to use a tool like Ajv to check that the response from the API conforms to the OpenAPI spec. |
https://www.google.com/search?q=openapi+to+json+schema+converter https://github.com/openapi-contrib/openapi-schema-to-json-schema Using generated client libraries may also work but may be more complicated |
This does not generate testers though, but converts OpenAPI 3.0 to JSON Schema Draft 4. The output of the conversion, can't also be used directly for comparison in tests. As the tests needs to validate that the json returned by the API is the same as what is specified in the spec.
I'll check this out but I am not sure how that will work, The client libraries will be generated client code that calls the API, they might not have facility to validate the response. And we do not need client code to call the api as we have that already in lodestar itself. |
Closing for now, tho note there is still work to do to ensure Lodestar logically conforms to the spec. |
Describe the bug
There are spec conformance issues in the BeaconAPI json-rpc endpoint.
Expected behavior
Steps to Reproduce
Use the json-rpc endpoint.
Screenshots
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: