Skip to content

Instantly share code, notes, and snippets.

@danyx23
Created October 12, 2016 21:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danyx23/2efcd3098d401364014585d1d914f83f to your computer and use it in GitHub Desktop.
Save danyx23/2efcd3098d401364014585d1d914f83f to your computer and use it in GitHub Desktop.
Simple recipe for how to regenerate swagger based apis without overwriting implementation
java -jar swagger-codegen-cli.jar generate -l python-flask -i SWAGGER-YAML-FILE -o api
git add api
git commit ...
# this is just a convienience for the first time you change your api
git tag -a initial-api-scaffold -m "Initial swagger scaffold. Base point for future api changes"
# work on implementation, then:
git add, commit
# Now you want to change the api. *First* of all, go back to the commit we tagged above and create a new branch from there:
git checkout -b api-update initial-api-scaffold
# Now change the swagger file, then:
git add, commit
# Now checkout master again and merge the changes from the branch
git checkout master
git merge api-update
# Because you based your work on a line of commits that had no implementation in it,
# if you merge this into master which does have implementation it will usually do the
# right thing with the default merge strategy and leave the implemention changes alone.
# Important! If you do the next api update, the point to base your work on is the commits
# to the api-update branch *before the merge* into master. This is the line of commits that
# contains no implementation and just the api changes. If you should base your future api
# updates on master, it will also work but when merging back into master you have to be
# careful not to overwrite any implemenations from earlier on master.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment