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 (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.5.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

yamole-2.1.5-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: yamole-2.1.5.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for yamole-2.1.5.tar.gz
Algorithm Hash digest
SHA256 96df8d86c6660e5705993ce30d31350f98c1c6a7640c1e599984cd7c965aa35c
MD5 11a7948ba8f32a2f2df2df5705ed57ec
BLAKE2b-256 3a6fcdc9af2e0d8caa87c091b2b005d15d796013a3b57a65674afda4077c6e8c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for yamole-2.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 a9d014bbd62b863e94f37c57761013a7406479b94151310d3e954a420736b71b
MD5 54298560c4881413bf35545f9f2904ea
BLAKE2b-256 6d8b06e6179598d40cbca0a5027331864d723814932ece5a950f92b287730d43

See more details on using hashes here.

Supported by

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