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

paramters with underscore that have sample values with underscore do not work #311

Closed
bennettellis opened this issue Feb 12, 2016 · 7 comments

Comments

@bennettellis
Copy link

## Underscores [/somepath/{?template_type}]

### Get Underscores [GET]

Parameters
  + template_type: advocacy_post (string, required) the template type 
...

Doesn't work. Always interprets the end-to-end underscores as something strange and causes syntax errors. Attempts to escape them with %5f don't work because the parameter does not pass through properly in the console when making the request. The only thing that I've found that works is taking the second underscore out and making the parameter be this:
+ template_type: advocacy post (string, required) the template type
I can get by with that but it's not really good because the sample should have an underscore in it. All of the valid values for that parameter have an underscore in them, so I can only make it work by putting in a sample value that would never work.

@kylef
Copy link
Member

kylef commented Feb 12, 2016

Parameter keys and values which contains a reserved character (_) must be escaped (wrapped in backticks).

+ Parameters
    + `template_type`: `advocacy_post` (string, required) the template type

Note: There is a known issue [drafter#123] with using backticks in parameters.

@bennettellis
Copy link
Author

backticks don't solve the problem.

@zdne
Copy link
Contributor

zdne commented Feb 15, 2016

@kylef for what it is worth this is about parameters and not attributes (parameters are, for now, using a different parsing mechanism)

@pksunkara
Copy link
Contributor

@kylef's comment should be working now in drafter parser. It might not be deployed to Apiary though if you are not invited to beta MSON rendering. So, please follow #191 to know when this will be deployed to Apiary for everyone. I am closing this. Thanks.

@daniyel
Copy link

daniyel commented Apr 25, 2018

Hi.

Was this issue solved? I have similar problem where our session id has underscore and I am getting Parser warning that

specifying parameter 'appointment_hub_session_id (string, required, `ejMPAfFLPd2W_NCieglc4Y4hfBlPE4xI-IpwYNJOKMdBbXqiZGAJXfVL0icgmROgIs5V7GWBe5SSuusb1MFEQw' as required supersedes its default value, declare the parameter as 'optional' to specify its default value on line 51

Api blueprint:

+ Parameters

    + appointment_hub_session_id (string, required, `ejMPAfFLPd2W_NCieglc4Y4hfBlPE4xI-IpwYNJOKMdBbXqiZGAJXfVL0icgmROgIs5V7GWBe5SSuusb1MFEQw==`) - Id of appointment hub session.

If i change "_" to "-", everything works fine and I get no warnings.

Best regards.

@bennettellis
Copy link
Author

bennettellis commented Apr 25, 2018

Yes, I believe it was. At the time I entered this issue, backticks were not working for parameters. Not exactly sure when it was fixed, but I do know they work. You need to do something like the above referenced backtick escaping, so for me it was:

+ Parameters: 

    + `template_type`: `advocacy_post` (enum[string], required) - the template type

Your syntax is wrong though, so it's not just the backticks, it's also the way you've specified the parameter. You really want something like this (I added this into my own apiary doc temporarily to test, and it validated and works fine).

+ Parameters

    + `appointment_hub_session_id`: `ejMPAfFLPd2W_NCieglc4Y4hfBlPE4xI-IpwYNJOKMdBbXqiZGAJXfVL0icgmROgIs5V7GWBe5SSuusb1MFEQw==` (string, required) - Id of appointment hub session

Hope that helps.

Oh, also you should NOT escape the backticks in your URI template.

@daniyel
Copy link

daniyel commented Apr 25, 2018

@bennettellis Thank you for the prompt answer. Your solution worked.

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

5 participants