{"id":16296882,"url":"https://github.com/windomz/swagger-merger","last_synced_at":"2025-04-05T07:05:45.877Z","repository":{"id":19794818,"uuid":"87785130","full_name":"WindomZ/swagger-merger","owner":"WindomZ","description":":link: Merge multiple swagger files into a swagger file, support JSON/YAML.","archived":false,"fork":false,"pushed_at":"2022-12-02T16:29:19.000Z","size":567,"stargazers_count":142,"open_issues_count":7,"forks_count":28,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-04-14T20:04:53.492Z","etag":null,"topics":["cli","json","merge","swagger","swagger-files","swagger-merger","swagger2","yaml"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/WindomZ.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-10T08:19:51.000Z","updated_at":"2024-04-03T08:09:09.000Z","dependencies_parsed_at":"2023-01-13T20:35:33.817Z","dependency_job_id":null,"html_url":"https://github.com/WindomZ/swagger-merger","commit_stats":null,"previous_names":[],"tags_count":34,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WindomZ%2Fswagger-merger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WindomZ%2Fswagger-merger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WindomZ%2Fswagger-merger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WindomZ%2Fswagger-merger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WindomZ","download_url":"https://codeload.github.com/WindomZ/swagger-merger/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247299832,"owners_count":20916190,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","json","merge","swagger","swagger-files","swagger-merger","swagger2","yaml"],"created_at":"2024-10-10T20:24:18.828Z","updated_at":"2025-04-05T07:05:45.859Z","avatar_url":"https://github.com/WindomZ.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"```\n┌─┐┬ ┬┌─┐┌─┐┌─┐┌─┐┬─┐   ┌┬┐┌─┐┬─┐┌─┐┌─┐┬─┐\n└─┐│││├─┤│ ┬│ ┬├┤ ├┬┘───│││├┤ ├┬┘│ ┬├┤ ├┬┘\n└─┘└┴┘┴ ┴└─┘└─┘└─┘┴└─   ┴ ┴└─┘┴└─└─┘└─┘┴└─\n```\n\n[![Greenkeeper badge](https://badges.greenkeeper.io/WindomZ/swagger-merger.svg)](https://greenkeeper.io/)\n[![Node.js(≥12.22) CI](https://github.com/WindomZ/swagger-merger/actions/workflows/ci.yml/badge.svg)](https://github.com/WindomZ/swagger-merger/actions/workflows/ci.yml)\n[![Coverage Status](https://coveralls.io/repos/github/WindomZ/swagger-merger/badge.svg?branch=master)](https://coveralls.io/github/WindomZ/swagger-merger?branch=master)\n[![Standard - JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com/)\n[![License](https://img.shields.io/badge/license-MIT-green.svg)](https://opensource.org/licenses/MIT)\n\n\u003e Merge **multiple** related files from **a** input swagger file, Write to **a** output swagger file.\n\u003e \n\u003e Support **JSON**/**YAML**.\n\n[![NPM](https://nodei.co/npm/swagger-merger.png)](https://nodei.co/npm/swagger-merger/)\n\n[![swagger-merger](https://img.shields.io/npm/v/swagger-merger.svg)](https://www.npmjs.com/package/swagger-merger)\n[![status](https://img.shields.io/badge/status-stable-green.svg)](https://www.npmjs.com/package/swagger-merger)\n\n## Features\n- [x] _Merge_ ***multiple*** swagger files into ***a*** swagger file.\n- [x] _$ref_ - A tag, include a **single-level** of swagger file.\n- [x] _$ref#*_ - A tag, include a **multi-level** of swagger file.\n- [x] _Support_ **JSON**/**YAML** swagger files(`.json`/`.yaml`/`.yml`).\n- [x] _CLI_ - Command line interface.\n\n## Usage\n\n### $ref\n\u003e Includes a _single-level_ of swagger file.\n\n- [Official standards](https://swagger.io/docs/specification/using-ref/)\n- Recommended, universal\n\nFor `yaml` example:\n\n```yaml\n$ref: \"./host.yaml\"\nparameters:\n  - $ref: \"name.yaml\"\n  - $ref: \"./year.yaml\"\n  - $ref: \"age.yaml#/alex/son\"\nremote:\n  $ref: \"https://raw.githubusercontent.com/WindomZ/swagger-merger/remote.yaml#/name\"\nresponses:\n  $ref: \"./responses.yaml#/post\"\n```\n\n### $ref#*\n\u003e Includes a _multi-level_ of swagger file.\n\n- Non-standard, suggest you use it for yourself\n- Instead of `$ref`, can be used _side by side_ and not an array\n\nFor `yaml` example:\n\n```yaml\npaths:\n  $ref#pets: \"./paths/pets.yaml\"\n  $ref#pets-id: \"./paths/pets-id.yaml\"\npaths-url:\n  $ref#paths: \"https://raw.githubusercontent.com/WindomZ/swagger-merger/master/test/no_ext_json\"\n```\n\nOutput `yaml`:\n\n```yaml\npaths:\n  /pets:\n    hello: world\n  /pets/{id}:\n    good: bye\npaths-url:\n  /pets:\n    hello: world\n  /pets/{id}:\n    good: bye\n```\n### CLI\n\u003e How to use?\n\n```bash\n$ swagger-merger -h\n\n  Usage: swagger-merger [-h] [-v] [-c] [-o file] \u003c-i file | file\u003e\n\n  Merge multiple swagger files into a swagger file, just support JSON/YAML.\n\n  Options:\n\n    -h, --help           output usage information\n    -V, --version        output the version number\n    -i, --input \u003cfile\u003e   input a main/entry JSON/YAML swagger file\n    -o, --output \u003cfile\u003e  output a merged JSON/YAML swagger file, default is `swagger.*`\n    -c, --compact        compact JSON/YAML format string\n    --debug              debug mode, such as print error tracks\n```\n\nEasy to use.\n```bash\nswagger-merger -i in.yaml                # Merge in.yaml into swagger.yaml\nswagger-merger -i in.yaml -o out.yaml    # Merge in.yaml into out.yaml\nswagger-merger -i in.yaml -o out.yaml -c # Merge in.yaml into out.yaml and compress it\nswagger-merger -i in.yaml -o out.json    # Merge in.yaml into out.json\n\nswagger-merger -i in.json                # Merge in.json into swagger.json\nswagger-merger -i in.json -o out.json    # Merge in.json into out.json\nswagger-merger -i in.json -o out.json -c # Merge in.json into out.json and compress it\nswagger-merger -i in.json -o out.yaml    # Merge in.json into out.yaml\n```\n\n### Module\n\u003e How to use?\n\n```bash\nnpm install swagger-merger\n```\n\n```js\n#!/usr/bin/env node\n\nconst swaggerMerger = require('swagger-merger')\n\nswaggerMerger.merge({\n  input: 'index.json',\n  output: 'swagger.json',\n  compact: false\n}).catch(e =\u003e {\n  console.error(e)\n})\n```\n\n## Install\n```bash\nnpm install swagger-merger -g\n```\n\n## Examples\n\u003e It would be more helpful to see these examples.\n\nOpen the terminal, **choose** one of the following ways: \n\n- [npm](https://www.npmjs.com/)\n    ```bash\n    npm install\n    npm run test\n    ```\n\n- [yarn](https://yarnpkg.com/)\n    ```bash\n    yarn\n    yarn run test\n    ```\n\n- [swagger-merger]((https://www.npmjs.com/package/swagger-merger)) (installed, go to each examples)\n    ```bash\n    swagger-merger -i index.yaml\n    swagger-merger -i index.json\n    ```\n\nThen, these examples may help you:\n\n### [heroku-pets](https://github.com/WindomZ/swagger-merger/tree/master/example/heroku-pets)\n- Official swagger example\n- _No_ modification\n\nGo to `example/heroku-pets`\n1. The output `swagger.json` is same as the expected `heroku-pets.json`.\n1. The output `swagger.yaml` is similar to the expected `heroku-pets.yaml`.\n\n### [echo](https://github.com/WindomZ/swagger-merger/tree/master/example/echo)\n- Base on official swagger example\n- _Modify_ to support for [$ref](#ref) tags\n\nGo to `example/echo`\n1. The output `swagger.json` is same as the expected `echo.json`.\n1. The output `swagger.yaml` is similar to the expected `echo.yaml`.\n\n### [petstore_simple](https://github.com/WindomZ/swagger-merger/tree/master/example/petstore_simple)\n- Base on official swagger example\n- _Modify_ to support for [$ref#*](#ref-1) tags\n\nGo to `example/petstore_simple`\n1. The output `swagger.json` is same as the expected `petstore_simple.json`.\n1. The output `swagger.yaml` is similar to the expected `petstore_simple.yaml`.\n\n### [petstore_domain](https://github.com/WindomZ/swagger-merger/tree/master/example/petstore_domain)\n\u003e A way of using [$ref](#ref) instead of [$ref#*](#ref-1), and better compatibility.\n\n- Same as [petstore_simple](#examplepetstore_simple)\n- _Modify_ to support for [$ref](#ref) tags\n- _Modify_ to support for **multiple levels** schema\n\nGo to `example/petstore_domain`\n1. The output `swagger.json` is same as the expected `petstore_simple.json`.\n1. The output `swagger.yaml` is similar to the expected `petstore_simple.yaml`.\n\n## Contributing\nWelcome to pull requests, report bugs, suggest ideas and discuss **swagger-merger**, \ni would love to hear what you think about **swagger-merger** on [issues page](https://github.com/WindomZ/swagger-merger/issues).\n\nIf you like it then you can put a :star: on it.\n\n## License\n[MIT](https://github.com/WindomZ/swagger-merger/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwindomz%2Fswagger-merger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwindomz%2Fswagger-merger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwindomz%2Fswagger-merger/lists"}