Openapi-generator: [REQ] Support TypeScript Server generation

Created on 19 Oct 2019  路  10Comments  路  Source: OpenAPITools/openapi-generator

Is your feature request related to a problem? Please describe.

I want to make a server generator of Node using typescript with koa.js.
There is a very nice useful class AbstructTypeScriptClientCodegen for clients, but not for servers.

Describe the solution you'd like

  1. Rename AbstructTypeScriptClientCodegen to AbstructTypeScriptCodegen, and remove getTag() from this
  2. Create AbstructTypeScriptClientCodegen again, add getTag() to this.
  3. Create AbstructTypeScriptServerCodegen, add getTag() to this.

Provably this is a minimal impact and maintainable solution because there are some client generators.
(And we need to change TypeScriptNodeClientCodegen to extends AbstractTypeScriptServerCodegen from AbstractTypeScriptClientCodegen maybe.)

Describe alternatives you've considered

Have only AbstractTypeScriptCodegen

  • Need to add getTag() to all typescript client generators.
  • If increase method for typescript client, we need to change all typescript client generators.

Copy AbstractTypeScriptServerCodegen from AbstructTypeScriptClientCodegen.

  • Almost all functions will overlap with those of client.

    • There are many codes that dependencies TypeScript. It's pretty hard to maintain both codes, I think.

Create AbstractTypeScriptServerCodegen that extends AbstructTypeScriptClientCodegen.

  • if new medhod added to AbstractTypeScriptClientCodegen, it may occur probrem in server.

    • But difficult to notice those problems when working because the name is misleading.

Additional context

TypeScript is used by clients and servers. But other Languages also can have servers and clients.
I would be happy to discuss the good balance of abstraction in this nice project.

Feature New generator TypeScript help wanted

Most helpful comment

Hi. I'm interested in this. What's the current status? If anyone isn't working on this actively, can I take over this?

All 10 comments

getTag() was generated by new.sh, :thinking:
so best solution may be "Have only AbstractTypeScriptCodegen"....

sounds like a good idea. would you be willing to contribute such a generator?

Similar request: https://github.com/OpenAPITools/openapi-generator/issues/3011

@HiromiShikata is that what you'd in mind as well?

@macjohnny

sounds like a good idea. would you be willing to contribute such a generator?

Of course I want to contribute, I want to use this generator in other projects (not only current project) in the future, so the new generator is good for me.

@wing328

Similar request:聽#3011@HiromiShikata聽is that what you'd in mind as well?

I didn't notice #3011, thank you tell me.
I agree with your opinion. TypeScript & Koa2 Server generator is very useful for me.

@HiromiShikata I've produced a typescript generator in a closed source repo. My approach was to extend AbstractTypeScriptClientCodegen

For example, I made one for the HAPI node server: public class TypescriptHapiServerGenerator extends AbstractTypeScriptClientCodegen

I didn't feel like any functionality was missing from this approach other than using an in-corrrect tag as you've mentioned.

I like your approach here. If you'd like me to contribute the changes you outlined let me know. Otherwise I'll leave it to you. When we have this core functionality inplace I can port my HapiServer generator to the open source community and start working on one for NestJs next

What do you think? Do you want to make a PR or would you rather me take over? I'm fine either way

I've created https://github.com/OpenAPITools/openapi-generator/tree/ts_server with a new TypeScriptServerCodegen as a starting point: https://github.com/OpenAPITools/openapi-generator/compare/ts_server?expand=1

Please feel free to submit PRs for this branch or submit a PR based on what you've created so far.

Hi. I'm interested in this. What's the current status? If anyone isn't working on this actively, can I take over this?

Any updates? How can I use the ts_server branch's generator?

@Kiikurage please go ahead as I don't think anyone is actively working on it at the moment.

If you need help, please PM me via Slack (https://join.slack.com/t/openapi-generator/shared_invite/enQtNzAyNDMyOTU0OTE1LTY5ZDBiNDI5NzI5ZjQ1Y2E5OWVjMjZkYzY1ZGM2MWQ4YWFjMzcyNDY5MGI4NjQxNDBiMTlmZTc5NjY2ZTQ5MGM)

Was this page helpful?
0 / 5 - 0 ratings