Closed wtho closed 4 years ago
The current workaround from my side was to create bigDecimal.ts
with
export type BigDecimal = number;
which is quite annoying to do every time.
So in JS/TS there are no native solutions for arbitrary-precision decimal arithmetic, but there are e. g. these libraries to achieve it:
(At least for big.js
) There are also corresponding typings in DefinitelyTyped/types
.
If you don't like to include any of them or implement BigDecimal in JS/TS on swagger's side, it does not make much sense to use some sort of BigDecimal
in JS/TS. In that case number
should work just fine.
Are there swagger guidelines on type projections to other languages?
If there is a consent how to handle this and someone points me on the right code locations I'm happy to create a PR. With the current setup and the missing BigDecimal
this generator is not usable.
hi @wtho, this issue has been fixed, for latest releases, mapping BigDecimal
to number
. going to close issue, but please let me know if you still get the issue.
I've run into this issue myself. A generated model attempts to import BigDecimal
in a way similar to @wtho initial example does, but the file is missing. In my case, I'm using the generic javascript
generator, not typescript-angular
, so let me know if it's preferred for me to create a new issue.
Using the latest build available to me at the moment:
https://oss.sonatype.org/content/repositories/snapshots/io/swagger/codegen/v3/swagger-codegen-cli/3.0.17-SNAPSHOT/swagger-codegen-cli-3.0.17-20200123.095202-4-javadoc.jar
.
Edit: I'm fairly new to these tools, and I've realized that this isn't as issue for the swagger-codegen
repo, so my report may be misplaced. I can see here that the type mappings defined in this lib don't correlate with my experience.
@HugoMario is there any difference between swagger-codegen-cli and swagger-codegen-cli-v3? I tried latest
, 3.0.18
and unstable
on swagger-codegen-cli-v3
and BigDecimal is still poppin' up. Also I am using the javascript generator.
More specifically when I'm using swagger-codegen-cli:latest
instead, I get this one
missing swagger input or config!
edit: I get the above error because swagger-codegen-cli uses v2 by default and that doesn't support OpenAPI v3 (which I am using)
@itbrandonsilva @AmazingTurtle going to check this issue, thanks for letting me know
hey @itbrandonsilva @AmazingTurtle
Can you please try with 3.0.20 version
@HugoMario I can confirm, BigDecimal is gone by now with the 3.0.20 version. Thanks for the fix
Issue
When generating (v3.0.5) using
and the schema (swagger: 2.0) contains a field
it generates this model:
The problem is, that the file
bigDecimal.ts
is never created.If the schema contains
it renders
someOtherField: number;