SwaggerMerge 0.1.0
See the version list below for details.
dotnet tool install --global SwaggerMerge --version 0.1.0
dotnet new tool-manifest # if you are setting up this repo dotnet tool install --local SwaggerMerge --version 0.1.0
#tool dotnet:?package=SwaggerMerge&version=0.1.0
nuke :add-package SwaggerMerge --version 0.1.0
Swagger v2 JSON merge CLI tool
The Swagger v2 merge CLI tool allows you to process the merging of multiple Swagger v2 JSON files into a single Swagger v2 JSON file. This is useful for bringing together the API layer of a distributed service architecture where you wish to expose the APIs via a single API gateway.
Getting started
Install the tool
dotnet tool install -g SwaggerMerge
Configure your Swagger document merge
To use the CLI tool, you will need access to all of your Swagger v2 JSON input files, and you will need to create a configuration JSON file that will be used by the CLI tool to determine how to merge the input files together.
Here's an example of the format for this configuration file.
{
"inputs": [
{
"file": "./projects.swagger.json"
},
{
"file": "./users.swagger.json",
"path": {
"prepend": "/api/users",
"stripStart": "/foo"
},
"info": {
"append": true,
"title": " Including Users",
}
}
],
"output": {
"file": "./api.swagger.json",
"info": {
"title": "Services",
"version": "1.0"
}
}
}
The configuration file is made up of several options that allow you to customize and tailor the inputs and output of the tool.
inputs
- Required. An array of input files. Each input file is a JSON object with the following properties:file
- Required. The path to the input file.path
- Optional. A configuration object for the paths of APIs with the following properties:prepend
- Optional. A string to prepend to the path of each operation in the input file.stripStart
- Optional. A string to strip from the start of the path of each operation in the input file.
info
- Optional. A configuration object for the info section with the following properties:append
- Optional. A boolean value that determines whether the input file's info title should be appended to the output file's info title.title
- Optional. A string to use as the title of the output file that is different to the original.
output
- Required. A configuration object for the output file with the following properties:file
- Required. The path to the output file.info
- Optional. A configuration object for the info section with the following properties:title
- Optional. A string to use as the title of the output file.version
- Optional. A string to use as the version of the output file.
Run the merge tool
Once you have your configuration file, it is simply a case of running CLI and passing the file as the first argument to the tool.
swagger-merge config.json
This will merge all of the input files into a single output file at the configured path. And that's it!
Contributing 🤝🏻
Contributions, issues and feature requests are welcome!
Feel free to check the issues page. You can also take a look at the contributing guide.
We actively encourage you to jump in and help with any issues, and if you find one, don't forget to log it!
Support this project 💗
As many developers know, projects like this are built and maintained in spare time. If you find this project useful, please Star the repo.
Author
👤 James Croft
- Website: https://www.jamescroft.co.uk
- Twitter: @jamesmcroft
- Github: @jamesmcroft
- LinkedIn: @jmcroft
License
This project is made available under the terms and conditions of the MIT license.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
This package has no dependencies.