dreamish/api
momijizukamori a0ca65ee1b
API tooling (#3033)
* Updates to API generation and tooling

- Added build script and build instructions for API files
- Updated `.gitignore` to keep node_module folders out, wherever they occur
- Rewrite existing YAML files to use new component system
- Compile rewritten YAML files
- Add more validation checks to the route builders and dispatchers
- Add a user-facing documentation page with interactive view using RapiDoc
- Add a generic 404 handler for missing routes under `/api`, which returns JSON instead of HTML
- Clean up spec output route slightly to make it valid OpenAPI 3.0.0

* Auto-fill API Key in docs

Co-authored-by: Cocoa <momijizukamori@gmail.com>
2023-01-03 22:42:09 -08:00
..
dist API tooling (#3033) 2023-01-03 22:42:09 -08:00
src API tooling (#3033) 2023-01-03 22:42:09 -08:00
README.md API tooling (#3033) 2023-01-03 22:42:09 -08:00
build.js API tooling (#3033) 2023-01-03 22:42:09 -08:00
package-lock.json API tooling (#3033) 2023-01-03 22:42:09 -08:00
package.json API tooling (#3033) 2023-01-03 22:42:09 -08:00

README.md

This folder contains the YAML files used to generate and validate OpenAPI routes for Dreamwidth, and to build the spec file supplied to end users. src contains the files you should edit - reusable components should go into src\components\ and can then be referenced using JS Schema reference notation (eg, $ref: components/schemas/username.yaml). This cuts down on items that need to be retyped, and keeps descriptions of items consistent across different endpoints. dist contains the compiled YAML files that are used by the Perl endpoint controllers. Because YAML has no mechanism for file includes, there is unfortunately still a manual step required to rebuild the dist files when the src files are changed. First install node and then the necessary packages (npm install from inside this folder), and then run the build.js file (node build.js). This will compile the YAML files, and print any errors encountered along the way to the terminal.