Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Output Request Format for Endpoints #47

Closed
aharisu opened this issue Aug 14, 2024 · 1 comment
Closed

Feature Request: Output Request Format for Endpoints #47

aharisu opened this issue Aug 14, 2024 · 1 comment

Comments

@aharisu
Copy link
Contributor

aharisu commented Aug 14, 2024

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.

@aharisu
Copy link
Contributor Author

aharisu commented Aug 19, 2024

Resolved in PR #48 . Thanks for merging!

@aharisu aharisu closed this as completed Aug 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant