Skip to content

[BUG] [dart-dio-next] Custom Date type has no replace method #10672

@MihaMarkic

Description

@MihaMarkic
Description

In yaml definition I have a class with a property like this:

absentFrom:
        $ref: '#/definitions/Date'

and below is Date definition as

Date:
    type: object
    required:
      - year
      - month
      - day
    properties:
      year:
        type: integer
        format: int32
      month:
        type: integer
        format: int32
      day:
        type: integer
        format: int32

Generator creates code that relies on autogenerated Date type's replace method which does not exist.

case r'absentFrom':
          final valueDes = serializers.deserialize(value,
              specifiedType: const FullType(Date)) as Date;
          result.absentFrom.replace(valueDes);
          break;

The problem is that there is no replace method on dart's Date type, at least so it seems.

openapi-generator version

5.2.1, 6.0.0

OpenAPI declaration file content or url

Full model

SchoolAbsenceDay:
    type: object
    required:
      - year
      - month
      - day
    properties:
      year:
        type: integer
        format: int32
      month:
        type: integer
        format: int32
      day:
        type: integer
        format: int32
      absentFrom:
        $ref: '#/definitions/Date'
      absentTo:
        $ref: '#/definitions/Date'
      schoolType:
        type: string
      school:
        type: string
      personType:
        type: string
      personClass:
        type: string
      reason:
        type: string
  Date:
    type: object
    required:
      - year
      - month
      - day
    properties:
      year:
        type: integer
        format: int32
      month:
        type: integer
        format: int32
      day:
        type: integer
        format: int32
Generation Details

˙... -g dart-dio-next -c open-generator-config.yaml --enable-post-process-file
dart-dio yields same result

Steps to reproduce

Generate dart-dio-next code from

Suggest a fix

Deserialization should create a new Date instance instead of using replace method.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions