Giter Site home page Giter Site logo

Comments (5)

IkeyBenz avatar IkeyBenz commented on July 28, 2024 1

You can find explanation in docs.

The docs seem to say that what @Meyzz was looking for can no longer be achieved... am I misunderstanding? I would also like to reference interfaces by name.

from openapi-typescript.

skh- avatar skh- commented on July 28, 2024 1

@Meyzz if you're just looking for fewer keystrokes, here's what I came up with:

in a .d.ts file:

import { components } from 'your-module';

declare global {
  type Schemas = components['schemas'];
}

Usage: const foo: Schemas['Foo'] = makeFoo(); in a different file without having to import anything.

from openapi-typescript.

akellbl4 avatar akellbl4 commented on July 28, 2024

You can find explanation in docs.
https://github.com/manifoldco/swagger-to-ts#no-wrappers

from openapi-typescript.

drwpow avatar drwpow commented on July 28, 2024

Yes that’s correct—with 2.0 the option to remove wrappers was removed. It made the library overly-complicated to maintain when your schema can be transformed. It’s your schema! The types should match reality.

As referenced in the README, I’d recommend just creating shorthand types where needed to reduce typing.

from openapi-typescript.

fgblomqvist avatar fgblomqvist commented on July 28, 2024

It feels quite non-typescript'y to have to write even Schemas['Foo']. Feels like everything in components['schemas'] should be directly importable/referenceable. If you have to use a nested structure for accessing paths/methods etc. and other more complicated/niche bits, that's fine.

The types should match reality.

The types do match reality. Nesting them does not feel like it matches reality though. If I have a type Foo shouldn't I be able to just do import { Foo } from './schema.ts';?
@drwpow

from openapi-typescript.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.