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

API option handling #2758

Closed
sebgie opened this issue May 14, 2014 · 0 comments
Closed

API option handling #2758

sebgie opened this issue May 14, 2014 · 0 comments
Labels
affects:api Affects the Ghost API

Comments

@sebgie
Copy link
Contributor

sebgie commented May 14, 2014

Refs #2187

In our current implementation wrong or misused options are removed and the request is carried out without the options. This behavior makes our lives a bit easier in regards to error handling but invalid values for valid options should not be accepted and return 400 Bad Request.

Request parameters that are not supported at all could be ignored as most other web applications do.

Example:

Request: GET /ghost/api/v0.1/posts/?status=green
Result: 400, 'green is an invalid status'

Request: GET /ghost/api/v0.1/posts/?test=true
Result: same result as GET /ghost/api/v0.1/posts/

For internal API requests a new error class (InvalidOptionError) could be introduced.

@ErisDS ErisDS added the api label May 14, 2014
@ErisDS ErisDS added this to the Future milestone May 14, 2014
@ErisDS ErisDS added later [triage] Things we intend to work but are not immediate priority apps and removed apps later [triage] Things we intend to work but are not immediate priority labels Jun 26, 2015
ErisDS added a commit to ErisDS/Ghost that referenced this issue Jun 28, 2015
refs TryGhost#2758

- Post, Tag & User API methods are refactored to use pipeline
- Each functional code block is a named task function
- Each function takes options, manipulates it, and returns options back
- Tasks like permissions can reject if they don't pass, causing the pipeline to fail
- Tasks like validating and converting options might be abstracted out into utils - the same for each endpoint
- Tasks like the data call can be extremely complex if needs be (like for some user endpoints)
- Option validation is mostly factored out to utils
- Option conversion is factored out to utils
- API utils have 100% test coverage
- Minor updates to inline docs, more to do here
@ErisDS ErisDS mentioned this issue Jun 30, 2015
31 tasks
ErisDS added a commit to ErisDS/Ghost that referenced this issue Jul 14, 2015
refs TryGhost#2758

- add a set of default options to utils
- update validation function to only pass through permitted options
- pass permitted options into validate where necessary
- setup basic validation for each known option, and generic validation for the remainder
- change slug to treat 'name' as data, rather than an option
@ErisDS ErisDS modified the milestone: Current Backlog Oct 9, 2015
@ErisDS ErisDS mentioned this issue Oct 20, 2015
24 tasks
@ErisDS ErisDS added the later [triage] Things we intend to work but are not immediate priority label Sep 20, 2016
@ErisDS
Copy link
Member

ErisDS commented Sep 20, 2016

I'm closing most API issues temporarily with the later label.

JSON API Overhaul & OAuth access are currently scheduled next on the roadmap

@ErisDS ErisDS closed this as completed Sep 20, 2016
@ErisDS ErisDS removed later [triage] Things we intend to work but are not immediate priority labels Jan 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects:api Affects the Ghost API
Projects
None yet
Development

No branches or pull requests

2 participants