Hello,
While building a frontend connected to litestar, I found that I had to type URL on my frontend but I would prefer using constant exported from litestar cli.
Using the command schema typescript
, it would be nice if the routes (path) can be added to the exported file so we could import and use the route in the frontend.
The command schema openapi
export the paths in the file (in a different format of course)
Also, routes url should include the parameters in the exported file:
/v2/apps/{app_id}/deployments/{deployment_id}/cancel
After some searches, found some examples but do not know if it's relevant:
openapi-typescript
export namespace API {
export namespace AccountLogin {
// Somewhere there the path
export namespace Http201 {
export type ResponseBody = {
access_token: string;
expires_in ? : null | number;
refresh_token ? : null | string;
token_type: string;
};
};
export namespace Http400 {
export type ResponseBody = {
detail: string;
extra ? : Record < string,
unknown > | null | unknown[];
status_code: number;
};
};
export type RequestBody = {
password: string;
username: string;
};
};
};
Example in the frontend.
Instead of using the following code:
function submit() {
router.post("/api/access/login", form);
}
I could use
function submit() {
router.post(API.AccountLogin.Path, form);
}
No response
No response
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too