aglio icon indicating copy to clipboard operation
aglio copied to clipboard

Request parameters breaking when examples and copy has underscores

Open earnaway opened this issue 9 years ago • 8 comments

I've noticed an issue when there are underscores as part of the params in the resources.

Here's an example:

## Resource Title [/resource/{id}/info{?status,order_by,sort,page,per_page}]

+ Parameters
    + id: 64 (required, string) - user id  or 'me'
    + status: paid (optional, string) - transaction status, one of pending, validated, paid, denied
    + order_by: transaction_date (optional, enum) - one of transaction_date, some_name, amount, user_status, status
    + sort: asc (optional, enum) - one of asc, desc
    + page: 1 (optional, integer) - pagination parameter
    + per_page: 5 (optional, integer) - pagination parameter

When running aglio against the above, I get the error:

>> Line 867: parameter 'order_by: transaction_date' not specified in 'Resource Title' its '/resource/{id}/info{?status,order_by,sort,page,per_page}' URI template (warning code 8)

But if I remove all the underscores from the "order_by" params and replace it with:

+ order_by: transactiondate (optional, enum) - one of transactiondate, somename, amount, userstatus, status

Then it works! I think the parser is breaking on underscores as parameters.

Anyone else come across this before?

earnaway avatar Sep 16 '15 13:09 earnaway

@earnaway interesting, this looks like an upstream bug in the parser. I'll try to investigate and see if it's still happening with the latest major release (which Aglio will be moving to in the near future).

danielgtaylor avatar Sep 18 '15 09:09 danielgtaylor

Thanks. Any idea how soon you might be moving the next major release?

earnaway avatar Sep 18 '15 10:09 earnaway

@earnaway the major breaking work on the C++ parser is done now with the release of Drafter 1.0.0 and Protagonist 1.0.0, however there are still some missing features and some bugs that won't break backward compatibility. Those are being worked on now, and the plan is to use an upcoming release of Fury in Aglio soon. It's at least a few weeks away, but it's going to come with some neat new possibilities like better support for MSON.

danielgtaylor avatar Sep 18 '15 12:09 danielgtaylor

can confirm, it's definitely breaking with underscores in the description.

This breaks:

+ Parameters
  + grant_type: `23123` (string, required) - The type of authentication, should be refresh_token

It appears as:

aglio-bad-underscore

ghost avatar Feb 08 '16 19:02 ghost

Anyone managed to find a workaround or get this fixed for underscores in the description?

earnaway avatar Oct 03 '16 11:10 earnaway

Hi @earnaway , I had same problem with aglio and found a solution at https://github.com/apiaryio/api-blueprint/issues/224 .

If you read the MSON spec, you can see that _ is a reserved character. Please use backticks to escape the whole word. Here is an example:

+ `some_thing`: `an_example_thing`

This solved my problem, I hope this helps you.

juno avatar Nov 10 '16 14:11 juno

That makes sense, would be cool to include examples of that in the docs 👍

ghost avatar Nov 10 '16 16:11 ghost

Thanks @juno, works perfectly now with a recent update!

earnaway avatar Nov 14 '16 16:11 earnaway