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

Dredd skips transaction if there is dotted query parameter #1256

Closed
alikh31 opened this issue Feb 28, 2019 · 3 comments
Closed

Dredd skips transaction if there is dotted query parameter #1256

alikh31 opened this issue Feb 28, 2019 · 3 comments

Comments

@alikh31
Copy link

alikh31 commented Feb 28, 2019

If you have a route with a query parameter that has a dot (.) on its name like "filter.test" dredd gives a warning

Compilation warning in file 'api/swagger/swagger.yaml': Ambiguous URI parameter in template: /me{?filter%2etest}
Parameter not defined in API description document: filter%2etest ( > /me > GET) 

and skips the route.

To Reproduce
Given the following swagger file:

swagger: "2.0"

info:
  version: '1'
  title: test

host: localhost:3000
basePath: /

schemes:
  - http

consumes:
  - application/json

paths:
  /me:
    get:
      description: Get
      parameters:
        - in: query
          name: filter.test
          type: string
      responses:
        '200':
          description: OK

dredd will give the warning and skips the route
Expected behavior
Its expected dredd behaves as the name does not have a dot and run the test over the route

What is in your dredd.yml?

dry-run: null
language: nodejs
sandbox: false
server: "node index.js"
server-wait: 3
init: false
names: false
only: []
output: []
header: []
sorted: false
user: null
inline-errors: false
details: false
method: []
color: true
loglevel: debug
timestamp: false
silent: false
path: []
hooks-worker-timeout: 5000
hooks-worker-connect-timeout: 1500
hooks-worker-connect-retry: 500
hooks-worker-after-connect-wait: 100
hooks-worker-term-timeout: 5000
hooks-worker-term-retry: 500
hooks-worker-handler-host: localhost
hooks-worker-handler-port: 61325
config: ./dredd.yml
blueprint: api/swagger/swagger.yaml
endpoint: 'http://localhost:3000'

What's your dredd --version output?

dredd v8.0.3 (Darwin 18.2.0; x64)

Does dredd --loglevel=debug uncover something?
not much, just the following:

2019-02-28T12:38:27.265Z - debug: Compiling HTTP transactions from API description file: api/swagger/swagger.yaml
2019-02-28T12:38:27.322Z - warn: Compilation warning in file 'api/swagger/swagger.yaml': Ambiguous URI parameter in template: /me{?filter%2etest}
Parameter not defined in API description document: filter%2etest ( > /me > GET)

Can you send us failing test in a Pull Request?
yes

@honzajavorek
Copy link
Contributor

Hi @alikh31! 🙋‍♂️ Nice to still see you around the Apiary realm 🙂

I believe the bug you're experiencing is a problem with encoding/decoding URI parameters we already have around. I think related issues are #1012, #856, #481.

I'd say the bug happens somewhere here and is caused by the fact that the parameter name can/must be encoded in the URI template, but isn't encoded in the parameters list, so Dredd doesn't correctly match them together.

I wanted to focus on fixing this soon, together with agreement with @apiaryio/adt that the parser would always provide a valid and correctly encoded URI template, regardless what the user provides. In that case Dredd could just decode the parameter name from the template and deterministically match it with the name provided in the parameters list.

@alikh31
Copy link
Author

alikh31 commented Mar 4, 2019

Hey @honzajavorek, thanks for the detailed response. I added a quick fix, please do have a look and let me know if it makes sense.

@honzajavorek
Copy link
Contributor

This should be fixed in Dredd now, I forgot to close this one.

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

No branches or pull requests

2 participants