-
I'm using HonoJS and openapi which uses this package underneath. I want to define the parameters passed into the body schema under "body" while keeping the default type definition name. Any api endpoint with a json body should be like this The goal: export interface LoginWithCredentialsOperationRequest {
body?: LoginWithCredentialsRequest;
} When I have the request part of my openapi definition like this request: {
query: queryParamsSchema,
body: {
content: {
"application/json": {
schema: bodySchema,
},
},
},
},
It produces... export interface LoginWithCredentialsOperationRequest {
loginWithCredentialsRequest?: LoginWithCredentialsRequest;
} If I change it to be "application/json": {
schema: bodySchema.openapi("body"),
}, I get this export interface LoginWithCredentialsOperationRequest {
body?: Body;
} This is good for one endpoint but with multiple endpoints, if I use How can I generate an sdk with this type definition where the key is body but the type definition is the default generated type name? export interface LoginWithCredentialsOperationRequest {
body?: LoginWithCredentialsRequest;
} Is there a way to define it like this? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I realized you have to hint at the date in the openapi method with something like the schema below for the openapi docs to know it's a string but of format date-time. const schema = z.object({
createdAt: z.date().openapi({format: "date-time"})
}); Then when using the sdk in the client, the type will be properly inferred as a date |
Beta Was this translation helpful? Give feedback.
I realized you have to hint at the date in the openapi method with something like the schema below for the openapi docs to know it's a string but of format date-time.
Then when using the sdk in the client, the type will be properly inferred as a date