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] [kotlin-spring] Bigdecimal generation with default value is not working #14584

Closed
3 of 6 tasks
pdione opened this issue Feb 1, 2023 · 4 comments · Fixed by #17956
Closed
3 of 6 tasks

[BUG] [kotlin-spring] Bigdecimal generation with default value is not working #14584

pdione opened this issue Feb 1, 2023 · 4 comments · Fixed by #17956

Comments

@pdione
Copy link

pdione commented Feb 1, 2023

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

When we generate the code in Kotlin language with a Bigdecimal default value, the code doesn't compile.
We got a Type mismatch error : inferred type is Double but BigDecimal? was expected..
The kotlin-spring generator is used for my project. Find the documentation below :
https://openapi-generator.tech/docs/generators/kotlin-spring/

openapi-generator version

I'm using the 6.2.1 version of openapi-generator.

OpenAPI declaration file content or url

Please find below a sample of the affected class from my yaml file :

LoanType:
  type: object
  properties:
    projectTotalAmount:
      type: number
      description: |
        #### Total amount of the project
      default: -9999999999.99
    downpaymentAmount:
      type: number
      description: |
       #### Downpayment amount
      default: -9999999999.99
Generation Details

The expected generated code for the class fields should be :

data class LoanType(
	var projectTotalAmount: java.math.BigDecimal?= BigDecimal(-9999999999.99)
	var downpaymentAmount: java.math.BigDecimal?= BigDecimal(-9999999999.99)
)

Instead of the actual result that doesn't compile :

data class LoanType(
	var projectTotalAmount: java.math.BigDecimal?= -9999999999.99
	var downpaymentAmount: java.math.BigDecimal?= -9999999999.99
)
Steps to reproduce
Related issues/PRs
Suggest a fix
@wing328
Copy link
Member

wing328 commented Feb 2, 2023

@pdione may I know if you've time to contribute a fix? I can show you some good starting points.

@pdione
Copy link
Author

pdione commented Feb 15, 2023

@wing328 Sorry, i had some days off. It would be very appreciated if you can show me some starting points.
Please let me know how you want us to proceed.

@fjaouen
Copy link

fjaouen commented Feb 24, 2023

Hello @wing328, we are facing the same problem. Are you expecting to correct it quickly? Because it is a bit blocking for us. Thank you!

@jremeseiro
Copy link

jremeseiro commented Aug 31, 2023

Hello! We're also facing the same issue, it was fixed for kotlin config, but not for kotlin-spring: #10866, fixed in #12213, would be awesome to have it fixed for spring config also.
@wing328 if you can give some tips or maybe if it's similar to the kotlin fix we could make the contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants