Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[BUG] [Python] API client cannot retrieve data for some models #2797

Closed
ewenger opened this issue May 2, 2019 · 2 comments
Closed

[BUG] [Python] API client cannot retrieve data for some models #2797

ewenger opened this issue May 2, 2019 · 2 comments

Comments

@ewenger
Copy link

ewenger commented May 2, 2019

Description

I used the openapitools-codegen-cli (latest) (and swagger-codegen (2.x,3.x) to generate a python api for a swagger spec I was given by a partner. The generated api client works in most cases but I have one model for which it always returns no data.

openapi-generator version
OpenAPI declaration file content or url
  pose:
    type: "object"
    properties:
      position:
        description: "This is "
        $ref: "#/definitions/point"
      orientation:
        description: "This is "
    example:
      orientation:
        w: 5.9
        x: 0.8
        y: 6.0
        z: 1.4
      position:
        x: 0.8
        y: 6.0
        z: 1.4
  point:
    type: "object"
    properties:
      x:
        type: "number"
        format: "double"
      y:
        type: "number"
        format: "double"
      z:
        type: "number"
        format: "double"
    example:
      x: 0.8
      y: 6.0
      z: 1.4
  quaternion:
    type: "object"
    properties:
      x:
        type: "number"
        format: "double"
      y:
        type: "number"
        format: "double"
      z:
        type: "number"
        format: "double"
      w:
        type: "number"
        format: "double"
    example:
      w: 5.9
      x: 0.8
      y: 6.0
      z: 1.4

-->

Command line used for generation

docker run --rm -v %CD%:/local openapitools/openapi-generator-cli:latest generate -i local/my_swagger.yaml -g python -o local/out/python-oapit-latest -c local/config.json

Steps to reproduce

Use the getAssetPose function to return the pose always yields none for position and orientation.
Using tcpdump I can verify the request and response are properly formatted.

Related issues/PRs

Maybe this one: swagger-api/swagger-codegen#6291 (comment)

Suggest a fix

The deserialize_model function in the api client gets a pose dict and checks to see if the position and quaternion attributes exist. They do not since only the "pose" attribute exists in that json. I hacked it to work by checking for the pose attribute and then setting data = data['pose'] to dereference it one level deeper before it tries to pull the attribute values. I don't know (yet) how to elegantly fix the issue.

@auto-labeler
Copy link

auto-labeler bot commented May 2, 2019

👍 Thanks for opening this issue!
🏷 I have applied any labels matching special text in your issue.

The team will review the labels and make any necessary changes.

@spacether
Copy link
Contributor

This should be resolved for the latest version of the python generator

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants