6

I recently started using Swagger to generate flask templates: http://editor.swagger.io/#/

My workflow is flawed, and I am wondering where I am going wrong. I:

  1. Use the UI to write the API V1 .yaml
  2. Generate the code using the UI editor, which downloads a stubbed out zip
  3. Write the functions that were stubbed out

This part of the process is fine. However, let's say we want to add a new endpoint or change an existing endpoint. Now what? I:

  1. reload the swagger editor
  2. edit the yaml
  3. generate the code, which downloads a new zip and blows away the old code
  4. take the newly generated code and do a "self-merge" where I copy over the new stub into the old code and copy over the new yaml into the old

It seems there is a gap between the initial generation of the flask template and ongoing maintenance. What am I doing wrong?

davidism
  • 121,510
  • 29
  • 395
  • 339
Tommy
  • 12,588
  • 14
  • 59
  • 110
  • Please see my answer [here](https://stackoverflow.com/a/45680372/1366989), which offers an alternate approach. – MrName Aug 14 '17 at 18:04

1 Answers1

6

Yeah, there isn't really a good workflow for that yet AFAICS.

One thing you can do is check the original generated code into git on a branch called "generated" or similar. Then merge that to master and start working on it. If, at a later point, you extend your swagger definition, you can generate the code again, switch to the generated branch, overwrite the existing code with the newly generated code, commit and merge to master again. If all you had were some additional endpoints, this should even work without any merge conflicts.

It would of course be nicer if the swagger tools had a concept of which code they generated and be able to update generated code, but until then this should be a bearable workaround.

Daniel Bachler
  • 139
  • 1
  • 5