Skip to content

Commit ae92e68

Browse files
authored
Merge branch 'master' into issue-9495
2 parents f4c7325 + b22ed93 commit ae92e68

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/Swift4Codegen.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public class Swift4Codegen extends DefaultCodegen implements CodegenConfig {
6060
protected static final String LIBRARY_PROMISE_KIT = "PromiseKit";
6161
protected static final String LIBRARY_RX_SWIFT = "RxSwift";
6262
protected static final String[] RESPONSE_LIBRARIES = {LIBRARY_PROMISE_KIT, LIBRARY_RX_SWIFT};
63+
protected static final String MODEL_CLASSES = "modelClasses";
6364
protected String projectName = "SwaggerClient";
6465
protected boolean unwrapRequired;
6566
protected boolean objcCompatible = false;
@@ -302,6 +303,10 @@ public void processOpts() {
302303
additionalProperties.put(POD_AUTHORS, DEFAULT_POD_AUTHORS);
303304
}
304305

306+
if (additionalProperties.containsKey(MODEL_CLASSES)) {
307+
additionalProperties.put("useModelClasses", true);
308+
}
309+
305310
setLenientTypeCast(convertPropertyToBooleanAndWriteBack(LENIENT_TYPE_CAST));
306311

307312
supportingFiles.add(new SupportingFile("Podspec.mustache",

modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/Swift5Codegen.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public class Swift5Codegen extends DefaultCodegen implements CodegenConfig {
4747
private static final String LIBRARY_PROMISE_KIT = "PromiseKit";
4848
private static final String LIBRARY_RX_SWIFT = "RxSwift";
4949
private static final String[] RESPONSE_LIBRARIES = {LIBRARY_PROMISE_KIT, LIBRARY_RX_SWIFT};
50+
protected static final String MODEL_CLASSES = "modelClasses";
5051
protected String projectName = "SwaggerClient";
5152
private boolean unwrapRequired;
5253
private boolean objcCompatible = false;
@@ -289,6 +290,10 @@ public void processOpts() {
289290
additionalProperties.put(POD_AUTHORS, DEFAULT_POD_AUTHORS);
290291
}
291292

293+
if (additionalProperties.containsKey(MODEL_CLASSES)) {
294+
additionalProperties.put("useModelClasses", true);
295+
}
296+
292297
setLenientTypeCast(convertPropertyToBooleanAndWriteBack(LENIENT_TYPE_CAST));
293298

294299
supportingFiles.add(new SupportingFile("Podspec.mustache",

modules/swagger-codegen/src/main/resources/swift4/modelObject.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
public struct {{classname}}: Codable {
2+
public {{#useModelClasses}}class{{/useModelClasses}}{{^useModelClasses}}struct{{/useModelClasses}} {{classname}}: Codable {
33
44
{{#allVars}}
55
{{#isEnum}}

modules/swagger-codegen/src/main/resources/swift5/modelObject.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
public struct {{classname}}: Codable {
2+
public {{#useModelClasses}}class{{/useModelClasses}}{{^useModelClasses}}struct{{/useModelClasses}} {{classname}}: Codable {
33
44
{{#allVars}}
55
{{#isEnum}}

0 commit comments

Comments
 (0)