Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[BUG] Python3 client deserialization mutates string data #1816

Closed
spacether opened this issue Jan 4, 2019 · 1 comment
Closed

[BUG] Python3 client deserialization mutates string data #1816

spacether opened this issue Jan 4, 2019 · 1 comment

Comments

@spacether
Copy link
Contributor

Description

When deserializing utf-8 string data in the python3 client, the client incorrectly adds a lot of whitespace.

openapi-generator version

3.3.4

OpenAPI declaration file content or url
swagger: '2.0'
info:
  version: ''
  title: carrier api
host: example.com
schemes:
  - https
paths:
  /v3/shipments/{shipmentId}/label:
    get:
      operationId: getShipmentLabel
      summary: Retrieve a shipment's label
      description: Retrieve a shipment's label
      parameters:
        - in: path
          name: shipmentId
          type: string
          required: true
          description: the shipmentId to use
        - in: query
          name: format
          type: string
          required: true
          description: The format of the resulting label
          default: ZPL
          enum:
            - ZPL
        - name: Content-Type
          in: header
          required: true
          type: string
          default: application/json
        - name: Authorization
          in: header
          required: true
          type: string
          default: 'Token <<apiv3_token>>'
        - name: Accept-Charset
          in: header
          required: true
          type: string
          default: utf-8
        - name: Accept
          in: header
          required: true
          type: string
          default: application/json
      consumes:
        - application/json; charset=utf-8
      responses:
        200:
          description: 'LabelResponse'
          schema:
            $ref: "#/definitions/LabelResponse"
definitions:
  LabelResponse:
    type: object
    properties:
      label:
        type: string
Command line used for generation

openapi-generator generate -i carrierapi.yaml -g python -o ./carrierapi -DpackageName=carrierapi

Steps to reproduce

Ingest the below response as a LabelResponse:

{"label":"^XA~DGR:LOGO.GRF,3200,20,,::::::::::::::::::::::::::::::::::::::::::::::::::Q0G1GFGCO0G3GFGCT0P0G1IFGEM0G3IFGCS0P0KFG8K0G1KFS0O0G3KFGCK0G7KFGCR0O0MFK0MFR0N0G1MFG8I0G3MFG8Q0N0G3MFGEI0G3MFGCQ0N0G7MFGEI0NFGEQ0N0OF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,70^FO60,515^FDJohn Doe^FS^FO60,580^FD2250 Shattuck Avenue^FS^FO60,635^FDPenthouse^FS^FO60,690^FDBerkeley CA 94704^FS^FXBARCODE^BY3,2,200^FO200,765^BC^FD123^FS^CFA,30^A0N,40,45^FO60,1020^FDREF#:^FS^FO170,1020^FD^FS^FO60,1110^A0N,40,45^FDDATE:^FS^FO170,1110^FD^FS^FO615,1110^A0N,40,45^FD#4666086^FS^XZ"}

The client converts it to:

{'label': '^XA~DGR:LOGO.GRF,3200,20,,::::::::::::::::::::::::::::::::::::::::::::::::::Q0G1GFGCO0G3GFGCT0P0G1IFGEM0G3IFGCS0P0KFG8K0G1KFS0O0G3KFGCK0G7KFGCR0O0MFK0MFR0N0G1MFG8I0G3MFG8Q0N0G3MFGEI0G3MFGCQ0N0G7MFGEI0NFGEQ0N0OFI0OFQ0M0G1OFG8G0G1OFG8P0M0G1IFGCG0G1IFGCG0G3OFG8P0M0G3IFI0G7HFGCG0G3IFG8G0G3IFGCP0M0G7HFGEI0G3HFGEG0G7IFI0IFGCP0M0G7HFG8I0G1IFG0IFGCI0G7HFGEP0M0G7HFK0IFG0IFG8I0G3HFGEP0M0IFK0G7HFG1IFJ0G1IFP0M0HFGEK0G7HFG9IFK0IFP0L0G1HFGEK0G7HFG9HFGEK0IFP0L0G1HFGEK0G3HFGBHFGCK0G7HFG8O0L0G1TFGCK0G7HFG8O0L0G1TFGCK0G3HFG8O0L0G1TFG8K0G3HFG8O0:::::L0G1TFGCK0G3HFG8O0L0G1HFGEN0G3HFGCK0G3HFG8O0L0G1HFGEN0G3HFGCK0G7HFG8O0L0G1HFGEN0G3HFGEK0G7HFG8O0M0IFN0G3HFGEK0IFP0M0IFG8M0G3IFK0IFP0M0IFGCJ0G1G8G0G3IFJ0G1IFP0M0G7HFGEJ0G3GCG0G3IFG8I0G3HFGEP0M0G7IFJ0GFGEG0G3IFGCI0G7HFGEP0M0G3IFGCH0G3HFG0G3JFI0IFGCP0M0G1JFGCG3IFG8G3JFGCG0G7IFGCP0M0G1OFG8G3PFG8P0N0OFGCG3PFQ0N0G7NFGEG3PFQ0N0G3NFGEG3OFGEQ0N0G1NFGCG3OFGCQ0O0NFG0G3OFG8Q0O0G7LFGEG0G3HFG8LFR0O0G1LFG8G0G3HFG8KFGCR0P0G7JFGCH0G3HFG8G1JFS0Q0IFGEI0G3HFG8G0G7HFGCS0R0HFJ0G3HFG8H0GFU0X0G3HFG8X0::::::::::::::::::,::::::::::::::::::::::::::::::::::::::::^FS^FO60,130^XGR:LOGO.GRF,1,1^FS^CI28^CFC,60^FO340,248^FD^FS^FO550,120^BQ,2,8^FDHM,A4666086^FS^CFC,30^A0N,60,70^FO60,325^FDEasyPost^FS^CFA,30^FO60,390^FD1937 '
          'Davis Street Suite A^FS^FO60,440^FDSan Leandro CA '
          '94577^FS^CFC,30^A0N,60,70^FO60,515^FDJohn Doe^FS^FO60,580^FD2250 '
          'Shattuck Avenue^FS^FO60,635^FDPenthouse^FS^FO60,690^FDBerkeley CA '
          '94704^FS^FXBARCODE^BY3,2,200^FO200,765^BC^FD123^FS^CFA,30^A0N,40,45^FO60,1020^FDREF#:^FS^FO170,1020^FD^FS^FO60,1110^A0N,40,45^FDDATE:^FS^FO170,1110^FD^FS^FO615,1110^A0N,40,45^FD#4666086^FS^XZ'}

I have traced the issue to somewhere inside api_client.py def __deserialize

Related issues/PRs

#1445

Suggest a fix

Don't add extra whitespace.

@auto-labeler
Copy link

auto-labeler bot commented Jan 4, 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 spacether changed the title [BUG] Python3 client deserialization mutates string data binary [BUG] Python3 client deserialization mutates string data Jan 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant