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

[Kotlin] support array, list in collection type #1564

Merged
merged 4 commits into from
Nov 29, 2018
Merged

[Kotlin] support array, list in collection type #1564

merged 4 commits into from
Nov 29, 2018

Conversation

absimas
Copy link
Contributor

@absimas absimas commented Nov 28, 2018

PR checklist

  • Read the contribution guidelines.
  • Ran the shell script under ./bin/ to update Petstore sample so that CIs can verify the change. (For instance, only need to run ./bin/{LANG}-petstore.sh and ./bin/security/{LANG}-petstore.sh if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in .\bin\windows\.
  • Filed the PR against the correct branch: master, 3.4.x, 4.0.x. Default: master.
  • Copied the technical committee to review the pull request if your PR is targeting a particular programming language.

Description of the PR

Swagger spec file contains only array types thus it is always the preferred choice when converting to kotlin. Allow specifying which collection type to convert to.

@jimschubert @dr4ke616

Copy link
Member

@jimschubert jimschubert left a comment

Choose a reason for hiding this comment

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

Looks good to me, although we may want to keep list as the default until the next major release as this will be a breaking change for regenerated clients.

I think I originally created the default as Array and someone had a compelling argument to default to List. Adding a configurable choice is the best way to solve the preference difference.

@absimas
Copy link
Contributor Author

absimas commented Nov 28, 2018

I don't quite understand your comment on the default.

Current default is array and this code doesn't change that, thus this is not a breaking change.

@absimas
Copy link
Contributor Author

absimas commented Nov 28, 2018

Oh unless you meant the default for list which indeed was kotlin.collections.List.

@jimschubert
Copy link
Member

@absimas yes, sorry for the confusion. For a non-breaking change we would want array and list to remain the same default type until the next major release.

I haven't tested if this PR still works with type mappings (another way users can modify these defaults), so I (or someone else) need to test that before merge.

@wing328
Copy link
Member

wing328 commented Nov 29, 2018

Tested with both array and list, and the output compiles without issues.

@wing328 wing328 added this to the 3.3.4 milestone Nov 29, 2018
@wing328 wing328 merged commit 777bf1f into OpenAPITools:master Nov 29, 2018
@wing328 wing328 changed the title Kotlin collection type [Kotlin] support array, list in collection type Nov 29, 2018
@wing328
Copy link
Member

wing328 commented Dec 4, 2018

@absimas thanks for the PR, which has been included in the v3.3.4 release: https://twitter.com/oas_generator/status/1068772409795207168

A-Joshi pushed a commit to ihsmarkitoss/openapi-generator that referenced this pull request Feb 27, 2019
* Allow specifying type

* Add test

* Update docs

* Don't modify types if the default option is chosen
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.

3 participants