Skip to content

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

Closed
@enkot

Description

@enkot

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    PRs welcomePRs are welcome to solve this issue!enhancementNew feature or requestopenapi-tsRelevant to the openapi-typescript library

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions