Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #2724
Closed
Open
Issue created Apr 23, 2019 by Administrator@rootContributor5 of 5 checklist items completed5/5 checklist items

[BUG][Python-Flask] Primitive type bytearray deserialization missing in util.py.

Created by: dannmartens

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue? Yes.
  • Have you validated the input using an OpenAPI validator ([example] (https://apidevtools.org/swagger-parser/online/))?
  • What's the version of OpenAPI Generator used? HEAD of current master branch.
  • Have you search for related issues/PRs? Yes.
  • What's the actual output vs expected output?
  File "/home/ubuntu/dvm-rest-api/dvmapi/util.py", line 111, in deserialize_model
    setattr(instance, attr, _deserialize(value, attr_type))
  File "/home/ubuntu/dvm-rest-api/dvmapi/util.py", line 32, in _deserialize
    return deserialize_model(data, klass)
  File "/home/ubuntu/dvm-rest-api/dvmapi/util.py", line 103, in deserialize_model
    if not instance.openapi_types:
AttributeError: 'bytearray' object has no attribute 'openapi_types'
Description

When an object property is specified as type:string, format:byte, no code is generated to support deserialization.

openapi-generator version

HEAD of current master branch -> 4.0.0 - no regression.

OpenAPI declaration file content or url
openapi: 3.0.1
info:
  title: Flask Generator Issue
  description: This API provides an example of the problem with util.py generated but the Flask generator, for deserializing supported primitive types.
  version: 0.1.0
servers:
- url: http://localhost:8080
paths:
  /examples:
    get:
      summary: Example GET.
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Example'
components:
  schemas:
    Example:
      required:
      - data 
      properties:      
        data:
          type: string
          description: Base64 representation of data.
          format: byte
Steps to reproduce

Inspect util.py, there is no mention of the primitive type 'bytearray'. Inspect models/example.py, the data property is typed 'bytearray'.

        self.openapi_types = {
            'data': bytearray
        }
Suggest a fix

Update template to generate util.py to include 'bytearray' at

    if klass in six.integer_types or klass in (float, str, bool):
        return _deserialize_primitive(data, klass)
Assignee
Assign to
Time tracking