Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Proposal: Support other template languages #113

Open
erictuvesson opened this issue Mar 10, 2020 · 3 comments
Open

API Proposal: Support other template languages #113

erictuvesson opened this issue Mar 10, 2020 · 3 comments

Comments

@erictuvesson
Copy link

Justification

Right now only Mustache is supported, I can see the benefits of the template language. It's just a little bit off putting for people how doesn't know it that well to build custom templates.

I don't consider this important, just would like to open a discussion around it.

API Proposal

There are already a something building on top of this, building this up more to be able to handle more abstract types would make it easy to solve.

https://github.com/mtennoe/swagger-typescript-codegen/blob/master/src/transform/transformToCodeWithMustache.ts#L12-L38

I am not sure what the design reason behind having the default templates inside the transform code, it would be nice to move that out of there.
https://github.com/mtennoe/swagger-typescript-codegen/blob/master/src/transform/transformToCodeWithMustache.ts#L40-L52

Considerations

  • Easier to maintain.
  • Easier for new people.
@mtennoe
Copy link
Owner

mtennoe commented Mar 10, 2020

I like this! @Markionium and I have previously discussed supporting ES6 template literals for instance. To maintain backwards compatibility and allow people to use their preferred template language, adding the template logic in some plugin-like way (with maybe mustache as the default fallback) would be nice, and would make the generator quite a bit more flexible.

I don't think it's the highest priority feature either, but it's definitely a Nice-to-Have

@erictuvesson
Copy link
Author

Yes, as little of breaking changes as possible is always nice.

What would be the ideal naming conversion? Currently it's named transform and transformToCodeWithMustache.
The options structure should probably also be revisited in some way, so there can be custom options for each language.

@mtennoe
Copy link
Owner

mtennoe commented Mar 11, 2020

Hm, naming wise maybe transform and transformToCode would be decent
Options-wise it should probably just be a simple base-config with a set of mandatory and optional properties, with some way of extending that based on the template language.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants