File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -35,13 +35,14 @@ If you need to do the conversion in reverse, checkout [json-schema-to-openapi-sc
35
35
npm install --save openapi-schema-to-json-schema
36
36
```
37
37
38
- ## Usage
38
+ ## Converting OpenAPI schema
39
39
40
40
Here's a small example to get the idea:
41
41
42
42
``` js
43
43
44
44
var toJsonSchema = require (' openapi-schema-to-json-schema' );
45
+ // OR: toJsonSchema = require('openapi-schema-to-json-schema').fromSchema;
45
46
46
47
var schema = {
47
48
type: ' string' ,
@@ -125,22 +126,28 @@ If the handler is not provided, the default handler is used. If `additionalPrope
125
126
126
127
See ` test/pattern_properties.test.js ` for examples how this works.
127
128
128
- # Converting OpenAPI parameters
129
+ ## Converting OpenAPI parameters
129
130
130
- OpenAPI parameters can be converted.
131
+ OpenAPI parameters can be converted:
131
132
132
133
``` js
133
- {
134
+ var toJsonSchema = require (' openapi-schema-to-json-schema' ).fromParameters ;
135
+
136
+ var param = {
134
137
name: ' parameter name' ,
135
138
in: ' query' ,
136
139
schema: {
137
140
type: ' string' ,
138
141
format: ' date'
139
142
}
140
143
}
144
+
145
+ var convertedSchema = toJsonSchema (param);
146
+
147
+ console .log (convertedSchema);
141
148
```
142
149
143
- would be converted to :
150
+ The result is as follows :
144
151
145
152
``` js
146
153
{
You can’t perform that action at this time.
0 commit comments