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-converter
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.ymlformats. - Adds missing
operationIdandsummaryfields to operations. - Ensures the
info.titlefield 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:
python -m 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 toopenapi.json.--split-by-tag: (Optional) Split the OpenAPI spec into multiple files by tag.
Examples
Convert and output a single JSON file:
python -m adp_api_transformer api.yaml modified_api.json
Split by tag and output to a directory:
python -m 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.titleis 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
tagsfield (if missing), using the first path segment as the tag.
- If
--split-by-tagis 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
- Python 3.9+
- pyyaml
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file adp_api_transformer-1.0.2.tar.gz.
File metadata
- Download URL: adp_api_transformer-1.0.2.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e02aa216c2d57b61a2c93dd0f34e3446d08e587e16c4c3e23f71de66adfbf5f
|
|
| MD5 |
0c5e88e2eb435a5055fb2843ac91bd0c
|
|
| BLAKE2b-256 |
d64933e8d7cdd0f749356042de7f80e3e62d2032fdc026fdeacb7e043632a434
|
File details
Details for the file adp_api_transformer-1.0.2-py3-none-any.whl.
File metadata
- Download URL: adp_api_transformer-1.0.2-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
365ac77f7adcea06e88ba725e732c7ff06e3a82d1ad519a7abf303e058326e3d
|
|
| MD5 |
90a8714c58d23af7970ac67f2d9dfcc2
|
|
| BLAKE2b-256 |
d311076ffaf062f531ca0125e0ad2d789f5643ee1c26579a7633c63f34b63eed
|