Skip to main content

deforest

PyPI version Build Status

Remove all x-amazon-tags from your Open API 3 or Swagger 2 specification. Useful if you are using Cloudformation to specify your API Gateways, and want to provide your consumers with the same specification but not wanting to disclose your internal Amazon integrations.

Installation

pip install --user deforest

Features

  • Clean keys starting with the string x-amazon
  • Handles JSON and YAML input
  • Handles JSON and YAML output (defaults to YAML)
  • Support for AWS CloudFormation templates
    • AWS::ApiGateway::RestApi resource type
    • AWS::Serverless::Api resource type

Usage

Usage: deforest [OPTIONS] INFILE

Options:
  -o, --outfile TEXT        specify output file, default is
                            ./<title>-<version>.<format>, ignored if input is
                            a CloudFormation template and the template
                            contains more than one ApiGateway resource)
  -f, --format [yaml|json]  output format  [default: yaml]
  -i, --indent INTEGER      if output format is json, specify indentation
  -d, --debug               if enabled, show debug logs
  --no-ignore               if set, deforest will export paths marked as
                            ignored
  --version                 Show the version and exit.
  --help                    Show this message and exit.

CloudFormation templates

Version 0.1.1 and later supports CloudFormation templates as input. If more than one API Gateway is part of the template, the --outfile flag will be ignored.

Hide paths

Version 0.2.0 introduced support for deforest to ignore certain paths. If you specify x-deforest-ignore: true anywhere in your specification, deforest will not extract its parent node to the end results. Example:

paths:
  "/validation":
    post:
      responses:
        "200":
          schema:
            type: array
            items:
              "$ref": "#/definitions/Error"
          headers:
            test-method-response-header:
              type: string
    get:
      x-deforest-ignore: true
      parameters:
        - name: q1
          in: query
          required: true
      responses:
        "200":
          schema:
            type: array
            items:
              "$ref": "#/definitions/Error"
          headers:
            test-method-response-header:
              type: string

will result in

paths:
  /validation:
    post:
      responses:
        "200":
          headers:
            test-method-response-header:
              type: string
          schema:
            items:
              $ref: "#/definitions/Error"
            type: array

If we'd written this:

paths:
  "/validation":
    x-deforest-ignore: true
    post:
      responses:
        "200":
          schema:
            type: array
            items:
              "$ref": "#/definitions/Error"
          headers:
            test-method-response-header:
              type: string
    get:
      parameters:
        - name: q1
          in: query
          required: true
      responses:
        "200":
          schema:
            type: array
            items:
              "$ref": "#/definitions/Error"
          headers:
            test-method-response-header:
              type: string

we'd get an empty result since the parent node is removed:

paths: {}

If x-deforest-ignore: false, or missing, the node will be extracted as usual. If the runtime flag --no-ignore is set, the nodes will be extracted as usual as well.

Limitations

The output file looses its order of the keys in the file, which shouldn't affect you if you're using a converter to create a graphical documentation/specification - but can be confusing if you have a specific internal order you wish to keep.

Contribute

If you wish to see a specific feature, please create an issue in the issue tracker - and if you want to help develop deforest, you're free to create a pull request as well. All submitted code will be subject to the licensing specified in the LICENSE file.

Metadata

Release files for deforest 0.4.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 deforest 0.4.0
File Size Uploaded Provenance Actions
deforest-0.4.0.tar.gz 10.4 kB Without provenance Details for deforest-0.4.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for deforest 0.4.0
File Interpreter ABI Platform Actions
deforest-0.4.0-py3.7.egg Legacy Egg format - - Details for deforest-0.4.0-py3.7.egg
deforest-0.4.0-py3-none-any.whl Python 3 none any Details for deforest-0.4.0-py3-none-any.whl

Total release size: 52.7 kB

Release files / deforest-0.4.0.tar.gz

Download URL deforest-0.4.0.tar.gz
Size 10.4 kB
Tags Source
SHA-256 checksum
How to use checksums
0dec032a214dea78cf242f89bf9d4ac03f2a6424ca9d422ce7eeb9a6e3ba0125
BLAKE2b-256 checksum
How to use checksums
2421d5cb0496a62215d5e5f2f168a9d5bd15323969e14c3c1469b125cdf85e34
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.5

Release files / deforest-0.4.0-py3.7.egg

Download URL deforest-0.4.0-py3.7.egg
Size 28.7 kB
Tags Egg
SHA-256 checksum
How to use checksums
ca0e718d04c2221bb78f45d942266c9a796cd421b7b65b6bf79b8d28fc2765f7
BLAKE2b-256 checksum
How to use checksums
80c4dc7467147dc254dc5b519ca4f4f1d8199d3572451c4b9fd0c37bc5e7501e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.5

Release files / deforest-0.4.0-py3-none-any.whl

Download URL deforest-0.4.0-py3-none-any.whl
Size 13.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b643973578494f16034b50e8ce953fb33a164cc203b032faddc3fd50f3464e83
BLAKE2b-256 checksum
How to use checksums
bd2812ad7716358f684e3152783b8bf825c0b80fc8fcbe89b76af44c16ef216e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.5

Security for deforest 0.4.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