Skip to content

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

@pdione

Description

@pdione

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions