Project

Profile

Help

Task #3580

Document how to generate REST API bindings using swagger-codegen

Added by dkliban@redhat.com over 1 year ago. Updated 6 months ago.

Status:
CLOSED - COMPLETE
Priority:
Normal
Category:
-
Sprint/Milestone:
Start date:
Due date:
% Done:

0%

Platform Release:
Blocks Release:
Backwards Incompatible:
No
Groomed:
Yes
Sprint Candidate:
Yes
Tags:
API Bindings, Pulp 2
QA Contact:
Complexity:
Smash Test:
Verified:
No
Verification Required:
No
Sprint:
Sprint 42

Description

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.

[0] https://swagger.io/swagger-codegen/
[1] http://editor.swagger.io/#/
[2] https://github.com/swagger-api/swagger-codegen


Related issues

Copied from Python Support - Task #3579: Publish REST API bindings for Python on PyPI NEW Actions

History

#1 Updated by dkliban@redhat.com over 1 year ago

  • Copied from Task #3579: Publish REST API bindings for Python on PyPI added

#2 Updated by dkliban@redhat.com over 1 year ago

  • Subject changed from Publish REST API bindings for Ruby on rubygems.org to Document how to generate REST API bindings using swagger-codegen
  • Description updated (diff)
  • Tags Documentation added

#3 Updated by CodeHeeler over 1 year ago

  • Groomed changed from No to Yes

#4 Updated by daviddavis over 1 year ago

  • Sprint set to Sprint 36

Be sure to add a note that any installed plugins will be included in the bindings.

#5 Updated by rchan over 1 year ago

  • Sprint changed from Sprint 36 to Sprint 37

#6 Updated by rchan over 1 year ago

  • Sprint changed from Sprint 37 to Sprint 38

#7 Updated by rchan over 1 year ago

  • Sprint changed from Sprint 38 to Sprint 39

#8 Updated by daviddavis over 1 year ago

Apparently the instructions are here:

https://www.redhat.com/archives/pulp-dev/2018-May/msg00098.html

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 dkliban@redhat.com over 1 year ago

The instructions should tell the user to download the jar from fedorapeople.org0.

https://repos.fedorapeople.org/pulp/pulp/swagger/swagger-codegen-cli.jar

#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 safe_chars_for_path_param to '/' in the configuration of the python bindings.

#11 Updated by dkliban@redhat.com over 1 year ago

  • Sprint changed from Sprint 39 to Sprint 40

#12 Updated by daviddavis over 1 year ago

  • Tags API Bindings added
  • Tags deleted (Documentation, Pulp 3)

#13 Updated by rchan about 1 year ago

  • Sprint changed from Sprint 40 to Sprint 41

#14 Updated by rchan about 1 year ago

  • Sprint changed from Sprint 41 to Sprint 42

#15 Updated by dkliban@redhat.com about 1 year ago

  • Status changed from NEW to ASSIGNED
  • Assignee set to dkliban@redhat.com

#16 Updated by dkliban@redhat.com about 1 year ago

  • Status changed from ASSIGNED to CLOSED - COMPLETE

#17 Updated by bmbouter 6 months ago

  • Tags Pulp 2 added

Please register to edit this issue

Also available in: Atom PDF