Skip to content

[dart] fix toJson does not handle complex type#6730

Merged
wing328 merged 2 commits intoOpenAPITools:masterfrom
agilob:4562
Jul 22, 2020
Merged

[dart] fix toJson does not handle complex type#6730
wing328 merged 2 commits intoOpenAPITools:masterfrom
agilob:4562

Conversation

@agilob
Copy link
Copy Markdown
Contributor

@agilob agilob commented Jun 20, 2020

Rebase of #5189 that fixes #4562

PR checklist

  • Read the contribution guidelines.
  • If contributing template-only or documentation-only changes which will change sample output, build the project beforehand.
  • Run the shell script ./bin/generate-samples.shto update all Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master. These must match the expectations made by your contribution. You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/config/java*. For Windows users, please run the script in Git BASH.
  • File the PR against the correct branch: master
  • Copy the technical committee to review the pull request if your PR is targeting a particular programming language.

@ircecho (2017/07) @swipesight (2018/09) @jaumard (2018/09) @nickmeinhold (2019/09) @athornz (2019/12) @amondnet (2019/12)

@sbu-WBT
Copy link
Copy Markdown
Contributor

sbu-WBT commented Jul 15, 2020

Hi, I tested this PR with this https://github.com/geoDavey/osrm-openapi/blob/master/osrm-openapi.yaml OpenAPI specification.
The thing is, I can't find any change between before and after the PR.

For Example:
List<Waypoint> destinations = []; is defined in the class TableResponse.

But in the toJson() method you can still find this:

    if (destinations != null)
      json['destinations'] = destinations;

The same problem exists also with objects without lists, if you look inside the annotation.dart.

It would be very nice if this could get fixed, because this is a very big problem for serialization. Thank you

{{/complexType}}
{{^complexType}}
'{{baseName}}': {{name}}{{^-last}},{{/-last}}
{{/complexType}}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@agilob Can we keep the indentation as 2-space? It would make the code review a lot easier.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This MR will cause a bunch of conflicts with 2 other MR I have in progress and it's not my changes, I resurrected commit from
@arndt-s. I will take care of it as the last thing if you dont mind?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed with taking care of the code indentation in another PR.

@agilob
Copy link
Copy Markdown
Contributor Author

agilob commented Jul 21, 2020

It would be very nice if this could get fixed, because this is a very big problem for serialization. Thank you

Totally agree, but as per comment above, I think this should be solved after more fundamental problems are solved in dart generation, like basic enums, non-nullable fields. Please also note these aren't my changes. I picked old MR, fixed git conflict and reopened it.

@wing328 wing328 merged commit a59e506 into OpenAPITools:master Jul 22, 2020
@wing328 wing328 added this to the 5.0.0 milestone Jul 22, 2020
@agilob agilob deleted the 4562 branch September 25, 2021 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Dart mustache model toJson doesn't handle the situation which the property is object or array

4 participants