Giter Site home page Giter Site logo

Add `models/index.ts` about openapi-ts HOT 8 CLOSED

hey-api avatar hey-api commented on May 24, 2024
Add `models/index.ts`

from openapi-ts.

Comments (8)

jordanshatford avatar jordanshatford commented on May 24, 2024 2

@anchan828 the root index.ts should export all models and services. Are you able to import multiple models from there instead?

Whoops, just re-read your issues and see. You are only including the models. This should be do-able.

from openapi-ts.

jordanshatford avatar jordanshatford commented on May 24, 2024 2

@anchan828 I have added this and released it in version 0.28.0.

from openapi-ts.

jordanshatford avatar jordanshatford commented on May 24, 2024

@anchan828 Im curious if you can share how your repository is structured? Could you use a mono repo where the generated client is one package and other can use it as a dependency?

from openapi-ts.

jordanshatford avatar jordanshatford commented on May 24, 2024

NOTE: im thinking we could add models/index.ts and services/index.ts and schemas/index.ts These would export all of the models/services/schemas. Then in the root index.ts, instead of exporting each manually we export * from './models (Check if config has exporting enabled for models/service/schemas).

from openapi-ts.

anchan828 avatar anchan828 commented on May 24, 2024

@jordanshatford I have two repositories.

  1. There is a backend repository where I do integration testing with code generated by openai-ts.
  2. There is a frontend repository where I have my own HTTP client and validation, so I don't use services or schemas, but I cast the resulting data in models types. This is completely on my side, but I can't package it, so I copy it and add the file from backend to frontend repository.

from openapi-ts.

mrlubos avatar mrlubos commented on May 24, 2024

Hey @anchan828, thanks for opening an issue! A couple questions

  1. Why are you using your own HTTP client and not one of the generated ones?
  2. Why aren't you using one of the other OpenAPI types generators that don't come with any HTTP client if that's all you need?

from openapi-ts.

anchan828 avatar anchan828 commented on May 24, 2024

Hi @mrlubos,

  1. Why are you using your own HTTP client and not one of the generated ones?

Sorry, I can't explain it convincingly, but what I can say is that the frontend system already has an HTTP client, so switching to the openapi-ts's HTTP client is not an immediate option.

  1. Why aren't you using one of the other OpenAPI types generators that don't come with any HTTP client if that's all you need?

This is because there is no point in going to the trouble of using two generators.
When I was using openapi-generator, it took 5 seconds, but with openapi-ts, I can now generate it in less than 100~150ms, so the speed of generation is one of the main reasons I use openapi-ts. 😀

from openapi-ts.

mrlubos avatar mrlubos commented on May 24, 2024

Thanks for the additional context! Ideally, you wouldn't have to use a custom client when using this package, so if there's anything we can do to bridge that gap between our generated client and what you use, please let us know!

from openapi-ts.

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.