Skip to content
This repository has been archived by the owner on Nov 8, 2024. It is now read-only.

Conversion of hyphens to %2d in API documentation #856

Open
gellati opened this issue Aug 11, 2017 · 5 comments
Open

Conversion of hyphens to %2d in API documentation #856

gellati opened this issue Aug 11, 2017 · 5 comments

Comments

@gellati
Copy link

gellati commented Aug 11, 2017

Describe your problem

I am not sure if this is a bug...

Concerning this issue #460 , I've tried encoding hyphens (-) as %2d in query parameters, because some APIs are not compliant with RFC 6570. However, %2d is further encoded to %252d, i.e. the percentage sign is further encoded. Is this a bug in the library, or part of expected behaviour? Or does this issue stem from the URI Template library.

I am trying to make a search query to an implementation of a healthcare API which provides this resource, the search/query parameter based-on can be seen at the bottom of the page: https://www.hl7.org/fhir/careplan.html

Converting hyphens to %2d might not be the best way to tackle this problem, but right now I would just like to know where error message originates from.

What command line options do you use?

$ dredd

What is in your dredd.yml?

# documentation about options can be read in https://github.com/apiaryio/dredd/blob/master/src/options.coffee
dry-run: null #null, true
hookfiles: ./hooks/hook.*
language: nodejs
sandbox: false
server: null
server-wait: 3
init: false
custom: {}
names: false
only: []
reporter: []
output: []
header: []
sorted: false
user: null
inline-errors: false
method: []
color: true
level: verbose # verbose, info
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
config: ./dredd.yml
blueprint: ./kapa-api/kapa-api.yaml
endpoint: 'https://localhost:6082'
#endpoint: 'https://oda.medidemo.fi'

What's your dredd --version output?

dredd v4.1.2 (Linux 4.11.12-200.fc25.x86_64; x64)

Does dredd --level=debug uncover something?

Parameter not defined in API description document: based%252don

Can you send us failing test in a Pull Request?

@gellati
Copy link
Author

gellati commented Aug 11, 2017

The spec gives these:

varchar       =  ALPHA / DIGIT / "_" / pct-encoded

where

ALPHA          =  %x41-5A / %x61-7A   ; A-Z / a-z
DIGIT          =  %x30-39             ; 0-9
pct-encoded    =  "%" HEXDIG HEXDIG
HEXDIG         =  DIGIT / "A" / "B" / "C" / "D" / "E" / "F"   ; case-insensitive

I guess the percentage sign is not part of the spec. So this behaviour is then expected?

@honzajavorek
Copy link
Contributor

Hi, this somehow slipped through my notifications 🙀 I'm going to take a look at this right away.

@honzajavorek honzajavorek changed the title :bug Conversion of hyphens to %2d in API documentation Conversion of hyphens to %2d in API documentation Aug 18, 2017
@honzajavorek
Copy link
Contributor

@gellati Would you please share the relevant piece of your Swagger document here? The #460 and #481 issues might be relevant to this one, but they're talking about API Blueprint. I see from your dredd.yml that you're using ./kapa-api/kapa-api.yaml as your API description document, which would be Swagger, I believe. From the top of my head I'm not sure how this topic is handled in the Fury adapter for Swagger, so it would be best to have an example of what exactly you have defined in your description.

@honzajavorek
Copy link
Contributor

@gellati Any updates on this?

@lorangf
Copy link

lorangf commented Nov 3, 2017

Test.txt
I am also having issues when using '[' and ']' as part of query parameter names. Our APIs have been documented in apiary using the swagger specs, and the query parameter names show up fine in the documentation it generates. However, when using dredd to validate the docs against our application server, we are getting a warning from dredd and the endpoint is skipped.

For example, one of our query parameter in our swagger file is defined as:
name: filter[contents][role]

When running dredd, we are getting the following error:
warn: Compilation warning in file 'Content.yaml': Ambiguous URI parameter in template: /libraries{?filter%5Bcontents%5D%5Brole%5D} Parameter not defined in API description document: filter%5Bcontents%5D%5Brole%5D (Library > /libraries > GET)

Dredd Version:
dredd v4.6.1 (Linux 4.10.0-38-generic; x64)

Attached is a simple yaml test file that illustrate the issue (rename .txt to .yaml), which can be run with the option --dry-run to reproduce by running:
dredd Test.yaml http://localhost:8080 --dry-run

If I use url encoded query param in the yaml file, the param name shows up decoded in apiary but dredd is still complaining about the same error except that this time the paramater appears to be encoded twice:
warn: Compilation warning in file 'Test.yaml': Ambiguous URI parameter in template: /api/pets{?tags,limit,filter%255Bcontents%255D%255Brole%255D} Parameter not defined in API description document: filter%255Bcontents%255D%255Brole%255D ( > /api/pets > GET)

Maybe my issue is more related to #481...

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Projects
None yet
Development

No branches or pull requests

3 participants