Api-blueprint: paramters with underscore that have sample values with underscore do not work

Created on 12 Feb 2016  ·  7Comments  ·  Source: apiaryio/api-blueprint

## 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.

Language Awaiting Validation Question

Most helpful comment

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._

All 7 comments

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._

backticks don't solve the problem.

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

@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.

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.

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.

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

robbinjanssen picture robbinjanssen  ·  6Comments

zatziky picture zatziky  ·  4Comments

spark-developer picture spark-developer  ·  12Comments

rodriguise picture rodriguise  ·  11Comments

fh-thudson picture fh-thudson  ·  3Comments