Deimdal.ExtractOpenApi
1.0.5
Prefix Reserved
dotnet tool install --global Deimdal.ExtractOpenApi --version 1.0.5
dotnet new tool-manifest
dotnet tool install --local Deimdal.ExtractOpenApi --version 1.0.5
#tool dotnet:?package=Deimdal.ExtractOpenApi&version=1.0.5
nuke :add-package Deimdal.ExtractOpenApi --version 1.0.5
extract-open-api
A dotnet tool for reducing OpenApi specification documents by filtering out unnecessary operations.
Schema v2 and v3 are supported
Usage
- Specify a source document (URL or file name)
- Specify destination document file name
- Specify a path filter (what path should be preserved) with an optional operation filter (see below)
- Specify optional parameters (if required): destination document version and format
Schema filter is not supported. Schema tree-shaking will be performed for preserved paths automatically
Path and operation filter
Please ensure your command shell allows symbols like
{and}, or use escaped strings otherwise
Path filter can be:
- Single
-p /pet/{petId}/uploadImage - Multiple
-p /pet/{petId}/uploadImage /pet/findByStatus /user/{username} /pet/findByTags
Path filter can contain operation filter:
- Single operation
-p /user/{username}=get(only GET operation for this path will be preserved in the final document) - Multiple operations
-p /user/{username}=get,put(GET and PUT operations for this path will be preserved in the final document)
Installation (global tool)
dotnet tool install Deimdal.ExtractOpenApi --global
Usage command
extract-open-api -s <source OpenApi file or URL> -d <destination OpenApi file> -p <path filter 1> <path filter 2> <...>
Examples
Get specification from URL https://petstore.swagger.io/v2/swagger.json, preserve all operations for path /user/{username} and save a result to file spec.yaml in YAML format
extract-open-api -s https://petstore.swagger.io/v2/swagger.json -d spec.yaml -p /user/{username}
Get specification from URL https://petstore.swagger.io/v2/swagger.json, preserve all operations for path /store/inventory and GET operation for path /pet/{petId}, then save a result to file spec.yaml in YAML format
extract-open-api -s https://petstore.swagger.io/v2/swagger.json -d spec.yaml -p /store/inventory /pet/{petId}=get
Get specification from URL https://petstore.swagger.io/v2/swagger.json, preserve all operations for path /pet, /pet/{petId} and /store/inventory, then save a result to file spec.json in JSON format
extract-open-api -s https://petstore.swagger.io/v2/swagger.json -d spec.json -f json -p /pet /pet/{petId} /store/inventory
See help for full parameter usage details
extract-open-api -h
Local testing as a tool
- Create a package
dotnet pack -c Release - Uninstall any current versions (global in this example)
dotnet tool uninstall Deimdal.ExtractOpenApi --global - Install a local package (from the root of the solution in this example)
dotnet tool install Deimdal.ExtractOpenApi --global --add-source .\Deimdal.ExtractOpenApi\nupkg --version 0.0.1
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
This package has no dependencies.