[SWIFT4] Value of type XX has no member 'map'
Created by: Sal0g
Description
When using using Objc compatible code, the produced code is not valid in Swift 3/4.
Using openapi-generator Version 3.3.2
with the command:
openapi-generator generate \
-i ./openAPI-3.yaml \
--config ./api-generation-config.json \
-g swift4 \
and the config file api-generation-config.json:
{
...
"objcCompatible":"true",
"podswift_version":"4.0"
}
and the yaml:
definitions:
ModelA:
required:
- intA
properties:
intA:
type: integer
format: int64
name:
type: string
produces this code:
public struct ModelA: Codable {
public var intA: Int64
public var intANum: NSNumber? {
get {
return intA.map({ return NSNumber(value: $0) })
}
}
public var name: String?
public init(intA: Int64, name: String?) {
self.intA = intA
self.name = name
}
}
resulting in the error:
- ERROR | xcodebuild: ModelA.swift: error: value of type 'Int64' has no member 'map'
This occurs for type Int64 and Bool.