Its easy to generate source code from a swagger file because there are many plugins around. I find it difficult to find a documentation which shows me how to create a swagger.yml file from by java code base, build tool is gradle.
I scanned https://springfox.github.io/springfox/docs/current/#configuration-explained - but I did not find something interesting.
https://plugins.gradle.org/plugin/org.hidetake.swagger.generator seems that it only creates source code of swagger.yml