swagger-node-runner
swagger-node-runner copied to clipboard
Path param of type array[integer] always fails on length 1
Swagger YAML Def:
/Permission:
x-swagger-router-controller: permission
get:
tags: ['Permissions']
description: Get either all permissions or a permission with a specific id
operationId: getPermissions
parameters:
- $ref: "#/parameters/NodeIDs"
responses:
"200":
description: Success
schema:
type: array
items:
$ref: "#/definitions/Permission"
default:
description: Error
schema:
$ref: "#/definitions/ErrorResponse"
parameters:
NodeIDs:
name: ids
in: query
description: A list of node ids (integers).
type: array
items:
type: integer
Example command: curl -k https://0.0.0.0:3000/Permission?ids=123
Error:
{"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":"A list of node ids (integers)."}],"in":"query","message":"Invalid parameter (ids): Value failed JSON Schema validation","name":"ids","path":["paths","/Permission","get","parameters","1"]}]}
However the following works: curl -k https://0.0.0.0:3000/Permission?ids=1231,1231
The following behavior does not hold true when the yaml def changes to the following:
parameters:
NodeIDs:
name: ids
in: query
description: A list of node ids (integers).
type: array
items:
type: string
However, I receive an error when I try to put an integer 1231 into a string.
I'd really love for a resolution to this.
Best, Dan
Hi Dan,
Thanks for your report! I agree, that looks like a real issue. Unfortunately, this project doesn't handle OpenAPI validation. It will have to be addressed in this underlying library: https://github.com/apigee-127/sway.
Best, Scott
The sway library has a PR that will fix this issue, but it hasn't been merged yet. If you want to take advantage of it you can use npm and install it using the following command:
npm install https://github.com/apigee-127/sway.git#918b22e --save
Cheers!