Skip to content

Exposing directly components types #2265

@Aschen

Description

@Aschen

Description

Hello !

First, thanks for your work here people, I really like having strong typing from backend to the frontend and your libraries are perfect for this 👌

At my work, we did a small additionnal wrapper that rewrite part of the types so we can access them directly like "natural" types instead of having to use the nested access through components["schemas"]["MyApiType"]

// Before
import { components } from './openapi-types'

function foobar(person: components["schemas"]["Person"]) {
  // ...
}

// After
import { Person } from './openapi-types'`

function foobar(person: Person) {
  // ...
}

I was thinking about opening a PR here to add an option to generate types from components like this but I wanted your opinion on it first.

Extra

Metadata

Metadata

Assignees

No one assigned

    Labels

    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