Skip to main content

This package can be used to transform your openapi specs (json or yaml) to be used in the ADP1 apim repo

Project description

adp-api-transformer

A utility to transform your OpenAPI specifications (JSON or YAML) for use in the ADP1 APIM repository.
This tool ensures your API specs have required attributes and outputs a modified OpenAPI JSON file.

Features

  • Accepts OpenAPI specs in .json, .yaml, or .yml formats.
  • Adds missing operationId and summary fields to operations.
  • Ensures the info.title field is set to a template value.
  • Splits the OpenAPI spec into multiple files based on tags, with paths starting after the tag.
  • Outputs the modified spec as formatted JSON.

Usage

You can run the converter as a command-line tool:

adp-api-transformer <input_file> [output_file_or_dir] [--split-by-tag]
  • <input_file>: Path to your OpenAPI spec (YAML or JSON).
  • [output_file_or_dir]: (Optional) Path for the output JSON file, or output directory if using --split-by-tag. Defaults to openapi.json.
  • --split-by-tag: (Optional) Split the OpenAPI spec into multiple files by tag.

Examples

Convert and output a single JSON file:

adp-api-transformer api.yaml modified_api.json

Split by tag and output to a directory:

adp-api-transformer api.yaml output_dir --split-by-tag

This will create one file per tag (e.g., collection.openapi.json), with each file containing only the paths for that tag.
The paths in each split file start after the tag segment.
For example, /collection becomes /, /collection/{id} becomes /{id}.

How it works

  • Loads the OpenAPI spec from the provided file.
  • Adds or updates the following:
    • info.title is set to {{apiTitle}}.
    • Each operation gets an operationId (if missing) in the format: <method>_<path>-{consumerphase}.
    • Each operation gets a summary (if missing) in the format: <METHOD> <path>.
    • Each operation gets a tags field (if missing), using the first path segment as the tag.
  • If --split-by-tag is used:
    • The spec is split into multiple files, one per tag.
    • In each split file, the path starts after the tag segment (e.g., /collection/).
  • Saves the modified spec(s) as JSON.

Requirements

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

adp_api_transformer-1.0.4.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

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

adp_api_transformer-1.0.4-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file adp_api_transformer-1.0.4.tar.gz.

File metadata

  • Download URL: adp_api_transformer-1.0.4.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for adp_api_transformer-1.0.4.tar.gz
Algorithm Hash digest
SHA256 7b5b0b86914a3ad1153493a6943aae1365b979fc1ab1d7397030c8884afe1f01
MD5 9d3e6c0e831c2b634b01143cba2b99c4
BLAKE2b-256 1f6485729c6ef7b2f57cb73f76fc8ef8a406a5ad5781e6aeb140b25cf3a06332

See more details on using hashes here.

File details

Details for the file adp_api_transformer-1.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for adp_api_transformer-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 7a1dc696731dd18fdf201e6383c787cb9021748dbe9e80f218bf6c3d06f6e40b
MD5 9135f47e79b69147ca9e1c6648997a74
BLAKE2b-256 5e1adf8b1cbadc9d72b68e3f7c67d64bde169ddaeb3804024ea43cd2269ba474

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