swagger-api / swagger-api/swagger-codegen

Missing deserializer for type (Klass) "Object"

Open
#8,235 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

I can generate a mostly functional client, but I need to monkey patch the generated class to fix a missing deserializer for type "Object".

There is a deserializer for "object" lower case, which works fine, so I have to believe that it's simply a case of case confusion.

I resorted to this monkey-patch of the generated app_api class:

app_api.api_client.NATIVE_TYPES_MAPPING['Object'] =\
 app_api.api_client.NATIVE_TYPES_MAPPING['object']

Not sure where the fault lies exactly, I didn't completely follow the deserializer mapping logic.

Swagger-codegen version

❯ swagger-codegen version
2.3.1

Have not tried any other version, this is a new project.

Swagger declaration file content or url

This is a snippet of the swagger 1.2 API file.

        "Application": {
            "properties": {
                "globalState": {
                    "type": "Object"
                },
        }
Command line used for generation
	swagger-codegen generate \
		-i app.json \
		-l python \
		-o lib
Steps to reproduce

Upon receipt of a response containing the above "globalState" Object, which is a json string,

Suggest a fix/enhancement

Make the NATIVE_TYPES_MAPPING comparison case insensitive?

Here's a pic of the specific failure point:

screen shot 2018-05-24 at 2 14 10 pm

Note the object vs Object discrepancy.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the generated lib/app_api/api_client.py and inspect how response deserialization looks up Object versus object in NATIVE_TYPES_MAPPING. Reproduce it with the shown swagger-codegen generate command and app.json snippet; done means a Python client can deserialize the Object response without the monkey patch.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.