Document how to generate REST API bindings using swagger-codegen
With help from swagger-codegen0, Pulp's API schema can be used to generate bindings in many different languages.
I was able to GET the schema in JSON format from http://localhost:8000/api/v3/docs/api.json and then uploaded the JSON file to swagger editor1. I then clicked on "Generate Client" and selected "Python". This produced a ZIP archive that contained a python package with the bindings and documentation. The hosted solution is backed by a Java application called swagger-codegen2.
The goal of this task is to document how swagger-codegen can be used from the command line to generate bindings in any language supported by swagger-codegen.
#8 Updated by daviddavis over 1 year ago
Apparently the instructions are here:
However, I am not too keen on having to manually apply a patch every time we want to generate our bindings. Is there a way to submit a patch upstream or fork the swagger-codegen repo maybe?
#9 Updated by firstname.lastname@example.org over 1 year ago
The instructions should tell the user to download the jar from fedorapeople.org0.
#10 Updated by daviddavis over 1 year ago
I'm testing out the python bindings but they don't seem to work. I generated the python bindings and am trying to call the versions content endpoint:
from swagger_client.api.repositories_api import RepositoriesApi api = RepositoriesApi() api.repositories_versions_content("http://localhost:8000/pulp/api/v3/repositories/3a723819-6302-4352-8ac6-3875ac7b7429/versions/2/") # fails api.repositories_versions_content("/repositories/3a723819-6302-4352-8ac6-3875ac7b7429/versions/2/") # doesn't work either
It looks like the bindings are calling:
[12/Jul/2018 13:20:23] "GET /pulp/api/v3http%3A%2F%2Flocalhost%3A8000%2Fpulp%2Fapi%2Fv3%2Frepositories%2F3a723819-6302-4352-8ac6-3875ac7b7429%2Fversions%2F2%2F HTTP/1.1" 404 3183
It's also kind of strange that there's no "content" in the url which leads me to believe that I have to specify
/pulp/api/v3/repositories/3a723819-6302-4352-8ac6-3875ac7b7429/versions/2/content/ as the href but that doesn't seem right either.
Edit: Found a solution to the urlencoding. Looks like you have to set
'/' in the configuration of the python bindings.
#16 Updated by email@example.com about 1 year ago
- Status changed from ASSIGNED to CLOSED - COMPLETE
I wrote a blog post about this.
Please register to edit this issue