Skip to content

Commit 929c1ca

Browse files
committed
update README
1 parent 9476a97 commit 929c1ca

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

README.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,14 @@ If you need to do the conversion in reverse, checkout [json-schema-to-openapi-sc
3535
npm install --save openapi-schema-to-json-schema
3636
```
3737

38-
## Usage
38+
## Converting OpenAPI schema
3939

4040
Here's a small example to get the idea:
4141

4242
```js
4343

4444
var toJsonSchema = require('openapi-schema-to-json-schema');
45+
// OR: toJsonSchema = require('openapi-schema-to-json-schema').fromSchema;
4546

4647
var schema = {
4748
type: 'string',
@@ -125,22 +126,28 @@ If the handler is not provided, the default handler is used. If `additionalPrope
125126

126127
See `test/pattern_properties.test.js` for examples how this works.
127128

128-
# Converting OpenAPI parameters
129+
## Converting OpenAPI parameters
129130

130-
OpenAPI parameters can be converted.
131+
OpenAPI parameters can be converted:
131132

132133
```js
133-
{
134+
var toJsonSchema = require('openapi-schema-to-json-schema').fromParameters;
135+
136+
var param = {
134137
name: 'parameter name',
135138
in: 'query',
136139
schema: {
137140
type: 'string',
138141
format: 'date'
139142
}
140143
}
144+
145+
var convertedSchema = toJsonSchema(param);
146+
147+
console.log(convertedSchema);
141148
```
142149

143-
would be converted to:
150+
The result is as follows:
144151

145152
```js
146153
{

0 commit comments

Comments
 (0)