Skip to content

Commit 623d88c

Browse files
author
Phil Sturgeon
committed
added scope to readme
fixes #6
1 parent 010c175 commit 623d88c

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

README.md

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# JSON Schema to OpenAPI Schema
22

3-
A little NodeJS package to convert JSON Schema to [OpenAPI Schema Objects](https://swagger.io/specification/#schemaObject).
3+
A little NodeJS package to convert JSON Schema to a [OpenAPI Schema Object](http://spec.openapis.org/oas/v3.0.3.html#schema-object).
44

55
## Features
66

@@ -13,15 +13,15 @@ A little NodeJS package to convert JSON Schema to [OpenAPI Schema Objects](https
1313
## Installation
1414

1515
```
16-
npm install --save json-schema-to-openapi-schema
16+
npm install --save @openapi-contrib/json-schema-to-openapi-schema
1717
```
1818

1919
## Usage
2020

2121
Here's a small example to get the idea:
2222

2323
```js
24-
const toOpenApi = require('json-schema-to-openapi-schema');
24+
const convert = require('@openapi-contrib/json-schema-to-openapi-schema');
2525

2626
const schema = {
2727
'$schema': 'http://json-schema.org/draft-04/schema#',
@@ -30,7 +30,7 @@ const schema = {
3030
};
3131

3232
(async () => {
33-
const convertedSchema = await toOpenApi(schema);
33+
const convertedSchema = await convert(schema);
3434
console.log(convertedSchema);
3535
})();
3636

@@ -60,25 +60,19 @@ If set to `true`, all local and remote references (http/https and file) $refs wi
6060

6161
## Why?
6262

63-
OpenAPI 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. Despite OpenAPI v3 closing the gap, the issue of JSON Schema divergence has not been resolved fully.
63+
OpenAPI 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).
6464

6565
![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)
6666

67-
Carefully writing JSON Schema for your data model kiiiinda works, but it is possible to write JSON Schema that creates invalid OpenAPI, and vice versa. For more on this, read the article [_OpenAPI and JSON Schema Divergence_](https://blog.apisyouwonthate.com/openapi-and-json-schema-divergence-part-1-1daf6678d86e).
68-
6967
This 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).
7068

7169
## Versions
7270

7371
- **From:** [JSON Schema Draft v5 †](http://json-schema.org/specification-links.html#draft-5)
74-
- **To:** [OpenAPI 3.0](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md)
72+
- **To:** [OpenAPI 3.0](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md)
7573

7674
_† 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._
7775

78-
## TODO
79-
80-
- [ ] Support later JSON Schema drafts via [cloudflare/json-schema-transformer] when it adds that functionality
81-
8276
## Converting Back
8377

8478
To convert the other way, check out [openapi-schema-to-json-schema], which this package was based on.
@@ -93,7 +87,7 @@ npm test
9387

9488
## Thanks
9589

96-
- [Stoplight][] for donating time and effort to this project, and many more.
90+
- [Stoplight][] for [donating time and effort](https://stoplight.io/blog/companies-supporting-open-source/) to this project, and many more.
9791
- [mikunn][] for creating [openapi-schema-to-json-schema] which this is based on.
9892
- [Phil Sturgeon][] for flipping that conversion script about face.
9993
- [WeWork][] for giving this a home for a while.
@@ -103,6 +97,5 @@ npm test
10397
[WeWork]: https://github.com/wework
10498
[Stoplight]: https://stoplight.io/
10599
[Phil Sturgeon]: https://github.com/philsturgeon
106-
[openapi-schema-to-json-schema]: https://github.com/mikunn/openapi-schema-to-json-schema
107-
[link-contributors]: https://github.com/openapi-js/json-schema-to-openapi-schema/graphs/contributors
108-
[cloudflare/json-schema-transformer]: https://github.com/cloudflare/json-schema-tools/blob/master/workspaces/json-schema-transform/README.md
100+
[openapi-schema-to-json-schema]: https://github.com/openapi-contrib/openapi-schema-to-json-schema
101+
[link-contributors]: https://github.com/openapi-contrib/json-schema-to-openapi-schema/graphs/contributors

0 commit comments

Comments
 (0)