Use this script to rewrite a Swagger document to match the endpoints on a server.
Used to correct Swagger docs generated by Django (django-rest-swagger Python package) so it can be used to generate a Java client using the swagger code generator.
As a bonus it will upgrade the Swagger Document to version 2.0.
Download latest release from GitHub and unpack.
swagger-rewrite/bin/swagger-rewrite <input swagger location> <rewrites.yaml> <output swagger filename>
When response is defined in Swagger as type object, but endpoint returns array of type object.
Rewrites is yaml file using
response2array:
- /services/proteinfamily/
For example in the default response of GET operation on /services/proteinfamily/ path of will change
"type": "ProteinFamilySerializer"
into
"type": "array",
"items": {
"type": "ProteinFamilySerializer"
}
- Bump version in
build.gradle
file - Commit & push
- Create a release on GitHub.
- Run
./gradlew distZip
- Upload
build/distributions/*.zip
to GitHub release page.