You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 openapiexport 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
Basic Example
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);
}
Summary
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
Basic Example
Example in the frontend.
Instead of using the following code:
I could use
Drawbacks and Impact
No response
Unresolved questions
No response
Note
While we are open for sponsoring on GitHub Sponsors and
OpenCollective, we also utilize Polar.sh to engage in pledge-based sponsorship.
Check out all issues funded or available for funding on our Polar.sh dashboard
The text was updated successfully, but these errors were encountered: