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

Different parameters for different actions in the same resource #418

Open
fgblomqvist opened this issue Feb 23, 2018 · 2 comments
Open

Different parameters for different actions in the same resource #418

fgblomqvist opened this issue Feb 23, 2018 · 2 comments

Comments

@fgblomqvist
Copy link

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
Copy link
Member

kylef commented Feb 23, 2018

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
Copy link
Author

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.

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

2 participants