forked from loafle/openapi-generator-original
Better error handling for toExampleValue (#8940)
* better error handling for toExampleValue * revise logging * update debug
This commit is contained in:
parent
5d7f1c1c88
commit
bf859c640e
@ -3103,7 +3103,14 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
property.title = p.getTitle();
|
||||
property.getter = toGetter(name);
|
||||
property.setter = toSetter(name);
|
||||
// put toExampleValue in a try-catch block to log the error as example values are not critical
|
||||
try {
|
||||
property.example = toExampleValue(p);
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error in generating `example` for the property {}. Default to ERROR_TO_EXAMPLE_VALUE. Enable debugging for more info.", property.baseName);
|
||||
LOGGER.debug("Exception from toExampleValue: {}", e);
|
||||
property.example = "ERROR_TO_EXAMPLE_VALUE";
|
||||
}
|
||||
property.defaultValue = toDefaultValue(p);
|
||||
property.defaultValueWithParam = toDefaultValueWithParam(name, p);
|
||||
property.jsonSchema = Json.pretty(p);
|
||||
|
Loading…
x
Reference in New Issue
Block a user