- type allow in: query,path,body,formData,header
- schema standard or convenient jsonschema
const standard = {
required: [
'name',
],
properties: {
name: {
type: 'string',
description: 'xxx',
},
age: {
type: 'integer',
format: 'int32',
max: 100,
min: 1,
}
}
};
jsonSchemaToParameters('query', standard)
[
{
"name": "name",
"in": "query",
"required": true,
"type": "string",
"description": "xxx"
},
{
"name": "age",
"in": "query",
"required": false,
"type": "integer",
"format": "int32",
"max": 100,
"min": 1
}
]
const convenient = {
name: {
type: 'string',
required: true,
description: 'xxx',
},
age: {
type: 'integer',
format: 'int32',
max: 100,
min: 1,
},
};
jsonSchemaToParameters('query', convenient)
[
{
"name": "name",
"in": "query",
"required": true,
"type": "string"
},
{
"name": "age",
"in": "query",
"required": false,
"type": "integer",
"format": "int32"
}
]
-
result
{object}
header
{object}
header JSON-Schemaquery
{object}
query JSON-Schemabody
{object}
body JSON-Schemapath
{object}
path JSON-Schemaformdata
{object}
formdata JSON-Schema
-
options
{object}
lowercaseHeader
{boolean}
defaultfalse