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] [dart-dio-next] Custom Date type has no replace method #10672

Open
MihaMarkic opened this issue Oct 23, 2021 · 5 comments
Open

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

MihaMarkic opened this issue Oct 23, 2021 · 5 comments

Comments

@MihaMarkic
Copy link

MihaMarkic commented Oct 23, 2021

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.

@MihaMarkic MihaMarkic changed the title [BUG] [dart-dio-next] Custom Date type is handled as dart's Date [BUG] [dart-dio-next] Custom Date type has no replace method Oct 24, 2021
@kuhnroyal
Copy link
Contributor

Can you try using import mappings according to #10522 please.
We are creating an own Date class with dart-dio-next these two are probably conflict.
You should be able to fix that with mappings.

@MihaMarkic
Copy link
Author

@kuhnroyal Will try and feedback here, thanks

@MargieMo
Copy link

MargieMo commented Dec 4, 2021

May I have "open-generator-config.yaml" this file?
I think I also need one more yaml file.

Thank you. @MihaMarkic

@kuhnroyal
Copy link
Contributor

@MihaMarkic Can you tell us if you solved this via mappings?

@MihaMarkic
Copy link
Author

@kuhnroyal For the time being I just manually updated generated sources and then I postponed the project. So I didn't do much in this direction yet.

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

3 participants