{"_id":"@ecogy-energy/json-schema-to-openapi-schema","_rev":"5-8d84f8a81f2a38c2205e52a13d807c89","name":"@ecogy-energy/json-schema-to-openapi-schema","dist-tags":{"latest":"0.0.1"},"versions":{"0.0.0-development":{"name":"@ecogy-energy/json-schema-to-openapi-schema","version":"0.0.0-development","description":"Converts a JSON Schema to OpenAPI Schema Object","main":"index.js","bin":{"json-schema-to-openapi-schema":"bin/json-schema-to-openapi-schema.js"},"types":"index.d.ts","scripts":{"test":"nyc --reporter=html --reporter=text mocha","coverage":"nyc report --reporter=text-lcov"},"repository":{"type":"git","url":"git+https://github.com/ecogy-energy/json-schema-to-openapi-schema.git"},"author":{"name":"OpenAPI Contrib"},"license":"MIT","engines":{"node":">=10"},"devDependencies":{"coveralls":"^3.0.11","mocha":"^7.1.1","nock":"^11.9.1","nyc":"^15.0.1","should":"^13.2.0"},"dependencies":{"@cloudflare/json-schema-walker":"^0.1.1","@stoplight/json-ref-resolver":"^3.1.1","@stoplight/yaml":"^3.7.1","chalk":"^4.1.1","node-fetch":"^2.6.0","tslib":"^1.11.1","yargs":"^17.0.1"},"gitHead":"84cfb28cfcc91713db19db8985db6c156cce3012","bugs":{"url":"https://github.com/ecogy-energy/json-schema-to-openapi-schema/issues"},"homepage":"https://github.com/ecogy-energy/json-schema-to-openapi-schema#readme","_id":"@ecogy-energy/json-schema-to-openapi-schema@0.0.0-development","_nodeVersion":"14.15.4","_npmVersion":"6.14.10","dist":{"integrity":"sha512-HsPSxzX7RJBHQI1BHiqTSG75Nk9C7P65/Tx1DaJRKyr6CK/wQFdQ9LTxmXxoZFg/diaYLbcuhho6/obCvUDBFw==","shasum":"139617ec560e3cc327b42aa875011c01b68fcf8b","tarball":"https://registry.npmjs.org/@ecogy-energy/json-schema-to-openapi-schema/-/json-schema-to-openapi-schema-0.0.0-development.tgz","fileCount":44,"unpackedSize":98789,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEcmFsl7ZjAkwhJyCIYEz5VoazJ1pi9avfjvZI4J9m6NAiBZBMQtMiAmcsnlDuyjdkkSidnYX8iQ+IK1iS2OTPAb0Q=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJintFjACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmopew/+ITuqKVlzVwJ6gLqBDzQMIsmFzJrEhNeOw3KhsZQBhy86Dc7G\r\ntyJM/xdbKvZ0cp+mEgZtdlz5nqjllWJRDYl3QjgUHtuSccQ1fYfY2TzpuhoS\r\nC/dGhYb4I1eNPV7DlFtE8E5yeDHjUf9JPMvPVLS8ri5MUcH2KVMxpmrEZOxd\r\n4vVs/kGYjuxVJ1ado6mRVivuYZGSlNsic+YQ0z9dcPxnnTBl8xzUCFYnidSx\r\nsEHV7zDOU+QvyGsgEAFlndWmvCgRgpB4QXWJ9wuMgjnTYl4zC+mq/q7SOJ1e\r\n8QXbdfPQMNxTtDQkxDtLy+4godQSNIS5Dmx1bGSl4f+gAIF5zL6rkjvUudxn\r\nlxu34dCP2Fw8YAAwcLyi5eBW36XVYpztG2Vj0usywns8v3RAFM+5vrZ88Z5l\r\npLmsoegjVB+K6EjbQT2U8uo5NZgfkde2E4Jbalkidgbz5RuhaYEOTw8nX+yC\r\nIWULrPeLKLuonsR6b2vGYA+IXGCgp03bRpUYX5KtMoIsNluv+Xd0gdvhtSo2\r\nCjt/bWEuuoqRRQVSqfavYdDVsqCs7NiXjCCRwNIAIsA7N8pB8sdmIPjKrLi7\r\nZCAXzUBkmGGgZcdeAWjr1oUv3QsosAaBvk6Oi10fJLNwSQiiv3ktikt6rCLU\r\nSx4TZHFKB1NmFwwgFiK5/nAE8YxxgAmuncs=\r\n=Y38X\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"ecogy-energy","email":"itsupport@ecogyenergy.com"},"directories":{},"maintainers":[{"name":"ecogy-energy","email":"itsupport@ecogyenergy.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/json-schema-to-openapi-schema_0.0.0-development_1654575459652_0.8087806339209418"},"_hasShrinkwrap":false},"0.0.1":{"name":"@ecogy-energy/json-schema-to-openapi-schema","version":"0.0.1","description":"Converts a JSON Schema to OpenAPI Schema Object","main":"index.js","bin":{"json-schema-to-openapi-schema":"bin/json-schema-to-openapi-schema.js"},"types":"index.d.ts","scripts":{"test":"nyc --reporter=html --reporter=text mocha","coverage":"nyc report --reporter=text-lcov"},"repository":{"type":"git","url":"git+https://github.com/ecogy-energy/json-schema-to-openapi-schema.git"},"author":{"name":"OpenAPI Contrib"},"license":"MIT","engines":{"node":">=10"},"devDependencies":{"coveralls":"^3.0.11","mocha":"^7.1.1","nock":"^11.9.1","nyc":"^15.0.1","should":"^13.2.0"},"dependencies":{"@cloudflare/json-schema-walker":"^0.1.1","@stoplight/json-ref-resolver":"^3.1.1","@stoplight/yaml":"^3.7.1","chalk":"^4.1.1","node-fetch":"^2.6.0","tslib":"^1.11.1","yargs":"^17.0.1"},"gitHead":"d40d6ff74e65c99898c491b6b6387e6872d8d347","bugs":{"url":"https://github.com/ecogy-energy/json-schema-to-openapi-schema/issues"},"homepage":"https://github.com/ecogy-energy/json-schema-to-openapi-schema#readme","_id":"@ecogy-energy/json-schema-to-openapi-schema@0.0.1","_nodeVersion":"14.20.1","_npmVersion":"6.14.17","dist":{"integrity":"sha512-3Iqz9eqXHjBJcViF6H+dPF9HyyREb9Iyg83P/03oGl+S+Vi7obcVnnzCggQ0SnfwMBqXIoYgufgLIvwPYT1mqA==","shasum":"c62a34435f70e817cb0adc1dfebe3e74cedb48c2","tarball":"https://registry.npmjs.org/@ecogy-energy/json-schema-to-openapi-schema/-/json-schema-to-openapi-schema-0.0.1.tgz","fileCount":44,"unpackedSize":98531,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDe0YXcsoST8sTHEC01J/TC173rxPGWA95mf11OThIBpAiEAp0C+xnj2z8IbH9I2W2v/kjGfez5CuLIp9AyHDsR0brc="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjO7YQACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmr4vRAAmZZlrqXvz/3YijgUkSk0uEl6OQgShzn2A9L4u4xs2F8/I9gC\r\nMZzlzNkCFE9UZJfB4z7qJKLPKqCy+U74eODxDkNgef3Qx3EEVnaQ26wlQT/W\r\nhru9zpvrw1OWq4aL53eoyd9DbmNEy6zGiyqtTx6L47QGlwIOLIOybiAXQKtU\r\n6FzJ6erL5nYDYoe7LOncDujZmCUUjXaU7wtD+fpTfqeO/Lho1r7l56tUsG1I\r\n9RNcGiLAJXs9HP5+9ipWFK7hz02lT0i4vS1TVD3wdOp6Jvz+G9jdalH6HL86\r\nwQNwNOeW33WGfedaddsM7DV4alTMqzmT7tEqjPZcQTOK0z+myFO0WslSyoIQ\r\nWTg84HpHrvepoijmsE1sJw0BhPqSkpqMNWGepBfE0HKYWmvBq+lMRJzocmEt\r\n+V/iK+OEVgvoUhZgtU5+Jz5KCpoxrPS7Ghvjm35beDy741gSB9JkvNPuqsjz\r\nwgubQfdrigS6fTekaZAfUBVC6t8pR/UoMqo5QSjQw4YHMVhhu5UyKn1xDThN\r\nkgLzMkB2QOxGOAYYJnhjGNvh8qF5pus1SC189FLx8mv3lbo2vXZUqjOnMYFB\r\nq4IcciVRdAWHUnsnm3y4v2hIUgGRgEL8zoPs4Y9Kb1GfxpXaLE+ZQddGm8/q\r\n+CLVipyoBCHWwYDXWH7xhO+SgBmcASAh1F0=\r\n=rtzB\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"ecogy-energy","email":"itsupport@ecogyenergy.com"},"directories":{},"maintainers":[{"name":"ecogy-energy","email":"itsupport@ecogyenergy.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/json-schema-to-openapi-schema_0.0.1_1664857616337_0.08974407417156294"},"_hasShrinkwrap":false}},"time":{"created":"2022-06-07T04:17:39.594Z","0.0.0-development":"2022-06-07T04:17:39.876Z","modified":"2023-07-05T21:35:25.629Z","0.0.1":"2022-10-04T04:26:56.573Z"},"maintainers":[{"email":"eljpsm@eljpsm.com","name":"eljpsm"},{"email":"xamoghx@gmail.com","name":"xamogh"},{"email":"maxieduncan@gmail.com","name":"maxieduncan"},{"email":"itsupport@ecogyenergy.com","name":"ecogy-energy-admin"}],"description":"Converts a JSON Schema to OpenAPI Schema Object","homepage":"https://github.com/ecogy-energy/json-schema-to-openapi-schema#readme","repository":{"type":"git","url":"git+https://github.com/ecogy-energy/json-schema-to-openapi-schema.git"},"author":{"name":"OpenAPI Contrib"},"bugs":{"url":"https://github.com/ecogy-energy/json-schema-to-openapi-schema/issues"},"license":"MIT","readme":"# JSON Schema to OpenAPI Schema\n\n**This is a modified version of [@openapi-contrib/json-schema-to-openapi-schema](https://github.com/openapi-contrib/openapi-schema-to-json-schema) with some tweaks to integrate with the JSON Schemas that Ecogy uses**\n\nA little NodeJS package to convert JSON Schema to a [OpenAPI Schema Object](http://spec.openapis.org/oas/v3.0.3.html#schema-object).\n\n[![Treeware](https://img.shields.io/badge/dynamic/json?color=brightgreen&label=Treeware&query=%24.total&url=https%3A%2F%2Fpublic.offset.earth%2Fusers%2Ftreeware%2Ftrees)](https://treeware.earth)\n\n## Features\n\n- converts JSON Schema Draft 04 to OpenAPI 3.0 Schema Object\n- switches `type: ['foo', 'null']` to `type: foo` and `nullable: true`\n- supports deep structures with nested `allOf`s etc.\n- switches `patternProperties` to `x-patternProperties`\n- converts `dependencies` to an allOf + oneOf OpenAPI-valid equivalent\n\n## Installation\n\n```shell\nnpm install --save @openapi-contrib/json-schema-to-openapi-schema\n```\n\nRequires NodeJS v10 or greater.\n\n## Usage\n\nHere's a small example to get the idea:\n\n```js\nconst convert = require(\"@openapi-contrib/json-schema-to-openapi-schema\");\n\nconst schema = {\n  $schema: \"http://json-schema.org/draft-04/schema#\",\n  type: [\"string\", \"null\"],\n  format: \"date-time\",\n};\n\n(async () => {\n  const convertedSchema = await convert(schema);\n  console.log(convertedSchema);\n})();\n```\n\nThe example prints out\n\n```js\n{\n  type: 'string',\n  format: 'date-time',\n  nullable: true\n}\n```\n\n### Options\n\nThe function accepts `options` object as the second argument.\n\n#### `cloneSchema` (boolean)\n\nIf set to `false`, converts the provided schema in place. If `true`, clones the schema by converting it to JSON and back. The overhead of the cloning is usually negligible. Defaults to `true`.\n\n#### `dereference` (boolean)\n\nIf set to `true`, all local and remote references (http/https and file) $refs will be dereferenced. Defaults to `false`.\n\n## Command Line\n\n```sh\nUsage:\n    json-schema-to-openapi-schema <command> [options] <file>\n\nCommands:\n    convert                 Converts JSON Schema Draft 04 to OpenAPI 3.0 Schema Object\n\nOptions:\n    -h, --help              Show help for any command\n    -v, --version           Output the CLI version number\n    -d, --dereference       If set all local and remote references (http/https and file) $refs will be dereferenced\n```\n\n## Why?\n\nOpenAPI is often described as an extension of JSON Schema, but both specs have changed over time and grown independently. OpenAPI v2 was based on JSON Schema draft v4 with a long list of deviations, but OpenAPI v3 shrank that list, upping their support to draft v4 and making the list of discrepancies shorter. This has been solved for OpenAPI v3.1, but for those using OpenAPI v3.0, you can use this tool to solve [the divergence](https://apisyouwonthate.com/blog/openapi-and-json-schema-divergence).\n\n![Diagram showing data model (the objects, payload bodies, etc) and service model (endpoints, headers, metadata, etc)](https://cdn-images-1.medium.com/max/1600/0*hijIL-3Xa5EFZ783.png)\n\nThis tool sets out to allow folks to convert from JSON Schema (their one source of truth for everything) to OpenAPI (a thing for HTML docs and making SDKs).\n\n## Versions\n\n- **From:** [JSON Schema Draft v5 †](http://json-schema.org/specification-links.html#draft-5)\n- **To:** [OpenAPI 3.0](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md)\n\n_† Draft v5 is also known as Draft Wright 00, as the drafts are often named after the author, and this was the first one by A. Wright. Amongst other things, draft v5 aimed to rewrite the meta files, but the experiment failed, meaning we need to continue to use the draft v4 metafiles. Ugh._\n\n## Converting Back\n\nTo convert the other way, check out [openapi-schema-to-json-schema], which this package was based on.\n\n## Tests\n\nTo run the test-suite:\n\n```shell\nnpm test\n```\n\n## Treeware\n\nThis package is [Treeware](https://treeware.earth). If you use it in production, then we ask that you [**buy the world a tree**](https://plant.treeware.earth/{venfor}/{package}) to thank us for our work. By contributing to the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats.\n\n## Thanks\n\n- [Stoplight][] for [donating time and effort](https://stoplight.io/blog/companies-supporting-open-source/) to this project, and many more.\n- [mikunn][] for creating [openapi-schema-to-json-schema] which this is based on.\n- [Phil Sturgeon][] for flipping that conversion script about face.\n- [WeWork][] for giving this a home for a while.\n- [All Contributors][link-contributors]\n\n[mikunn]: https://github.com/mikunn\n[wework]: https://github.com/wework\n[stoplight]: https://stoplight.io/\n[phil sturgeon]: https://github.com/philsturgeon\n[openapi-schema-to-json-schema]: https://github.com/openapi-contrib/openapi-schema-to-json-schema\n[link-contributors]: https://github.com/openapi-contrib/json-schema-to-openapi-schema/graphs/contributors\n","readmeFilename":"README.md"}