openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

[REQ] Enhancing generated Code by customising with YAML-Based Binding Files

Open david0 opened this issue 1 year ago • 0 comments

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

I'm always frustrated when the generated model classes do not look the way that I would have expected.

It is the nature of code generation that this can happen, but I would like to have the ability to influence the generated output more.

E. g. Injecting additional code has been a very useful thing in the past.

Describe the solution you'd like

I think there are two ways to cover this

  1. Vendor extensions inside of the YAML file

  2. additional binding files [as they exist for XSD](https://docs.oracle.com/javase/tutorial/jaxb/intro/custom.html), [code injection example](https://plindenbaum.blogspot.com/2012/09/customizing-java-classes-for-ncbi.html)

While having more vendor extensions could accomplish that I think it it has disadvantages:

a. it can grow very big, especially when injecting code

b. as a client, you'll get a YAML handed over and usually don't want to modify it to simplify the workflow of updating

So because especially because of b) I would propose a separate xjc-like binding file that allows to refine the generated code. Of course we do not like XML and would prefer an YAML version of it.

Describe alternatives you've considered

  1. Mustace templates: these alone do not handle non-generic changes that apply to single types only very good
  2. Vendor extensions: These could cover my wishes too, but at the moment there is no annotation like x-inject-code to add more code to the generated POJO.

david0 avatar Aug 22 '24 11:08 david0