[BUG][SWIFT5] Swift5 generator sets wrong platforms requirement in Package.swift
Created by: deniskr
Description
Swift5 generates Package.swift a manifest file for Swift Package Manger. The manifest file contains a platforms directive that specifies the minimum iOS, macOS, tvOS, watchOS SDK version required to compile the generaged sources. Swift5 generator config options include a responseAs configuration that specifies what libraries the generated code should use. When responseAs is set to Combine, the generated code will use the Combine Framework, which is available on iOS 13, tvOS 13, macOS 10.15, watchOS 6 and above. The platforms directive in the Package.swift file does not reflect this requirement.
Expected Package.swift:
platforms: [
.iOS(.v13),
.macOS(.v10_11),
.tvOS(.v9),
.watchOS(.v3)
],
Actual Package.swift:
platforms: [
.iOS(.v9),
.macOS(.v10_11),
.tvOS(.v9),
.watchOS(.v3)
],
openapi-generator version
4.3.1
OpenAPI declaration file content or url
Gradle.build.kts:
openApiGenerate {
validateSpec.set(true)
generatorName.set("swift5")
outputDir.set(openApiOutputDir.toString())
inputSpec.set(file("openapi.yaml").toString())
configOptions.set(mapOf(
"nonPublicApi" to "false",
"responseAs" to "Combine",
"projectName" to "SpeedtestPlus",
"swiftUseApiNamespace" to "false"
))
}
Steps to reproduce
Create a Gradle build file with the above configuration, use any openapi.yaml, and generate.
Suggest a fix
When responseAs is set to Combine, the platforms directive in Package.swift should be as follows:
platforms: [
.iOS(.v13),
.macOS(.v10_15),
.tvOS(.v13),
.watchOS(.v6)
],