When creating a rest api using swagger2 (openAPI), I want to allow the param_id parameter to request the following:
- ? station_id = 23 (returns station 23)
- ? station_id = 23.45 (returns stations 23 and 45)
- ? station_id = [3:14] (returns stations 3 through 14)
- ? station_id = 100% (% s act as wildcards, so they return things like 1001, 10049, etc.).
I use the following swagger definition (array of strings) as an attempt to do the following:
parameters:
- name: station_id
in: query
description: filter stations by station_id
required: false
type: array
items:
type: string
With this definition, all the previous examples work, with the exception of? station_id = 23, because the validation check fails with the following message:
{
"message": "Validation errors",
"errors": [
{
"code": "INVALID_REQUEST_PARAMETER",
"errors": [
{
"code": "INVALID_TYPE",
"params": [
"array",
"integer"
],
"message": "Expected type array but found type integer",
"path": [],
"description": "filter stations by station_id"
}
],
"in": "query",
"message": "Invalid parameter (station_id): Value failed JSON Schema validation",
"name": "station_id",
"path": [
"paths",
"/stations",
"get",
"parameters",
"0"
]
}
]
}
, station_id ? station_id = '23 ', . . - union , , .
//{id}, , ( ) , , . , station_latitude.
- , (regex) - ? swagger , ? nodejs swagger-node swagger-express-mw 0.7.0.