I have:
- library that makes [stuff]
- swagger API definition, which is roughly equal to # 1 with slight differences, to clearly display the REST service
- a jar application created using Swagger-Codegen, for example, leads to python controller functions about one to one C # 1.
My intention is that the flash application (all generated code) should only process the display of the actual REST api and parameter parsing in order to comply with the API specification encoded in swagger. After any parsing of the parameters (again, the generated code), it should go directly to my (not created) backend.
My question is, what is the best way to connect them by manually editing the generated python / flask code? (Feedback on my design or the details of the formal design template that will do this will be great too, I'm new to this space).
Fresh from the generator, I get python functions such as:
def create_task(myTaskDefinition): """ comment as specified in swagger.json :param myTaskDefinition: json blah blah blah :type myTaskDefinition: dict | bytes :rtype: ApiResponse """ if connexion.request.is_json: myTaskDefinition = MyTaskTypeFromSwagger.from_dict(connexion.request.get_json()) return 'do some magic!'
On the backend, I have my actual logic:
def create_task_backend(myTaskDefinition):
What is the correct way to get create_task() to call create_task_backend() ?
Of course, if I make changes to my swagger specification, I will have to manually update the non-generated code; however, there are many reasons why I can regenerate my API (say, add / refine MyTaskTypeFromSwagger class or skip checking for git generated code in general), and if I need to manually edit the generated API code, then all these changes are deleted with each recreation.
Of course, I could script using simple grammar, for example. Pyparsing; but so far this is my first time with this problem, it seems that it has already been widely resolved!