sway
sway copied to clipboard
path templating parameter name include '-' would caused validateRequest failed
I create a swagger with path templating , and one parameter name is 'key-name' e.g.
"paths": {
"/keys/{key-name}/create": {
"post": {
"parameters": [
{
"name":"key-name"
the request validate would always failed with result below:
{ code: 'MISSING_REQUIRED_PARAMETER',
message: 'Value is required but was not provided',
schemaPath: '#/paths/~1keys~1{key+name}~1create/post/parameters/0' }
Since I refer to the swagger specification document , but I did not find any information about the parameter name could not include special character like '-'
I'll take a peek. I'm not sure why it would fail. Can you give more details on how you tested this? (The weird schemaPath value isn't from sway but z-schema and it shouldn't mislead you.) Can you give the full parameter definition and the requested path made? Or maybe even a simple reproduction snippet of code?
I'll take a peek. I'm not sure why it would fail. Can you give more details on how you tested this? (The weird
schemaPathvalue isn't fromswaybutz-schemaand it shouldn't mislead you.) Can you give the full parameter definition and the requested path made? Or maybe even a simple reproduction snippet of code?
Since I have debug it, below code goes wrong , that caused the validator consider the parameter missed https://github.com/apigee-127/sway/blob/e9ad6e81af41f526567e9d5a0f150e59e429e513/lib/types/path.js#L95
I think it caused by the path-to-regexp , per https://github.com/pillarjs/path-to-regexp, parameter names must use "word characters" ([A-Za-z0-9_]).