swagger-api / swagger-api/swagger-codegen

[Python] Default NATIVE_TYPES_MAPPING doesn't support unicode type ,so could not deal with Chinese character

Open
#8,299 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

My server response return the body with chinese character value, and the python client covertion will fail due to it only support the str(data) ,

Swagger-codegen version

2.3.1

Swagger declaration file content or url

The Name property contains the Chinese charascter response , I have customerize the NATIVE_TYPES_MAPPING , mapping the "str" to "unicode" as the work round . But I still need an e2e solution for it , I truely believe it is a common issue

 PersonList:
              type: "object"
              properties:
                PersonObject:
                  type: array
                  items:
                    type: object
                    properties:
                      PersonID:
                        type: string
                      InfoKind:
                        type: integer
                      SourceID:
                        type: string
                      DeviceID:
                        type: string
                      LeftTopX:
                        type: integer
                      LeftTopY:
                        type: integer
                      RightBtmX:
                        type: integer
                      RightBtmY:
                        type: integer
                      LocationMarkTime:
                        type: string
                      PersonAppearTime:
                        type: string
                      PersonDisAppearTime:
                        type: string
                      IDType:
                        type: string
                      IDNumber:
                        type: string
                      Name:
                        type: string
                      UsedName:
                        type: string
                      Alias:
                        type: string
                      GenderCode:
                        type: string
                      AgeUpLimit:
                        type: integer
                      AgeLowerLimit:
                        type: integer
                      EthicCode:
                        type: string
                      NationalityCode:
                        type: string
                      NativeCityCode:
                        type: string
                      ResidenceAdminDivision:
                        type: string
                      ChineseAccentCode:
                        type: string
                      PersonOrg:
                        type: string
                      JobCategory:
                        type: string
                      AccompanyNumber:
                        type: integer
                      HeightUpLimit:
                        type: integer
                      HeightLowerLimit:
                        type: integer
                      BodyType:
                        type: string
                      SkinColor:
                        type: string
                      HairStyle:
                        type: string
                      HairColor:
                        type: string
                      Gesture:
                        type: string
                      Status:
                        type: string
                      FaceStyle:
                        type: string
                      FacialFeature:
                        type: string
                      PhysicalFeature:
                        type: string
                      BodyFeature:
                        type: string
                      HabitualMovement:
                        type: string
                      Behavior:
                        type: string
Command line used for generation

java -jar bin/swagger-codegen-cli.jar generate -i ./viid_swagger.yaml -l python -o generated

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 by reproducing the Chinese-character response with the Python client generated from the supplied YAML, then inspect its NATIVE_TYPES_MAPPING and conversion path. Done means the generated client handles the Unicode value without a customized mapping; no file or test path is identified in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, python
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.