bcgov / cas-reporting

This is for the Clean Growth Digital Services team for work related to reporting.
Apache License 2.0
0 stars 0 forks source link

Documentation: API routes and file structure #347

Open pbastia opened 1 month ago

pbastia commented 1 month ago

Description:

After what was discussed during the API meeting and dev team agreements, we need to document in the API docs (docs/backend/api-design.md):

1) API routes don't need to mirror frontend routes. They should match the object they're fetching

GET "object-to-be-fetched/{id}"
GET "object-to-be-fetched?some_param=123&other_param=..."

example:
GET "report-version/{version_id}"
GET "facility-report/{facility_report_id}" OR "facility-report?...params..."

URI stands for "Uniform Resource Identifier" : the path should point at the resource we're dealing with
The payload/query params then can be used to filter, generate or modify the resource

2) API files should minimize the amount of routes they declare for readability & testability. Rule of thumb is one file per resource with GET PUT POST ...

example: report-version.py

File path can include subdirectories following the API endpoint's URL.

Acceptance Criteria:

Given I am a developer When I make a new API endpoint Then I know which route to assign to it, how parameters will be queried, and in which file to write it

Development Checklist:

Definition of Ready (Note: If any of these points are not applicable, mark N/A)

Definition of Done (Note: If any of these points are not applicable, mark N/A)

Notes:

-

pbastia commented 1 month ago

@Sepehr-Sobhani for API team visibility

Sepehr-Sobhani commented 1 month ago

In case we want to include it in docs: Path Parameters vs. Query Parameters We have used query params for paginating and sorting a list of items for a specific data grid.