Skip to content

Commit

Permalink
fix typo in swift option, minor code format enhancement
Browse files Browse the repository at this point in the history
  • Loading branch information
wing328 committed Dec 30, 2024
1 parent 8fa8530 commit 37912ec
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 45 deletions.
2 changes: 1 addition & 1 deletion docs/generators/swift5.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|useCustomDateWithoutTime|Uses a custom type to decode and encode dates without time information to support OpenAPIs date format (default: false)| |false|
|useJsonEncodable|Make models conform to JSONEncodable protocol (default: true)| |true|
|useSPMFileStructure|Use SPM file structure and set the source path to Sources/{{projectName}} (default: false).| |null|
|validatable|Make validation rules and validator for model properies (default: true)| |true|
|validatable|Make validation rules and validator for model properties (default: true)| |true|

## IMPORT MAPPING

Expand Down
2 changes: 1 addition & 1 deletion docs/generators/swift6.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|useCustomDateWithoutTime|Uses a custom type to decode and encode dates without time information to support OpenAPIs date format (default: false)| |false|
|useJsonEncodable|Make models conform to JSONEncodable protocol (default: true)| |true|
|useSPMFileStructure|Use SPM file structure and set the source path to Sources/{{projectName}} (default: true).| |null|
|validatable|Make validation rules and validator for model properies (default: true)| |true|
|validatable|Make validation rules and validator for model properties (default: true)| |true|

## IMPORT MAPPING

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,25 +84,43 @@ public class Swift5ClientCodegen extends DefaultCodegen implements CodegenConfig
protected static final String RESPONSE_LIBRARY_COMBINE = "Combine";
protected static final String RESPONSE_LIBRARY_ASYNC_AWAIT = "AsyncAwait";
protected static final String[] RESPONSE_LIBRARIES = {RESPONSE_LIBRARY_PROMISE_KIT, RESPONSE_LIBRARY_RX_SWIFT, RESPONSE_LIBRARY_RESULT, RESPONSE_LIBRARY_COMBINE, RESPONSE_LIBRARY_ASYNC_AWAIT};
@Setter protected String projectName = "OpenAPIClient";
@Setter protected boolean nonPublicApi = false;
@Setter protected boolean objcCompatible = false;
@Setter protected boolean readonlyProperties = false;
@Setter protected boolean swiftUseApiNamespace = false;
@Setter protected boolean useSPMFileStructure = false;
@Setter protected String swiftPackagePath = "Classes" + File.separator + "OpenAPIs";
@Setter protected boolean oneOfUnknownDefaultCase = false;
@Setter protected boolean useClasses = false;
@Setter protected boolean useBacktickEscapes = false;
@Setter protected boolean generateModelAdditionalProperties = true;
@Setter protected boolean hashableModels = true;
@Setter protected boolean identifiableModels = true;
@Setter protected boolean useJsonEncodable = true;
@Getter @Setter
@Setter
protected String projectName = "OpenAPIClient";
@Setter
protected boolean nonPublicApi = false;
@Setter
protected boolean objcCompatible = false;
@Setter
protected boolean readonlyProperties = false;
@Setter
protected boolean swiftUseApiNamespace = false;
@Setter
protected boolean useSPMFileStructure = false;
@Setter
protected String swiftPackagePath = "Classes" + File.separator + "OpenAPIs";
@Setter
protected boolean oneOfUnknownDefaultCase = false;
@Setter
protected boolean useClasses = false;
@Setter
protected boolean useBacktickEscapes = false;
@Setter
protected boolean generateModelAdditionalProperties = true;
@Setter
protected boolean hashableModels = true;
@Setter
protected boolean identifiableModels = true;
@Setter
protected boolean useJsonEncodable = true;
@Getter
@Setter
protected boolean mapFileBinaryToData = false;
@Setter protected boolean useCustomDateWithoutTime = false;
@Setter protected boolean validatable = true;
@Setter protected String[] responseAs = new String[0];
@Setter
protected boolean useCustomDateWithoutTime = false;
@Setter
protected boolean validatable = true;
@Setter
protected String[] responseAs = new String[0];
protected String sourceFolder = swiftPackagePath;
protected HashSet objcReservedWords;
protected String apiDocPath = "docs/";
Expand Down Expand Up @@ -322,7 +340,7 @@ public Swift5ClientCodegen() {
.defaultValue(Boolean.FALSE.toString()));

cliOptions.add(new CliOption(VALIDATABLE,
"Make validation rules and validator for model properies (default: true)")
"Make validation rules and validator for model properties (default: true)")
.defaultValue(Boolean.TRUE.toString()));

