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

Skipped tests when using square brackets in get parameter name #1908

Open
fessmage opened this issue Mar 11, 2021 · 5 comments
Open

Skipped tests when using square brackets in get parameter name #1908

fessmage opened this issue Mar 11, 2021 · 5 comments

Comments

@fessmage
Copy link

Describe the bug
Skipped tests when using square brackets in get parameter name

warn: API description URI template expansion warning in /api/api.apib (FooBar API > Foo > Foo): Ambiguous URI parameter in template: /foo{?bar%5B%5D}
Parameter not defined in API description document: bar[]
complete: Tests took 1ms

To Reproduce
docker image apiaryio/dredd:14.0.0

api blueprint:

FORMAT: 1A

# FooBar API

## Foo [/foo{?bar%5B%5D}]

+ Parameters
    + bar%5B%5D: `foobar`

### Foo [GET /foo{?bar%5B%5D}]

+ Response 200

Expected behavior
Successful test run with output

pass: GET (200) /foo?bar%5B%5D=foobar duration: 504ms
complete: 1 passing, 0 failing, 0 errors, 0 skipped, 1 total
complete: Tests took 509ms

What's your dredd --version output?

dredd v14.0.0 (Linux 5.4.72-microsoft-standard-WSL2; x64)
@jmendes92
Copy link

Got the same issue for the description below using dredd v14.1.0 (Linux 5.10.102.1-microsoft-standard-WSL2; x64)

FORMAT: 1A

# Foo API

## Group Pagination

### Get paginate foos [GET /foos{?page%5Bnumber%5D}{&page%5Bsize%5D}]

+ Parameters

    + page%5Bnumber%5D: `1` (number, optional) - Number of the page.
        + Default: `1`
    + page%5Bsize%5D: `2` (number, optional) - Number of items in each page.
        + Default: `50`

Changed the description to:

FORMAT: 1A

# Foo API

## Group Pagination

### Get paginated foos [GET /foos{?page%5Bnumber%5D}{&page%5Bsize%5D}]

+ Parameters

    + page[number]: `1` (number, optional) - Number of the page.
        + Default: `1`
    + page[size]: `2` (number, optional) - Number of items in each page.
        + Default: `50`

The warning was still logged but the tests were able to run.

image

But then it as aglio who was not happy with that change, even though the html file was properly generated 🤷🏼‍♂️

>> Line 7: parameter 'page[number]' is not found within the URI template '/foos{?page%5Bnumber%5D}{&page%5Bsize%5D}' for 'Get paginated foos'  (warning code 8)
>> Context
...
>> Line 7: parameter 'page[size]' is not found within the URI template '/foos{?page%5Bnumber%5D}{&page%5Bsize%5D}' for 'Get paginated foos'  (warning code 8)
>> Context
...

@jmendes92
Copy link

My bad the test success was pure luck. The parameters were missing in the query, just forgot to update the response body 🤦🏼‍♂️.

@deivid11
Copy link

Looks like there was a "related" fix to allow dots on request parameters but it does not actually fix this bug.

@deivid11
Copy link

The issue is affecting Open Api v3, on swagger 2.0 is working fine.

@deivid11
Copy link

The openApi parser (@apielements/openapi3-parser) is encoding the parameter name, so the parameter is never found on the available parameters.

One solution could be changing the openapi3-parse to return the parameters as the openapi2 parser, this could have more implications I don't already know.
Another solution is to decode the parameter names after getting the parsing result, maybe on this line

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

3 participants