mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2026-03-18 16:59:05 +00:00
This fixes an issue that makes the swift 4 api client fail to compile when using enums with a default value. The fix changes the toDefaultValue method to check if the property is of enum type, and then returns a properly formatted value. Looking into the code, I wonder why toEnumDefaultValue is not being used here, which seems to be the case for the java implementation.
This commit is contained in:
committed by
William Cheng
parent
7596fb7119
commit
f80fa08a01
@@ -510,6 +510,11 @@ public class Swift4Codegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
@Override
|
||||
public String toDefaultValue(Schema p) {
|
||||
if (p.getEnum() != null && !p.getEnum().isEmpty()) {
|
||||
if (p.getDefault() != null) {
|
||||
return "." + escapeText((String) p.getDefault());
|
||||
}
|
||||
}
|
||||
if (ModelUtils.isIntegerSchema(p) || ModelUtils.isNumberSchema(p) || ModelUtils.isBooleanSchema(p)) {
|
||||
if (p.getDefault() != null) {
|
||||
return p.getDefault().toString();
|
||||
|
||||
Reference in New Issue
Block a user