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

Export component's and path's types with friendly names #1598

Open
1 task done
enkot opened this issue Mar 27, 2024 · 0 comments
Open
1 task done

Export component's and path's types with friendly names #1598

enkot opened this issue Mar 27, 2024 · 0 comments
Labels
enhancement New feature or request help wanted Extra attention is needed openapi-ts Relevant to the openapi-typescript library

Comments

@enkot
Copy link

enkot commented Mar 27, 2024

Description

First of all, I want to thank you for this great lib! :)
To make it even better, I suggest exporting component types and paths like open-api-generator does.

Proposal

The first attempt to implement this is here #1260.
The idea is to generate types like this:
Components:

export type SchemaSimpleUser = components["schemas"]["simple-user"];
export type SchemaInstallation = components["schemas"]["installation"];
...
export type ResponseNotFound = components["responses"]["not_found"];
export type ResponseRequiresAuthentication = components["responses"]["requires_authentication"];
...
export type ParameterPerPage = components["parameters"]["per-page"];
export type ParameterPage = components["parameters"]["page"];
...
export type HeaderLink = components["headers"]["link"];
export type HeaderXRateLimitLimit = components["headers"]["x-rate-limit-limit"];

Paths:

export type RequestEnterpriseAdminListGlobalWebhooks = paths["/admin/hooks"]["get"]["parameters"];
export type RequestEnterpriseAdminGetGlobalWebhook = paths["/admin/hooks/{hook_id}"]["get"]["parameters"];

It would be also nice to generate types for requestBody and responses, but not sure how to properly handle content type (application/json, application/yaml etc.)

We also need to resolve the duplication issue described in this comment #1260 (comment). This can be solved by adding a number as a suffix to the duplicate name.

Checklist

@enkot enkot added enhancement New feature or request help wanted Extra attention is needed openapi-ts Relevant to the openapi-typescript library labels Mar 27, 2024
@enkot enkot changed the title Export component's and path's types Export component's and path's types with friendly names Mar 27, 2024
@enkot enkot mentioned this issue Mar 27, 2024
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed openapi-ts Relevant to the openapi-typescript library
Projects
None yet
Development

No branches or pull requests

1 participant