apiaryio / api-blueprint

API Blueprint
https://apiblueprint.org
MIT License
8.63k stars 2.14k forks source link

Different parameters for different actions in the same resource #418

Open fgblomqvist opened 6 years ago

fgblomqvist commented 6 years ago

I have the same issue as #40. It's a very old one but there is no clear solution to it. Some docs were referred to at the end that are now gone, and I am experiencing the exact same thing.

This is some sample code:

## Courses [/courses?quarter_id={quarter_id}&professor_id={professor_id}]

### List All Courses [GET]

+ Parameters
    + quarter_id (optional, number) - Limit the list to courses that were taught during the specified quarter
    + professor_id (optional, number) - Limit the list to courses that were taught by the specified professor

+ Response 200 (application/json)

### Post Courses [POST]

+ Response 200 (application/json)

Despite that the POST does not have any parameters, the URL still gets rendered like this: screenshot from 2018-02-23 12-51-00

If I remove the parameters from the URL in the doc, naturally they don't show up for any action. How are you supposed to do it? There is no clear way documented in the docs for API Blueprint/Apiary.

I would have expected to leave the parameters out and then have Apiary just automatically insert them for each action.

kylef commented 6 years ago

See below, you can define the URI Template with parameters specific to the action within the action.

## Courses [/courses]

### List All Courses [GET /courses{?quarter_id,professor_id}]

+ Parameters
    + `quarter_id` (optional, number) - Limit the list to courses that were taught during the specified quarter
    + `professor_id` (optional, number) - Limit the list to courses that were taught by the specified professor

+ Response 200 (application/json)

### Post Courses [POST]

+ Response 200 (application/json)
fgblomqvist commented 6 years ago

Oh I see, tried something similar but put a comma between the GET and the URI. I think this should be made clearer in the docs. Not sure how much you guys control it, but in the Polls API they don't do this, they just let it render incorrectly.