Skip to main content

A YAML parser that resolves JSON references

Project description

yamole

Build Status PyPI package

Dig through the JSON references inside a YAML file, the kind of situation you may run into when parsing OpenAPI files.

The result is a single, big YAML file with all the references resolved (i.e. with their contents replaced in the corresponding places).

yamole also includes small features that help you parse OpenAPI files, like combining all the elements in an allOf key into a single object.

Installation

yamole is available as a PyPI module, so you can install it using pip:

$ pip install yamole

Usage

Using yamole is pretty straightforward. The parser is available through the YamoleParser class:

with open('input_file.yaml') as file:
    parser = YamoleParser(file,
        merge_allof=False,  # Combine allOfs into single dicts and disable
                            # inheritance for "example" keys (def: True)
        max_depth=314)  # Allow a maximum of 314 nesting levels (def: 1000)

output_str = parser.dumps()

parser.data['some-key']  # The dict with the parsed file's structure

Testing

To test that yamole works properly, you can run:

$ pip install -r requirements.txt
$ python tests/test.py

This will run the parser against a specific test case that makes use of all of yamole's features, and will compare the result with a fixture (tests/expected.yaml).


(c) 2018 Yago González. All rights reserved

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

yamole-2.1.7.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

yamole-2.1.7-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file yamole-2.1.7.tar.gz.

File metadata

  • Download URL: yamole-2.1.7.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.3

File hashes

Hashes for yamole-2.1.7.tar.gz
Algorithm Hash digest
SHA256 cd37040d1b396d58ac5bd9864999b98700d37156b2e65d9498486874aee38fda
MD5 2bd0d55e1abf8f5888c4869b9d64da2a
BLAKE2b-256 ce4888002005a87b6ceeab41cab0cb3db2634acfdca81be317cac19052ee4f36

See more details on using hashes here.

File details

Details for the file yamole-2.1.7-py3-none-any.whl.

File metadata

  • Download URL: yamole-2.1.7-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.3

File hashes

Hashes for yamole-2.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 f491345f18e9d4133eed196166136144e92bb4bad83e60d44ce5754adf130a36
MD5 3d91a7e5a49a41255ad8d74071495d3d
BLAKE2b-256 5a33f73c440c55ee3de59dd73eabcdd0b61a3a76d1d16b3e461bef4240af0188

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page