-
Notifications
You must be signed in to change notification settings - Fork 43
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
fix(rust): revamp the OpenAPI specification #1564
Conversation
I love schemas in general 😄 , they enable so many useful things... IIUC, |
IMHO there are two use cases:
The Actually, I do not think it would be that hard to build our own generator for our use case. |
If you want to give it a try, Hey API seems to be a nice alternative:
|
Trello: https://trello.com/c/nV7mjrf9/ This is the first step towards adapting the storage code to use queries. As this part of the code is rather complex, we decided to move as many components as possible to TypeScript to have a kind of security net. ## What is included * Add a set of types from from our OpenAPI docs (see #1564) in `api/storage/types`. * Add a set of storage UI types in `types/storage`. We should unify the types, but let's do it later. * Define a new `api/storage` module moving big chunks of the `StorageClient` code. * Define a set of queries under `queries/storage`. * Adapt the `ProposalPage` component to use queries. It retrieves a lot of information that injects to nested components. * Convert `ProposalPage` and `InstallationDeviceField` to TypeScript. ## What is missing * As you may see, the front end is not building. That problems (and other subtle bugs) will be fixed as we adapt the rest of storage components to TypeScript. So a bunch of additional pull requests will follow. * Additionally, we are removing all those skeletons from the UI. We will use a unified mechanism.
48ee076
to
aad4c28
Compare
aad4c28
to
5f4a160
Compare
- name: Generate and validate the OpenAPI specification | ||
run: | | ||
cargo xtask openapi | ||
openapi-spec-validator out/openapi/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great that it is validated 👍 , but does it also find missing piece?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, if it is mentioned and not defined, it is found here (most of the problems were like that). About completely forgotten stuff, we might need to try something different (but I do not know what).
The
agama-web-server docs
command generates the OpenAPI specification of Agama's HTTP API. However, the resulting specification is badly broken 😢. This pull request aims to make the specification usable.Refactoring
Apart from being incomplete, the previous implementation had a few problems.
IpAddr
,IpInet
, etc.).For those reasons, we decided to use the builder API, which is pretty flexible. We also took the chance to split the generation into smaller pieces, making it easier to maintain.
Packaging the OpenAPI documentation
Instead of generating the OpenAPI spec at runtime, we can do it at build time and put the resulting JSON files in a separate package (
agama-openapi
).Generating the
schema.d.ts
You can generate the API in two simple steps:
To do
Future work