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

fix: add support for url parameters #47

Merged
merged 2 commits into from
Aug 20, 2020
Merged

Conversation

dannyifang
Copy link
Contributor

URL query params in schema are not supported and is automatically replaced with 'path' and marked as 'required' in the helper function.

fastify.get('/some-secrete-route/:id', {
  schema: {
    hide: true,
    params: {
      type: 'object',
      properties: {
        id: {
          type: 'string',
          description: 'user id'
        }
        urlParam: {
          in: 'query',
          type: 'string',
          description: 'optional url parameter'
        }
      }
    },
    response: {
      201: {
        description: 'Successful response',
        type: 'object',
        properties: {
          hello: { type: 'string' }
        }
      }
    },
  }
}, (req, reply) => {})
'''

Updated helper.js to account for param types that aren't paths.

@harveyconnor
Copy link

Also solves
#33

@dannyifang
Copy link
Contributor Author

Fix for #33 not in this request

@harveyconnor
Copy link

kk lgtm

@SkeLLLa
Copy link
Owner

SkeLLLa commented Aug 20, 2020

Could you please add some tests to be sure that all's working well? I'm not sure if fastify supports query string parameters declared in this way.

@dannyifang
Copy link
Contributor Author

I've added the test in genPaths

@SkeLLLa SkeLLLa merged commit 6a19600 into SkeLLLa:master Aug 20, 2020
@SkeLLLa
Copy link
Owner

SkeLLLa commented Aug 20, 2020

v3.0.2

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

Successfully merging this pull request may close these issues.

3 participants