Closed aharisu closed 2 months ago
Hello,
I really like typed-openapi for its headless usage. I would like to request a feature to output the request format for each endpoint, similar to what openapi-zod-client provides.
typed-openapi
openapi-zod-client
For example, given this OpenAPI schema:
/api/token: post: operationId: token_api_token_post requestBody: content: application/x-www-form-urlencoded: schema: $ref: '#/components/schemas/Body_token_api_token_post' required: true responses: '200': content: application/json: schema: $ref: '#/components/schemas/TokenOut' description: Successful Response '422': content: application/json: schema: $ref: '#/components/schemas/HTTPValidationError' description: Validation Error summary: Token
When output by openapi-zod-client, it generates an endpoint like this:
{ method: "post", path: "/api/token", alias: "token_api_token_post", requestFormat: "form-url", parameters: [ { name: "body", type: "Body", schema: Body_token_api_token_post, }, ], response: TokenOut, errors: [ { status: 422, description: `Validation Error`, schema: HTTPValidationError, }, ], },
I would like to have a similar feature in typed-openapi that includes the requestFormat property.
requestFormat
For example, the output could look like this:
export const post_Token_api_token_post = { method: z.literal("POST"), path: z.literal("/api/token"), requestFormat: z.literal("form-url"), // This is what I want! parameters: z.object({ body: Body_token_api_token_post, }), response: TokenOut, };
If you agree, I would be happy to create a PR. Please let me know your thoughts.
Resolved in PR #48 . Thanks for merging!
Hello,
I really like
typed-openapi
for its headless usage. I would like to request a feature to output the request format for each endpoint, similar to whatopenapi-zod-client
provides.For example, given this OpenAPI schema:
When output by
openapi-zod-client
, it generates an endpoint like this:I would like to have a similar feature in
typed-openapi
that includes therequestFormat
property.For example, the output could look like this:
If you agree, I would be happy to create a PR. Please let me know your thoughts.