forked from loafle/openapi-generator-original
* Fix issue 5460 * Handling only first and last double quote to support example with double quote in the middle * Fix proposed by @ePaul * Add comments to explain de fixStringModel function. Add an enum model called PetStatus that test this scenario. Update sample only for JavaPlayFramework generator
This commit is contained in:
committed by
wing328
parent
64658f0bea
commit
79e10c427a
@@ -161,7 +161,7 @@ public class InlineModelResolver {
|
||||
|
||||
Map<String, Property> properties = m.getProperties();
|
||||
flattenProperties(properties, modelName);
|
||||
|
||||
fixStringModel(m);
|
||||
} else if (model instanceof ArrayModel) {
|
||||
ArrayModel m = (ArrayModel) model;
|
||||
Property inner = m.getItems();
|
||||
@@ -191,6 +191,21 @@ public class InlineModelResolver {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function fix models that are string (mostly enum). Before this fix, the example
|
||||
* would look something like that in the doc: "\"example from def\""
|
||||
* @param m Model implementation
|
||||
*/
|
||||
private void fixStringModel(ModelImpl m) {
|
||||
if (m.getType() != null && m.getType().equals("string") && m.getExample() != null) {
|
||||
String example = m.getExample().toString();
|
||||
if (example.substring(0, 1).equals("\"") &&
|
||||
example.substring(example.length() - 1).equals("\"")) {
|
||||
m.setExample(example.substring(1, example.length() - 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String resolveModelName(String title, String key) {
|
||||
if (title == null) {
|
||||
return uniqueName(key);
|
||||
|
||||
Reference in New Issue
Block a user