Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #1456
Closed
Open
Issue created Nov 15, 2018 by Administrator@rootContributor

[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.

Assignee
Assign to
Time tracking