supportedLibraries.put(LIBRARY_URLSESSION, "[DEFAULT] HTTP client: URLSession");
Expand Down Expand Up @@ -1189,7 +1207,7 @@ public void postProcessFile(File file, String fileType) {
}
// only process files with swift extension
if ("swift".equals(FilenameUtils.getExtension(file.toString()))) {
this.executePostProcessor(new String[] {swiftPostProcessFile, file.toString()});
this.executePostProcessor(new String[]{swiftPostProcessFile, file.toString()});
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,27 +86,48 @@ public class Swift6ClientCodegen extends DefaultCodegen implements CodegenConfig
protected static final String RESPONSE_LIBRARY_COMBINE = "Combine";
protected static final String RESPONSE_LIBRARY_ASYNC_AWAIT = "AsyncAwait";
protected static final String RESPONSE_LIBRARY_OBJC_BLOCK = "ObjcBlock";
protected static final String[] RESPONSE_LIBRARIES = { RESPONSE_LIBRARY_ASYNC_AWAIT, RESPONSE_LIBRARY_COMBINE, RESPONSE_LIBRARY_RESULT, RESPONSE_LIBRARY_RX_SWIFT, RESPONSE_LIBRARY_OBJC_BLOCK, RESPONSE_LIBRARY_PROMISE_KIT };
@Setter protected String projectName = "OpenAPIClient";
@Setter protected boolean nonPublicApi = false;
@Setter protected boolean objcCompatible = false;
@Setter protected boolean readonlyProperties = false;
@Setter protected boolean swiftUseApiNamespace = false;
@Setter protected boolean useSPMFileStructure = true;
@Setter protected String swiftPackagePath = "Sources" + File.separator + projectName;
@Setter protected boolean oneOfUnknownDefaultCase = false;
@Setter protected boolean useClasses = false;
@Setter protected boolean useBacktickEscapes = false;
@Setter protected boolean generateModelAdditionalProperties = true;
@Setter protected boolean hashableModels = true;
@Setter protected boolean identifiableModels = true;
@Setter protected boolean useJsonEncodable = true;
@Getter @Setter protected boolean mapFileBinaryToData = false;
@Setter protected boolean useCustomDateWithoutTime = false;
@Setter protected boolean validatable = true;
@Setter protected boolean apiStaticMethod = true;
@Setter protected boolean combineDeferred = true;
@Setter protected String[] responseAs = { RESPONSE_LIBRARY_ASYNC_AWAIT };
protected static final String[] RESPONSE_LIBRARIES = {RESPONSE_LIBRARY_ASYNC_AWAIT, RESPONSE_LIBRARY_COMBINE, RESPONSE_LIBRARY_RESULT, RESPONSE_LIBRARY_RX_SWIFT, RESPONSE_LIBRARY_OBJC_BLOCK, RESPONSE_LIBRARY_PROMISE_KIT};
@Setter
protected String projectName = "OpenAPIClient";
@Setter
protected boolean nonPublicApi = false;
@Setter
protected boolean objcCompatible = false;
@Setter
protected boolean readonlyProperties = false;
@Setter
protected boolean swiftUseApiNamespace = false;
@Setter
protected boolean useSPMFileStructure = true;
@Setter
protected String swiftPackagePath = "Sources" + File.separator + projectName;
@Setter
protected boolean oneOfUnknownDefaultCase = false;
@Setter
protected boolean useClasses = false;
@Setter
protected boolean useBacktickEscapes = false;
@Setter
protected boolean generateModelAdditionalProperties = true;
@Setter
protected boolean hashableModels = true;
@Setter
protected boolean identifiableModels = true;
@Setter
protected boolean useJsonEncodable = true;
@Getter
@Setter
protected boolean mapFileBinaryToData = false;
@Setter
protected boolean useCustomDateWithoutTime = false;
@Setter
protected boolean validatable = true;
@Setter
protected boolean apiStaticMethod = true;
@Setter
protected boolean combineDeferred = true;
@Setter
protected String[] responseAs = {RESPONSE_LIBRARY_ASYNC_AWAIT};
protected String sourceFolder = swiftPackagePath;
protected HashSet objcReservedWords;
protected String apiDocPath = "docs/";
Expand Down Expand Up @@ -326,7 +347,7 @@ public Swift6ClientCodegen() {
.defaultValue(Boolean.FALSE.toString()));

cliOptions.add(new CliOption(VALIDATABLE,
"Make validation rules and validator for model properies (default: true)")
"Make validation rules and validator for model properties (default: true)")
.defaultValue(Boolean.TRUE.toString()));

cliOptions.add(new CliOption(API_STATIC_METHOD,
Expand Down Expand Up @@ -1222,7 +1243,7 @@ public void postProcessFile(File file, String fileType) {
}
// only process files with swift extension
if ("swift".equals(FilenameUtils.getExtension(file.toString()))) {
this.executePostProcessor(new String[] {swiftPostProcessFile, file.toString()});
this.executePostProcessor(new String[]{swiftPostProcessFile, file.toString()});
}
}

Expand Down

0 comments on commit 37912ec

Please sign in to comment.