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][SCALA] instantiationType array is missed in Scalatra generator #5507

Closed
6 tasks
chameleon82 opened this issue Mar 3, 2020 · 1 comment
Closed
6 tasks

Comments

@chameleon82
Copy link
Contributor

chameleon82 commented Mar 3, 2020

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)

Scalatra server template generating wrong default value new null[]() instead of 'List[String].emptydue missedarray` instantiationType

Description
openapi-generator version

2.3.0-SNAPSHOT

OpenAPI declaration file content or url

https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/test/resources/3_0/petstore.yaml

Command line used for generation
Steps to reproduce

regenerate scalatra server - default value has incorrect value new null[](). should be List[String].empty

Related issues/PRs

Related code 25036e4#diff-62e3a15550247bb6a76bdc7745faa850R265

Suggest a fix

Add instantiationTypes.put("array", "List"); at abstract level or per template if array has specific meaning

@jimschubert

@chameleon82 chameleon82 changed the title [BUG][SCALA] instantiationType array is missed in Scala generators [BUG][SCALA] instantiationType array is missed in Scalatra generator Mar 3, 2020
@jimschubert
Copy link
Member

Hm. This existed when I stepped through the code last. I wonder if I forgot to commit or if it came from DefaultCodegen and has since been removed. Or maybe it was only defined in a derived generator.

I imagine we'd have the same issue for all OpenAPI types which should not be Java types and really shouldn't rely on DefaultCodegen to "do the right thing" (like map should instantiate with immutable Map by default).

chameleon82 referenced this issue Mar 3, 2020
* [scala] Set support for unique arrays

This includes and builds upon community contribution for better Set support in Scala.
It makes property + model work as expected with Set and default values
across all Scala generators. Included tests to account for new changes.

This also reverts the community contribution to remove ListBuffer
imports and change the default for array to ListBuffer. Users should use
the instantiation types map to modify the desired array instantiation
type. Any new default should target a new minor release after community
discussion, as it affects all existing SDKs generated with
openapi-generator.

* [scala] Improve default handling of monadic collection type

* [scala] Regenerate samples

* Update ScalaPlayFrameworkServerCodegen.java

Scala Play defaulted to List and should continue to do so.

Co-authored-by: František Kocun <frantisek.kocun@gmail.com>
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

2 participants