[Python] remove default value from being fallback to example (#2213)

* remove example fallback

* reset test case
This commit is contained in:
William Cheng
2019-02-22 20:44:27 +08:00
committed by GitHub
parent 163b00459f
commit f2002b25da
59 changed files with 77 additions and 105 deletions

View File

@@ -614,14 +614,6 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
else
return "True";
}
// include fallback to example, default defined as server only
// example is not defined as server only
if (p.getExample() != null) {
if (Boolean.valueOf(p.getExample().toString()) == false)
return "False";
else
return "True";
}
} else if (ModelUtils.isDateSchema(p)) {
// TODO
} else if (ModelUtils.isDateTimeSchema(p)) {
@@ -630,10 +622,6 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
if (p.getDefault() != null) {
return p.getDefault().toString();
}
// default numbers are not yet returned by v2 spec openAPI results
// https://github.com/swagger-api/swagger-parser/issues/971
// include fallback to example, default defined as server only
// example is not defined as server only
if (p.getExample() != null) {
return p.getExample().toString();
}
@@ -641,13 +629,6 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
if (p.getDefault() != null) {
return p.getDefault().toString();
}
// default integers are not yet returned by v2 spec openAPI results
// https://github.com/swagger-api/swagger-parser/issues/971
// include fallback to example, default defined as server only
// example is not defined as server only
if (p.getExample() != null) {
return p.getExample().toString();
}
} else if (ModelUtils.isStringSchema(p)) {
if (p.getDefault() != null) {
if (Pattern.compile("\r\n|\r|\n").matcher((String) p.getDefault()).find())
@@ -655,23 +636,10 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
else
return "'" + p.getDefault() + "'";
}
// include fallback to example, default defined as server only
// example is not defined as server only
if (p.getExample() != null) {
if (Pattern.compile("\r\n|\r|\n").matcher((String) p.getExample()).find())
return "'''" + p.getExample() + "'''";
else
return "'" + p.getExample() + "'";
}
} else if (ModelUtils.isArraySchema(p)) {
if (p.getDefault() != null) {
return p.getDefault().toString();
}
// include fallback to example, default defined as server only
// example is not defined as server only
if (p.getExample() != null) {
return p.getExample().toString();
}
}
return null;

View File

@@ -1344,6 +1344,7 @@ definitions:
uuid:
type: string
format: uuid
example: 72f98069-206d-4f12-9f12-3d1e525a8e84
password:
type: string
format: password

View File

@@ -1373,6 +1373,7 @@ components:
uuid:
type: string
format: uuid
example: 72f98069-206d-4f12-9f12-3d1e525a8e84
password:
type: string
format: password