Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

openapi code generator - python server stub workflow

I am using openapi-generator to generate server stub python code. Everything works fine, however, every time I make a change in the OpenAPI specs (the yaml file), the code generator overwrites the whole code, even the one customized (the controller). I would like to develop an incremental workflow, where if I make a change in the specs, the generator modifies the code handling that part of the code only.

It would be great if I get to the point where I can enforce the specs and also have an incremental workflow.

I am using openapi-generator version 3.3.4.

I tried to modify the controller and remove # noqa: E501, but it still overwrites the code every time I generate the stub from the specs.

How can I isolate the controller implementation by the generated interface, since the generated code is not OOP?

like image 367
Ionut Manolache Avatar asked Sep 14 '25 06:09

Ionut Manolache


1 Answers

Best solution i found, worked perfectly

Use two branch : One with raw server stub, One with server stub filled with your code.

Generate new server stub versions only on the raw branch an merge it to other branch wich contains previous server stub filled with your code.

My workflow :

Each time i need to modify the server stub i checkout the raw server stub branch => then modify the openAPi file => then generate the server stub => then commit => then checkout the dev branch => then merge raw server stub branch into my dev branch.

For now it works well :). Hope it helps.

like image 170
Gus tutu Avatar answered Sep 15 '25 20:09

Gus tutu