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

Reasoning for always setting defaultNumberType #1613

Closed
2 of 4 tasks
Marcelo00 opened this issue Apr 17, 2024 · 2 comments
Closed
2 of 4 tasks

Reasoning for always setting defaultNumberType #1613

Marcelo00 opened this issue Apr 17, 2024 · 2 comments
Labels

Comments

@Marcelo00
Copy link

Marcelo00 commented Apr 17, 2024

Sorting

  • I'm submitting a ...

    • bug report
    • feature request
    • support request
  • I confirm that I

    • used the search to make sure that a similar issue hasn't already been submit

Expected Behavior

If you have the following property in an interface

export interface ExampleInterface {
   numberType: number;
}

I would expect TSOA to not add a format option to the corresponding type in the openapi.yaml:

numberType:
   type: number

Additionally, I do not have the optional defaultNumberType config set in my TSOA config.

Current Behavior

This is the result I will get:

numberType:
   type: number
   format: double

The source of this behavior comes from lines 148-150 in packages/cli/src/cli.ts - see this pull request. If you not set defaultNumberType, it will just assume a double type for the numberType. In this context I wanted to get some clarification on why this behavior is the default approach?

For our use case, we would like to just have the type without the optional format. In downstream tasks it would lead to some confusion in the validation as the input 0 will be validated against the type double in the current default behavior. For languages like Python, it would lead to an error with such an input because the 0 is an integer. Removing format: double would lead to a successful validation as only number consists of floating numbers and integers.

Possible Solution

Remove the respective lines.

Steps to Reproduce

Context (Environment)

Version of the library: 6.2.0
Version of NodeJS: 18.18.0

  • Confirm you were using yarn not npm: [x]

Detailed Description

Breaking change?

Copy link

Hello there Marcelo00 👋

Thank you for opening your very first issue in this project.

We will try to get back to you as soon as we can.👀

Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days

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

No branches or pull requests

1 participant