Skip to main content

pyspec2openapi

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 https://github.com/ethereum/consensus-specs/pull/3506

Usage

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 the ethereum/consensus-specs repo to fetch sources from
  • sources: 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 types BlindedBeaconBlockBody, BlindedBeaconBlock, and SignedBlindedBeaconBlock for a specific set of forks.
  • ignore_classnames: Ignore container code blocks with this list of names
  • exclude_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

Metadata

Release files for pyspec2openapi 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyspec2openapi 0.3.0
File Size Uploaded Provenance Actions
pyspec2openapi-0.3.0.tar.gz 6.9 kB Without provenance Details for pyspec2openapi-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pyspec2openapi 0.3.0
File Interpreter ABI Platform Actions
pyspec2openapi-0.3.0-py3-none-any.whl Python 3 none any Details for pyspec2openapi-0.3.0-py3-none-any.whl

Total release size: 14.7 kB

Release files / pyspec2openapi-0.3.0.tar.gz

Download URL pyspec2openapi-0.3.0.tar.gz
Size 6.9 kB
Tags Source
SHA-256 checksum
How to use checksums
a033c914791d26e9937c42fde1ec03ae45e121ec34c42c3bb2b0e3035bda5efe
BLAKE2b-256 checksum
How to use checksums
c5d9589ee7ef08a98cae51ff8992a5f46f9f8c239c707f8f79bff2ea27742567
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.12.1 Darwin/22.5.0

Release files / pyspec2openapi-0.3.0-py3-none-any.whl

Download URL pyspec2openapi-0.3.0-py3-none-any.whl
Size 7.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
81cc27e94cf233158a4e0a54f8b572e562fc853e95f6b05a21498bec6fd1070c
BLAKE2b-256 checksum
How to use checksums
82f954fe7b14eb61172dae42a6e8f53475e88d2270b27a2d78ace4279517e723
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.12.1 Darwin/22.5.0

Security for pyspec2openapi 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page