mtennoe / swagger-typescript-codegen

A Swagger Codegenerator tailored for typescript.
Apache License 2.0
140 stars 52 forks source link

Add support for multiple request libraries or make SuperAgent optional #102

Open mtennoe opened 4 years ago

mtennoe commented 4 years ago

The way I see it it's not really needed, and just bloats the consumer's bundle size. Using XMLHttpRequest should be sufficient

andy-viv commented 4 years ago

There are a few benefits to superagent:

Might I suggest supporting multiple request libraries? I don't think you would have to maintain entirely different templates for each one, but instead have a helper that acts as a sort of switch statement depending on the option chosen.

It would be more work (so I wouldn't blame you for not going this route), especially because users can ultimately override the templates and do whatever they want.

mtennoe commented 4 years ago

All good points! I like the idea of supporting multiple request libraries. It will as you write introduce some complexity ofc, but might be worth it. A middle ground could be to make superagent optional, and fall back to XHR if superagent is disabled.

Overall though, I think this issue is not the highest priority one since it's so easy to change the template to not use it (we have done that in a project I am working on for instance).

erictuvesson commented 4 years ago

I don't think it necessarily have to introduce more complexity, parts of the code could be made more abstract making it easier to maintain different versions easier.

So the underlying data format (ViewData) would stay the same, just the template files would change depending of what "template set" you decide to use.

mtennoe commented 4 years ago

Agree, with the right level of abstractions it might turn out pretty nice. However, there will always be some complexity when adding abstractions, but in this case it might be a good trade-off.