RicoSuter / NSwag

The Swagger/OpenAPI toolchain for .NET, ASP.NET Core and TypeScript.
http://NSwag.org
MIT License
6.82k stars 1.3k forks source link

Feature: ES6 Fetch template #407

Open no-more opened 8 years ago

no-more commented 8 years ago

Hi,

Once again thanks for this great tool.

I would like to know if it could be possible to implement a framework independent typescript code template. I would like to use compiled code on server side without the framework that I don't need.

An even better solution in my case would be to be able to generate plain javascript (ES6) as I'm not using typescript currently on my server side, but I suspect this would be a lot of extra work.

Thanks a lot.

RicoSuter commented 8 years ago

I think ES6 supports promises and fetch. Isnt the Fetch template sufficent (except that it is TypeScript)?

no-more commented 8 years ago

Hi,

thanks for your fast response, I though this was related to Aurelia as in the project description it's marked : window.fetch API and ES6 promises, Fetch (use this template in your Aurelia project).

But I think you're right that should work according to what I can see, I'll give it a try tomorrow.

Thanks.

RicoSuter commented 8 years ago

We could create a fetch template without ts typings and you'll have your es6 code...

no-more commented 8 years ago

Hi,

It's working thanks. Would be great for me to have js only version, but I can deal with it.

Thanks.

RicoSuter commented 8 years ago

Can we just strip away the TypeScript typings and it would be proper ES6 JavaScript?

no-more commented 8 years ago

I don't think this will be enough, I don't think ES6 support the class declaration syntax, exports does not work the same way too.

RicoSuter commented 8 years ago

I think ES6 supports class and export (but no annotations, which are not used in the fetch tpl).

The question is whether to copy the tpl, extend the existing one or transform the output..