Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

yamole

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yamole

A YAML parser that resolves JSON references

  • 2.1.7
  • Source
  • PyPI
  • Socket score

Maintainers
1

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

Keywords

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc