Tool to convert the types defined in the Ethereum python specs https://github.com/ethereum/consensus-specs to an OpenAPI definition, for https://github.com/ethereum/beacon-APIs. This tool facilitates manteinance of the OpenAPI spec and follows the canonical JSON mapping from ethereum/consensus-specs#3506
Install from PyPI
pip install pyspec2openapi
Create a config.yml
file
spec_version: v1.4.0-beta.5
sources:
phase0:
- {spec: beacon-chain.md}
- {spec: validator.md}
- {file: extra_types/phase0.md}
altair:
- {spec: beacon-chain.md}
- {spec: validator.md}
- {spec: light-client/sync-protocol.md}
- {file: extra_types/altair.md}
bellatrix:
- {spec: beacon-chain.md}
- {spec: validator.md}
- {file: extra_types/bellatrix.md}
capella:
- {spec: beacon-chain.md}
- {spec: validator.md}
- {spec: light-client/sync-protocol.md}
deneb:
- {spec: polynomial-commitments.md}
- {spec: beacon-chain.md}
- {spec: validator.md}
- {spec: p2p-interface.md}
- {spec: light-client/sync-protocol.md}
- {file: extra_types/deneb.md}
generate_blinded_types: [bellatrix, capella, deneb]
ignore_classnames:
- LightClientStore
exclude_comments:
- '\[New [^\]]*\]'
- '\[Modified [^\]]*\]'
spec_version
: Specific Github tag from theethereum/consensus-specs
repo to fetch sources fromsources
: Topologically sorted list of fork and files to fetch types from. This tool can topologically sort types within the same markdown file, but not across them.generate_blinded_types
: Auto-generate the typesBlindedBeaconBlockBody
,BlindedBeaconBlock
, andSignedBlindedBeaconBlock
for a specific set of forks.ignore_classnames
: Ignore container code blocks with this list of namesexclude_comments
: Ignore comments for container properties that match any of this regex
Generate types spec
pyspec2openapi config.yml out.yml
Review an example output with an example config in ./pyspec2openapi/tests/example_specs_out.yml