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
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 https://github.com/apiaryio/dredd/issues/1012, https://github.com/apiaryio/dredd/issues/856, https://github.com/apiaryio/dredd/issues/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.
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.
This should be fixed in Dredd now, I forgot to close this one.
Most helpful comment
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.