diff --git a/docs/generators/swift6.md b/docs/generators/swift6.md index f6a81c3f3cb..aec4c81817f 100644 --- a/docs/generators/swift6.md +++ b/docs/generators/swift6.md @@ -29,6 +29,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |hashableModels|Make hashable models (default: true)| |true| |hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true| |legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|
**true**
The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.
**false**
The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.
|true| +|lenientTypeCast|Accept and cast values for simple types (string->bool, string->int, int->string)| |false| |library|Library template (sub-template) to use|
**urlsession**
[DEFAULT] HTTP client: URLSession
**alamofire**
HTTP client: Alamofire
**vapor**
HTTP client: Vapor
|urlsession| |mapFileBinaryToData|[WARNING] This option will be removed and enabled by default in the future once we've enhanced the code to work with `Data` in all the different situations. Map File and Binary to Data (default: false)| |false| |nonPublicApi|Generates code with reduced access modifiers; allows embedding elsewhere without exposing non-public API calls to consumers.(default: false)| |null| diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/Swift6ClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/Swift6ClientCodegen.java index ee3ee02ba3f..e075c95c7f9 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/Swift6ClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/Swift6ClientCodegen.java @@ -64,6 +64,7 @@ public class Swift6ClientCodegen extends DefaultCodegen implements CodegenConfig public static final String READONLY_PROPERTIES = "readonlyProperties"; public static final String SWIFT_USE_API_NAMESPACE = "swiftUseApiNamespace"; public static final String DEFAULT_POD_AUTHORS = "OpenAPI Generator"; + public static final String LENIENT_TYPE_CAST = "lenientTypeCast"; public static final String USE_SPM_FILE_STRUCTURE = "useSPMFileStructure"; public static final String SWIFT_PACKAGE_PATH = "swiftPackagePath"; public static final String ONE_OF_UNKNOWN_DEFAULT_CASE = "oneOfUnknownDefaultCase"; @@ -94,6 +95,8 @@ public class Swift6ClientCodegen extends DefaultCodegen implements CodegenConfig @Setter protected boolean objcCompatible = false; @Setter + protected boolean lenientTypeCast = false; + @Setter protected boolean readonlyProperties = false; @Setter protected boolean swiftUseApiNamespace = false; @@ -601,6 +604,8 @@ public class Swift6ClientCodegen extends DefaultCodegen implements CodegenConfig } additionalProperties.put(COMBINE_DEFERRED, combineDeferred); + setLenientTypeCast(convertPropertyToBooleanAndWriteBack(LENIENT_TYPE_CAST)); + // make api and model doc path available in mustache template additionalProperties.put("apiDocPath", apiDocPath); additionalProperties.put("modelDocPath", modelDocPath); diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/swift6/Swift6ClientCodegenOptionsTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/swift6/Swift6ClientCodegenOptionsTest.java index ee2ab3d21a5..676390038da 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/swift6/Swift6ClientCodegenOptionsTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/swift6/Swift6ClientCodegenOptionsTest.java @@ -46,6 +46,7 @@ public class Swift6ClientCodegenOptionsTest extends AbstractOptionsTest { verify(clientCodegen) .setNonPublicApi(Boolean.parseBoolean(Swift6ClientCodegenOptionsProvider.NON_PUBLIC_API_REQUIRED_VALUE)); verify(clientCodegen).setObjcCompatible(Boolean.parseBoolean(Swift6ClientCodegenOptionsProvider.OBJC_COMPATIBLE_VALUE)); + verify(clientCodegen).setLenientTypeCast(Boolean.parseBoolean(Swift6ClientCodegenOptionsProvider.LENIENT_TYPE_CAST_VALUE)); verify(clientCodegen).setPrependFormOrBodyParameters( Boolean.valueOf(Swift6ClientCodegenOptionsProvider.PREPEND_FORM_OR_BODY_PARAMETERS_VALUE)); verify(clientCodegen)