{"name":"swagger2openapi","version":"2.11.7","description":"Convert Swagger 2.0 definitions to OpenApi 3.0 and validate","main":"index.js","bin":{"swagger2openapi":"./swagger2openapi.js"},"browserify":{"transform":[["babelify",{"presets":["es2015"]}]]},"repository":{"url":"git+https://github.com/Mermade/swagger2openapi.git","type":"git"},"author":{"name":"Mike Ralphson","email":"mike.ralphson@gmail.com"},"license":"BSD-3-Clause","dependencies":{"ajv":"^5.0.1","call-me-maybe":"^1.0.1","co":"^4.6.0","js-yaml":"^3.6.1","node-fetch":"^1.6.3","node-readfiles":"^0.2.0","reftools":"0.0.18","should":"^13.0.1","yargs":"^9.0.1"},"keywords":["swagger","openapi","openapi2","openapi3","converter","conversion","validator","validation","resolver"],"devDependencies":{"babel-core":"^6.24.1","babel-loader":"^7.1.0","babel-preset-es2015":"^6.24.1","coveralls":"^3.0.0","webpack":"^3.5.6"},"gitHead":"ed2851112c09531e64316f9d2da03b2048f322d5","bugs":{"url":"https://github.com/Mermade/swagger2openapi/issues"},"homepage":"https://github.com/Mermade/swagger2openapi#readme","_id":"swagger2openapi@2.11.7","_npmVersion":"5.4.2","_nodeVersion":"8.7.0","_npmUser":{"name":"mermade","email":"mike.ralphson@gmail.com"},"dist":{"integrity":"sha512-7fErGfn1v0easaiSvikDLwJ8M0oSekICPXL6mFucYRz/3ja/yw39ey8/MV4+jP/rS6oFoRFDuc5kzAgGqI79Uw==","shasum":"7ccd1e32103313d5c293f50446f6731eef02fe3e","tarball":"http://registry-npm.ywwl.com/swagger2openapi/download/swagger2openapi-2.11.7.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDoPnM8KnS1X86f/fhIw5J3nbjSSnK2K50JEoYfBmH2jAIgR86zFf4nk6N/TtvwSRAZ259qaz5KFprVuaYSwzHeUVg="}],"size":78202,"noattachment":false,"key":"/swagger2openapi/-/swagger2openapi-2.11.7.tgz"},"maintainers":[{"name":"mermade","email":"mike.ralphson@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/swagger2openapi-2.11.7.tgz_1511861668195_0.5373234241269529"},"directories":{},"readme":"# swagger2openapi\n\n![logo](https://github.com/Mermade/oas-kit/blob/master/docs/logo.png?raw=true)\n\n[![OpenAPI Validation](https://mermade.org.uk/openapi-converter/api/v1/badge?url=https://mermade.org.uk/openapi-converter/examples/openapi.json)](https://mermade.org.uk/openapi-converter/api/v1/validate?url=https://mermade.org.uk/openapi-converter/examples/openapi.json)\n![Build](https://img.shields.io/travis/Mermade/oas-kit/master.svg)\n[![Tested on APIs.guru](https://api.apis.guru/badges/tested_on.svg)](https://APIs.guru)\n[![Tested on Mermade OpenAPIs](https://img.shields.io/badge/Additional%20Docs-74426-brightgreen.svg)](https://github.com/mermade/openapi-definitions)\n[![Coverage Status](https://coveralls.io/repos/github/Mermade/swagger2openapi/badge.svg?branch=master)](https://coveralls.io/github/Mermade/swagger2openapi?branch=master)\n[![Known Vulnerabilities](https://snyk.io/test/npm/swagger2openapi/badge.svg)](https://snyk.io/test/npm/swagger2openapi)\n[![Greenkeeper badge](https://badges.greenkeeper.io/Mermade/oas-kit.svg)](https://greenkeeper.io/)\n\nConvert Swagger 2.0 definitions into OpenApi 3.0.x\n\nThe online version of the converter/validator runs on a [Linode](https://www.linode.com/?r=5734be467cc501b23267cf66d451bc339042ddfa) VPS. If you are considering a hosted server, please sign up through this link so we both receive free credit.\n\nCurrently tracking [v3.0.x](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md)\n\n## Installation:\nThis is a node.js module, which you can run on the command line. First ensure you have npm installed (tested on version 6.1+), and then install as follows:\n```bash\nnpm install -g swagger2openapi\n```\nOr, add it to your node.js projects as shown below in option B.\n\n## Usage:\n### A. Command line:\n\n```text\nswagger2openapi [options] [filename|url]\nOptions:\n  --refSiblings        mode to handle $ref's with sibling properties\n                                        [choices: \"remove\", \"preserve\", \"allOf\"]\n  --resolveInternal    resolve internal references also                [boolean]\n  --warnProperty       Property name to use for warning extensions\n                                             [string] [default: \"x-s2o-warning\"]\n  --version            Show version number                             [boolean]\n  -c, --components     output information to unresolve a definition    [boolean]\n  -d, --debug          enable debug mode, adds specification-extensions[boolean]\n  -e, --encoding       encoding for input/output files[string] [default: \"utf8\"]\n  -f, --fatal          make resolution errors fatal                    [boolean]\n  -h, --help           Show help                                       [boolean]\n  -i, --indent         JSON indent to use, defaults to 4 spaces         [string]\n  -o, --outfile        the output file to write to                      [string]\n  -p, --patch          fix up small errors in the source definition    [boolean]\n  -r, --resolve        resolve external references                     [boolean]\n  -t, --targetVersion  override default target version of 3.0.0         [string]\n  -u, --url            url of original spec, creates x-origin entry     [string]\n  -v, --verbose        increase verbosity                                [count]\n  -w, --warnOnly       Do not throw on non-patchable errors, add warning\n                       extensions                                      [boolean]\n  -y, --yaml           write YAML, default JSON (overridden by --outfile\n                       filepath extension)                             [boolean]\n  -b, --rbname         Extension to use to preserve body parameter names in\n                       converted operations (\"\" == disabled)\n                                                          [string] [default: \"\"]\n```\n\n### B. Node.js API:\n\n```javascript\nconst converter = require('swagger2openapi');\nlet options = {};\n//options.patch = true; // fix up small errors in the source definition\n//options.warnOnly = true; // Do not throw on non-patchable errors\nconverter.convertObj(swagger, options, function(err, options){\n  // options.openapi contains the converted definition\n});\n// also available are asynchronous convertFile, convertUrl, convertStr and convertStream functions\n// if you omit the callback parameter, you will instead receive a Promise\n```\n\nNote that the `options` object passed in is modified/extended by the `convert*` functions.\n\nSee the [boast command-line tool](/packages/swagger2openapi/boast.js) for a fuller CLI tool for converting, validating and linting.\n\nSee here for complete [documentation](/docs/options.md) of the `options` object.\n\n### C. Browser:\n\nOr use the [online version](https://mermade.org.uk/openapi-converter) which also includes its own [API](http://petstore.swagger.io/?url=https://mermade.org.uk/openapi-converter/contract/swagger.json).\n\n#### Browser Support\n\nSee [initial documentation](/docs/browser.md).\n\n## Features\n\n### OpenAPI 3.0.x validation\n\n`oas-validate` can be used as a validator if given one or more existing OpenAPI 3.x definitions. The validator (however it is called) uses [WHATWG](https://whatwg.org/) URL parsing if available (node 7.x and above). The validator can have a linting mode enabled with the `--lint` option. Rules are defined [here](/packages/oas-linter/rules.yaml). Contributions of rules and rule actions for the linter are very much appreciated.\n\n```text\noas-validate.js [options] {path-to-docs}...\n\nOptions:\n  --lint            lint the definition                                [boolean]\n  --validateSchema  Run schema validation step: first, last* or never   [string]\n  --warnOnly        Do not throw on non-patchable errors               [boolean]\n  -h, --help        Show help                                          [boolean]\n  --version         Show version number                                [boolean]\n  -e, --encoding    encoding for input/output files   [string] [default: \"utf8\"]\n  -f, --fail        path to docs expected to fail                       [string]\n  -j, --jsonschema  path to alternative JSON schema                     [string]\n  -l, --laxurls     lax checking of empty urls                         [boolean]\n  -m, --mediatype   check media-types against RFC pattern              [boolean]\n  -n, --nopatch     do not patch minor errors in the source definition [boolean]\n  -o, --output      output conversion result  [string] [default: \"openapi.yaml\"]\n  -q, --quiet       do not show test passes on console, for CI         [boolean]\n  -r, --resolve     resolve external references                        [boolean]\n  -s, --stop        stop on first error                                [boolean]\n  -v, --verbose     increase verbosity                                   [count]\n  -w, --whatwg      enable WHATWG URL parsing                          [boolean]\n  -y, --yaml        skip YAML-safe test                                [boolean]\n```\n\n### Reference preservation\n\n`swagger2openapi` by default preserves almost all `$ref` JSON references in your API definition, and does not dereference\nevery item, as with some model-based parsers. The exception is internal references within externally referenced documents. To enable internal `$ref` resolution across the whole document, use the `--resolveInternal` option, which also disables creation of `$ref`s for shared `requestBodies`.\n\n### Schema transformations\n\n`swagger2openapi` will automatically 'repair' a number of problems where non-compliant Swagger 2.0 schemas have been used. It will attempt to transform JSON schemas (used incorrectly) into OpenAPI 3.0.x Schema objects.\n\n### Specification extensions\n\n`swagger2openapi` has support for a limited number of real-world [specification extensions](/docs/extensions.md) which have a direct bearing on the conversion. All other specification extensions are left untouched. swagger2openapi is [swaggerplusplus](https://github.com/mermade/swaggerplusplus)-compatible.\n\nIt is expected to be able to configure the process of specification-extension modification using options or a plugin mechanism in a future release.\n\n## Tests\n\nTo run a test-suite:\n\n```shell\nnode oas-validate [-f {path-to-expected-failures}]... [{path-to-APIs|single-file...}]\n```\n\nThe test harness currently expects files with a `.json` or `.yaml` extension, or a single named file, and has been tested on LTS Node.js versions against\n\n* [APIs.guru](https://github.com/APIs-guru/openapi-directory)\n* [Mermade OpenApi specifications collection](https://github.com/mermade/openapi_specifications)\n* [OpenAPI3-Examples (pass/fail)](https://github.com/mermade/openapi3-examples)\n* [SOM-Research collection](https://github.com/SOM-Research/hapi)\n\nAdditionally `swagger2openapi` has been tested on a corpus of 74,426 real-world valid Swagger 2.0 definitions from GitHub and [SwaggerHub](https://swaggerhub.com/). However, if you have a definition which causes errors in the converter or does not pass validation, please do not hesitate to [raise an issue](https://github.com/Mermade/swagger2openapi/issues).\n\n### Regression tests\n\nRegression tests (thanks [@domharrington](https://github.com/domharrington)) live in the `/test` directory and can be run with `npx mocha`. Each sub-directory of `s2o-test` should contain an input `swagger.yaml` file, an expected output `openapi.yaml` file and an optional `options.yaml` file. You can put private test cases in sub-directories starting with an underscore character. In the `resolver` sub-directory, each directory should contain an `input.yaml`, an `output.yaml` and an optional `options.yaml` file.\n\n### Version history\n\n* [Change-Log](https://github.com/Mermade/oas-kit/blob/master/CHANGELOG.md#change-log)\n\n## License\n\n[BSD-3-Clause](LICENSE) except the `openapi-3.0.json` schema, which is taken from the [OpenAPI-Specification](https://github.com/OAI/OpenAPI-Specification/blob/master/schemas/v3.0/schema.yaml) which is licensed under the [Apache-2](http://www.apache.org/licenses/LICENSE-2.0) license.\n","publish_time":1511861669581,"_cnpm_publish_time":1511861669581,"dist-tags":{"beta":"2.12.0-5","latest":"7.0.8"}}