Swagger-codegen: [SWIFT 4] BigDecimal support in Swift4Codegen not available.

Created on 26 Jun 2018  路  1Comment  路  Source: swagger-api/swagger-codegen

Description

Swift4Codegen.java does not have type mapping for bigdecimal. Even if we add the below line

typeMapping.put("bigdecimal", "Double");

in Swift4Codegen.java and compile the jar and run it. it gives the below error

[main] WARN io.swagger.util.PropertyDeserializer - no property from bigdecimal, null, {ENUM=null, TITLE=null, DESCRIPTION=null, DEFAULT=null, PATTERN=null, DESCRIMINATOR=null, MIN_ITEMS=null, MAX_ITEMS=null, MIN_PROPERTIES=null, MAX_PROPERTIES=null, MIN_LENGTH=null, MAX_LENGTH=null, MINIMUM=null, MAXIMUM=null, EXCLUSIVE_MINIMUM=null, EXCLUSIVE_MAXIMUM=null, UNIQUE_ITEMS=null, EXAMPLE=null, TYPE=bigdecimal, FORMAT=null, READ_ONLY=null, VENDOR_EXTENSIONS={}, MULTIPLE_OF=null}

Swagger-codegen version

master code

Swagger declaration file content or url
swagger: "2.0"
info:
  description: "Testing the swagger YAML to swift 4"
  version: "1.0.0"
  title: "testing swift"
  contact:
    email: "[email protected]"
  license:
    name: "sample code"
host: "localhost:8080"
basePath: "/v2"
schemes:
- "http"
paths:
  /user:
    put:
      summary: "Updated user"
      description: "This can only be done by the logged in user."
      operationId: "updateUser"
      produces:
      - "application/json"
      parameters:
      - in: "body"
        name: "user"
        description: "Updated user object"
        required: true
        schema:
          $ref: "#/definitions/User"
      responses:
        400:
          description: "Invalid user supplied"
        404:
          description: "User not found"
definitions:
  User:
    type: "object"
    properties:
      desk:
        type: "bigdecimal"
      firstName:
        type: "string"

Command line used for generation

swagger-codegen generate -i swagger_1.yaml -l swift4

Steps to reproduce

always

Related issues/PRs
Suggest a fix/enhancement

if I change my yaml and convert the
definitions:
User:
type: "object"
properties:
desk:
type: "number"
firstName:
type: "string"

then it works fine.
please tell me if 'number' should be used for big decimal in yaml? so that it gets converted to Double in swift?

Most helpful comment

Also seeing this issue

>All comments

Also seeing this issue

Was this page helpful?
0 / 5 - 0 ratings