-
Notifications
You must be signed in to change notification settings - Fork 169
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
Derive OpenAPI type schema from pyspec #402
Comments
ooh, great stuff! 👍 from me, was hoping it would lead to this. |
It would be good to maintain the script either in this repo or another repo under |
Sounds good, will look how to integrate it without polluting this repo too much. @rolfyone thoughts? |
Can we have the conversion script in this repo or in consensus-specs and just run it during build or something? or produce something in consensus-specs as part of that build that we then ingest would be ideal maybe? It looks like we're stripping out a bunch of types, can we just ingest it and ignore the types we dont need or something? I like the direction, agree polluting this repo would be less than ideal |
I don't think we should pollute the spec tests, since this is purely derivative it should leave in this repo
There may be some types that are un-used but looks like the minority. For that we should either maintain and opt-in list or an exclusion list. Is it worth the effort to have a few less lines? |
If we can just ingest the spec and it works, then the extra objects are pretty un-important, does make it easy when we add endpoints... The only thing would be if people get annoyed at unused objects if they cause issues in code generation maybe? |
https://redocly.com/docs/cli/commands/bundle/ offers a |
Thanks to ethereum/consensus-specs/pull/3506 we have canonical mapping of SSZ -> YAML, so it is possible to derive OpenAPI schemas for all the spec types.
Since the vast majority of API types are spec types auto-deriving the types would reduce future fork development and maintenance. Plus it paves the way to SSZ-ing most API routes.
We can define API-only extra types in SSZ syntax, such as:
Current status
I've created a simple python script to translate the pyspec to OpenAPI schemas https://pypi.org/project/pyspec2openapi. Here is a demo integration into the beacon-APIs repo dapplion#1
The diff is quite large since it merges all types into a single output file.
One can compare the bundled outputs with
The bundled diff is also quite substantial due to some key characteristics
beacon-APIs/types/block.yaml
Line 24 in 4882aa0
Next steps
If yes, decide how to merge
The text was updated successfully, but these errors were encountered: