You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+66-5Lines changed: 66 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# OpenAPI Schema to JSON Schema
2
2
3
-
A little NodeJS package to convert OpenAPI Schema Object to JSON Schema.
3
+
A little NodeJS package to convert OpenAPI Schema Object or Parameter Object to JSON Schema.
4
4
5
5
Currently converts from [OpenAPI 3.0](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md) to [JSON Schema Draft 4](http://json-schema.org/specification-links.html#draft-4).
6
6
@@ -19,6 +19,7 @@ If you need to do the conversion in reverse, checkout [json-schema-to-openapi-sc
*~~converts [common named data types](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#data-types) to `type` and `format`~~*(removed in version 2.0.0)*
23
24
*~~for example `type: "dateTime"` becomes `type: "string"` with `format: "date-time"`~~
24
25
* deletes `nullable` and adds `"null"` to `type` array if `nullable` is `true`
@@ -76,7 +77,7 @@ If set to `false`, converts the provided schema in place. If `true`, clones the
76
77
#### `dateToDateTime` (boolean)
77
78
78
79
This is `false` by default and leaves `date` format as is. If set to `true`, sets `format: 'date'` to `format: 'date-time'`.
79
-
80
+
80
81
For example
81
82
82
83
```js
@@ -90,7 +91,7 @@ var convertedSchema = toJsonSchema(schema, {dateToDateTime: true});
90
91
console.log(convertedSchema);
91
92
```
92
93
93
-
prints
94
+
prints
94
95
95
96
```js
96
97
{
@@ -102,7 +103,7 @@ prints
102
103
103
104
#### `keepNotSupported` (array)
104
105
105
-
By default, the following fields are removed from the result schema: `nullable`, `discriminator`, `readOnly`, `writeOnly`, `xml`, `externalDocs`, `example` and `deprecated` as they are not supported by JSON Schema Draft 4. Provide an array of the ones you want to keep (as strings) and they won't be removed.
106
+
By default, the following fields are removed from the result schema: `nullable`, `discriminator`, `readOnly`, `writeOnly`, `xml`, `externalDocs`, `example` and `deprecated` as they are not supported by JSON Schema Draft 4. Provide an array of the ones you want to keep (as strings) and they won't be removed.
106
107
107
108
#### `removeReadOnly` (boolean)
108
109
@@ -113,7 +114,7 @@ If set to `true`, will remove properties set as `readOnly`. If the property is s
113
114
Similar to `removeReadOnly`, but for `writeOnly` properties.
114
115
115
116
#### `supportPatternProperties` (boolean)
116
-
117
+
117
118
If set to `true` and `x-patternProperties` property is present, change `x-patternProperties` to `patternProperties` and call `patternPropertiesHandler`. If `patternPropertiesHandler` is not defined, call the default handler. See `patternPropertiesHandler` for more information.
118
119
119
120
#### `patternPropertiesHandler` (function)
@@ -124,3 +125,63 @@ If the handler is not provided, the default handler is used. If `additionalPrope
124
125
125
126
See `test/pattern_properties.test.js` for examples how this works.
0 commit comments