open-api
open-api copied to clipboard
[openapi-jsonschema-parameters] Some Openapi Schema in Path Parameters cannot be converted to JSON schema
The converter fails to convert some openapi schema, such as the one shown below:
const parametersSchemas = convertParametersToJSONSchema([
{
"name": "id_or_uri",
"in": "path",
"description": "The id or uri of the resource",
"required": true,
"schema": {
"oneOf": [
{
"type": "string",
"pattern": "^[0-9a-km-zA-HJ-Z]{7}$"
},
{
"type": "string",
"pattern": "^prefix:[0-9]{6,12}$"
}
]
}
}
]);
console.log(parametersSchema)
{
path: {
properties: {
id_or_uri: {}
},
required: [ 'id_or_uri' ]
}
}
I haven't dug very deep into the source code yet, but I am curious what's the rationale behind this behavior.
Please investigate further and open a PR!
can confirm that pattern validation is not working for:
ObjectId:
type: string
pattern: /^[a-f\d]{24}$/i
id:
in: path
name: id
schema:
$ref: '#/components/schemas/ObjectId'
please open a PR @I-ko, if you have time