Skip to content

Commit 6f243bc

Browse files
author
Mathieu Anderson
authored
docs(api): Add docs folder at root, add OpenAPI spec docs (#884)
- Add Documentation section in REAMDE - Add docs folder at root, add OpenAPI spec docs --------- Signed-off-by: Mathieu Anderson <[email protected]>
1 parent 3652fa3 commit 6f243bc

File tree

5 files changed

+24
-1
lines changed

5 files changed

+24
-1
lines changed

CONTRIBUTING.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ __1. Every PR has to be releasable__
105105

106106
- Every PR that is merged on `main` should be treated like we release it into production right away.
107107
- The `main` branch should always be in a state where it can be deployed and used right away.
108+
- If API changes were made, ensure the `openapi.yaml` spec was generated and added to the commit, and that the frontend types have been generated with `pnpm extract-api-types`. [Read about why here](./docs/openapi.md).
109+
- All GitHub actions checks must be green.
108110

109111
__2. A clear goal with a small scope__
110112

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,12 @@ For the versions available, see the [tags on this repository](https://github.com
9999

100100
- Help Wizard to setup Klaw
101101

102-
- Documentation : https://klaw-project.io/docs
102+
## Documentation
103+
104+
- User documentation : https://klaw-project.io/docs
105+
- Technical documentation for contributors:
106+
- general documentation: [`./docs`](./docs)
107+
- specific documentation for the React app `coral`: [`./coral/docs`](./coral/docs)
103108

104109
## Install
105110

docs/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## Table of content
2+
3+
- [API source of truth: OpenAPI spec](openapi.md)

docs/generation_schema.png

134 KB
Loading

docs/openapi.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
## What is the Klaw API source of truth?
2+
3+
The OpenAPI spec `./openapi.yaml` at the root of the project is our source of truth. It is _auto-generated_ from the current state of the API code when `mvn verify` is ran from `core`, and is therefore always up to date with the current state of the API.
4+
5+
We use this OpenAPI spec as a source for the generation of the TypeScript types the frontend relies on to accurately type our business logic (mainly in [the `.coral/domain` folder](../coral/docs/directory-structure.md#first-level-domain-folder)). The script to generate those types is `extract-api-types` in `coral/package.json`, and the output can be seen in `coral/types/api.d.ts`.
6+
7+
Therefore, every time the API changes, the OpenAPI spec will change, and the generated types for the frontend will keep in sync with the evolution of the API.
8+
9+
## Generating the OpenAPI spec and TypeScript types
10+
11+
This is a high level diagram of the process described above.
12+
13+
![Diagram illustrating the flow described in the previous paragraph](./generation_schema.png)

0 commit comments

Comments
 (0)