Managing large OpenAPI files can be a hassle, especially when you only need a small portion of the API for specific tasks. This is where OpenAPI Trimmer comes in handy. It's a lightweight tool designed to trim down your OpenAPI files to include only the endpoints and data transfer objects (DTOs) you care about.
Let's say you're working with a large OpenAPI file, but you only need the endpoints related to the Quotes API. You can easily extract just those endpoints and remove irrelevant DTOs with a single command:
openapi-trimmer -i openapi.yaml \ -p /v1/quotes,/v1/users \ -ec CompanyConfigDto,UpdateCompanyConfigDto
This command will:
The trimmed API definition will be saved as openapi-trimmer.yaml.
To ensure the integrity of your trimmed OpenAPI file, validate it with:
swagger-cli validate ./openapi-trimmer.yaml
This step helps catch any issues before you deploy or share the trimmed API file.
You can install OpenAPI Trimmer directly from PyPi:
pip install openapi-trimmer
For more details and the latest updates, visit the OpenAPI Trimmer PyPi page.
GitHub repository: OpenAPI Trimmer on GitHub.
The OpenAPI Trimmer offers several options to customize its operation:
OpenAPI Trimmer is an essential tool for developers looking to streamline their OpenAPI files, making them more manageable and tailored to specific needs. Whether you're preparing API documentation or simplifying an API for internal use, OpenAPI Trimmer saves you time and effort by focusing only on what matters most to you.
The above is the detailed content of OpenAPI Trimmer Python Tool. For more information, please follow other related articles on the PHP Chinese website!