karlvr / openapi-generator-plus-generators

Other
21 stars 8 forks source link

`typescript-express-example-server-generator`: inject request handlers? #17

Closed kindaro closed 3 years ago

kindaro commented 3 years ago

Currently, the work flows like this:

  1. Generate an example server that serves some example values.
  2. Rewrite the request handlers to use the actual logic (say, querying the data base).

This has the disadvantage that the generated code has to be edited (request handlers written inline) and therefore committed. However, as a rule, generated code should not be committed. Committing a patch over the generated code also has obvious drawbacks, such as being fragile and unwieldy.

The solution is to parametrize the generated code by the request handlers. This can be done in two ways:

karlvr commented 3 years ago

@kindaro thanks for this. The intention of this particular generator is to create a server that just returns example content, rather than as a basis for a node server.

I have actually worked on a node server with this in mind... it's separate from this repository, as probably a number of these generators should end up being! Check out https://github.com/karlvr/openapi-generator-plus-express-passport and see if this is going in the right direction for you. I haven't updated it in a little while, but we are currently using it in production in its current form.

kindaro commented 3 years ago

Thanks!