Codegen -> modify OpenAPI file -> Regenerate: possible?

23 views
Skip to first unread message

David Ludwig

unread,
Feb 16, 2018, 4:38:44 PM2/16/18
to Swagger
Might anyone have tips for continuously generating code, from an OpenAPI-formatted file?  My goal is to have a development process that runs a bit like so:

1. I generate server code from an OpenAPI file.  Language-wise, this would probably be C#, but this is not a hard-need.  I could switch to almost any language, here.
2. I modify the generated code with custom logic.  The customized code would probably be Controller-type code, which employed various business/company-specific logic to instantiate stuff from the Model.
3. I modify the OpenAPI file.  It is safe to assume that I would only be adding properties to it (as opposed to deleting or modifying things).
4. I regenerate the code from the now-modified OpenAPI file, with my custom, business logic still in-place, and with new properties being created.

I am thinking I might be able to accomplish this via use of polymorphism, in the target language.  I.e. subclass Controller objects, overriding methods as needed.  This seems somewhat verbose, moreso than the app needs, and perhaps prone to error.

OS-wise, I could use pretty much anything: OSX, Linux, or Windows.  I'm using OSX now, but could switch to something else, without much trouble.

In terms of tools, I've been using swagger-codegen v2.3.1.  I could see switching to something else, such as the 3.0.0 series, or even a custom-built copy.  I have been able to successfully build and run swagger-codegen, via Github-cloned code.

Does anyone have tips on how to accomplish the aforementioned development process (generate server code, modify OpenAPI file, regenerate server code w/o losing certain customizations)?  Might polymorphism (in the target language) be a prudent option?

Reply all
Reply to author
Forward
0 new messages