From 84a306c3687e9f4c06029b591a8b329b0b84f1bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Bardon?= Date: Tue, 6 Feb 2024 15:06:07 +0100 Subject: [PATCH] docs: ADR: Automatically detect OpenAPI routes --- ...2023-12-18-b-auto-detect-openapi-routes.md | 60 +++++++++++++++++++ ADRs/README.md | 1 + 2 files changed, 61 insertions(+) create mode 100644 ADRs/2023-12-18-b-auto-detect-openapi-routes.md diff --git a/ADRs/2023-12-18-b-auto-detect-openapi-routes.md b/ADRs/2023-12-18-b-auto-detect-openapi-routes.md new file mode 100644 index 00000000..f4d5ed15 --- /dev/null +++ b/ADRs/2023-12-18-b-auto-detect-openapi-routes.md @@ -0,0 +1,60 @@ +# ADR: Automatically detect OpenAPI routes + +- Date: **2023-12-18** +- Author: **Rémi Bardon <[remi@remibardon.name](mailto:remi@remibardon.name)>** + +- Status: **Proposed** + +- Relates to: + - [Describe Prose Pod API using the OpenAPI Specification](./2023-12-18-a-describe-with-openapi.md) (2023-12-18) + +- Superseded by: ø + +- Deprecated: No + +## Context + + + +The [Rocket] web framework [requires us to maintain an exhaustive list of all routes][rocket-routes-list]. +The [utoipa] crate, which we use to generate an [OpenAPI Specification], requires us to maintain +another exhaustive list. This will inevitably lead to desynchronization and thus incoherence +between the code and the [OpenAPI Specification]. + +## Decision + + + +We will use the [utoipauto] crate, +downloaded 1,418 times on [crates.io] at the time of writing this ADR +and weighing only 9.08 KiB (on `v0.1.8`). + +This crate is in its very early stages, with multiple new releases in the past few weeks. +However, it already has the features we need so we can use it without worrying about breaking changes. + +## Consequences + + + +Using [utoipauto] will allow us to not have to maintain a second exhaustive list of routes, +which will increase productivity and avoid inconsistencies. + +As always when adding dependencies, this decision will increase compile time and attack surface. +Fortunately, the [utoipauto] crate is very small so it is negligeable. + +Finally, as the crate is very recent, we cannot be sure that it will be maintained in the long run. +However, it isn't a dependency of the API core, so in case we have to get rid of it +for some reason in the future, we can always do it and list routes manually. + +[crates.io]: "crates.io: Rust Package Registry" +[OpenAPI Specification]: "OpenAPI Specification | Wikipedia" +[Rocket]: "Rocket homepage" +[rocket-routes-list]: "Overview - Rocket Programming Guide" +[utoipa]: "utoipa | crates.io" +[utoipauto]: "utoipauto | crates.io" diff --git a/ADRs/README.md b/ADRs/README.md index 64d64bb2..d1f01dac 100644 --- a/ADRs/README.md +++ b/ADRs/README.md @@ -14,6 +14,7 @@ as a template and replace every occurrence of `` by whatever it s ## Proposed ADRs - [Describe Prose Pod API using the OpenAPI Specification](./2023-12-18-a-describe-with-openapi.md) (2023-12-18) +- [Automatically detect OpenAPI routes](./2023-12-18-b-generate-openapi-description.md) (2023-12-18) ## Superseded ADRs