Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

path templating parameter name include '-' would caused validateRequest failed #221

Open
jianyexi opened this issue Mar 12, 2020 · 2 comments

Comments

@jianyexi
Copy link

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 '-'

@whitlockjc
Copy link
Member

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?

@jianyexi jianyexi reopened this Mar 12, 2020
@jianyexi
Copy link
Author

jianyexi commented Mar 12, 2020

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?

Since I have debug it, below code goes wrong , that caused the validator consider the parameter missed

this.regexp = pathToRegexp(sanitizedPath, {sensitive: true});

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_]).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants