I have an OpenAPI spec that I successfully turned into Server/Client Python code using OpenAPI generator. However the structure of the server does not really fit my needs. To specify how to handle request (say method.foo()), I need to modify a file inside the generated code called "default_controller.py". I'd much rather generate a Python object that specifies the method.foo() and give this to the generated code which turns this into a valid server.
class HandlerClass:
def foo(self):
print("Performing foo")
def bar(self):
print("Performing bar")
handler = HandlerClass()
server = GenerateServerFromHandler(handler)
I know this is possible within the Thrift API-spec but unfortunately this is not quite the right tool for the job. Is it possible to generate code like this?
The openapi-generator
generated code can be customized in several ways as described here , depending on which generator you are using:
openapi-generator
to them with the --template-dir
argument.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.