Skip to content

Feature Request: Output Request Format for Endpoints #47

Closed
@aharisu

Description

@aharisu

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.

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.

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions