forked from loafle/openapi-generator-original
[Swift5] Add useClasses cli option (#9608)
* [swift5] Add useClasses cliOption * Update swift docs
This commit is contained in:
parent
88f279ead3
commit
c4df343052
@ -39,6 +39,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|swiftPackagePath|Set a custom source path instead of OpenAPIClient/Classes/OpenAPIs.| |null|
|
||||
|swiftUseApiNamespace|Flag to make all the API classes inner-class of {{projectName}}API| |null|
|
||||
|useBacktickEscapes|Escape reserved words using backticks (default: false)| |false|
|
||||
|useClasses|Use final classes for models instead of structs (default: false)| |false|
|
||||
|useSPMFileStructure|Use SPM file structure and set the source path to Sources/{{projectName}} (default: false).| |null|
|
||||
|
||||
## IMPORT MAPPING
|
||||
|
@ -63,6 +63,7 @@ public class Swift5ClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
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 USE_CLASSES = "useClasses";
|
||||
public static final String USE_BACKTICK_ESCAPES = "useBacktickEscapes";
|
||||
public static final String GENERATE_MODEL_ADDITIONAL_PROPERTIES = "generateModelAdditionalProperties";
|
||||
public static final String HASHABLE_MODELS = "hashableModels";
|
||||
@ -82,6 +83,7 @@ public class Swift5ClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
protected boolean swiftUseApiNamespace = false;
|
||||
protected boolean useSPMFileStructure = false;
|
||||
protected String swiftPackagePath = "Classes" + File.separator + "OpenAPIs";
|
||||
protected boolean useClasses = false;
|
||||
protected boolean useBacktickEscapes = false;
|
||||
protected boolean generateModelAdditionalProperties = true;
|
||||
protected boolean hashableModels = true;
|
||||
@ -282,6 +284,8 @@ public class Swift5ClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
+ " and set the source path to Sources" + File.separator + "{{projectName}} (default: false)."));
|
||||
cliOptions.add(new CliOption(SWIFT_PACKAGE_PATH, "Set a custom source path instead of "
|
||||
+ projectName + File.separator + "Classes" + File.separator + "OpenAPIs" + "."));
|
||||
cliOptions.add(new CliOption(USE_CLASSES, "Use final classes for models instead of structs (default: false)")
|
||||
.defaultValue(Boolean.FALSE.toString()));
|
||||
|
||||
cliOptions.add(new CliOption(HASHABLE_MODELS,
|
||||
"Make hashable models (default: true)")
|
||||
@ -484,6 +488,11 @@ public class Swift5ClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
typeMapping.put("binary", "Data");
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(USE_CLASSES)) {
|
||||
setUseClasses(convertPropertyToBooleanAndWriteBack(USE_CLASSES));
|
||||
}
|
||||
additionalProperties.put(USE_CLASSES, useClasses);
|
||||
|
||||
setLenientTypeCast(convertPropertyToBooleanAndWriteBack(LENIENT_TYPE_CAST));
|
||||
|
||||
// make api and model doc path available in mustache template
|
||||
@ -904,6 +913,10 @@ public class Swift5ClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
this.swiftPackagePath = swiftPackagePath;
|
||||
}
|
||||
|
||||
public void setUseClasses(boolean useClasses) {
|
||||
this.useClasses = useClasses;
|
||||
}
|
||||
|
||||
public void setUseBacktickEscapes(boolean useBacktickEscapes) {
|
||||
this.useBacktickEscapes = useBacktickEscapes;
|
||||
}
|
||||
|
@ -96,6 +96,7 @@ public class Swift5OptionsProvider implements OptionsProvider {
|
||||
.put(Swift5ClientCodegen.GENERATE_MODEL_ADDITIONAL_PROPERTIES, GENERATE_MODEL_ADDITIONAL_PROPERTIES_VALUE)
|
||||
.put(Swift5ClientCodegen.HASHABLE_MODELS, HASHABLE_MODELS_VALUE)
|
||||
.put(Swift5ClientCodegen.MAP_FILE_BINARY_TO_DATA, "false")
|
||||
.put(Swift5ClientCodegen.USE_CLASSES, "false")
|
||||
.build();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user