Revert pull request #45 (#82)

Reverts:
Consider minLength, maxLength and pattern in referenced schema (#45)
This reverts commit 6b8079808b0d1d730324caf26489030a0cd960bd.
This commit is contained in:
Jérémie Bresson 2018-05-17 09:05:00 +02:00 committed by GitHub
parent 752b36e660
commit 85090f5068
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 17 deletions

View File

@ -1519,7 +1519,7 @@ public class DefaultCodegen implements CodegenConfig {
addProperties(allProperties, allRequired, child, allDefinitions); addProperties(allProperties, allRequired, child, allDefinitions);
} }
} }
addVars(m, properties, required, allProperties, allRequired, allDefinitions); addVars(m, properties, required, allProperties, allRequired);
// TODO // TODO
//} else if (schema instanceof RefModel) { //} else if (schema instanceof RefModel) {
} else { } else {
@ -1533,7 +1533,7 @@ public class DefaultCodegen implements CodegenConfig {
if (ModelUtils.isMapSchema(schema)) { if (ModelUtils.isMapSchema(schema)) {
addAdditionPropertiesToCodeGenModel(m, schema); addAdditionPropertiesToCodeGenModel(m, schema);
} }
addVars(m, schema.getProperties(), schema.getRequired(), allDefinitions); addVars(m, schema.getProperties(), schema.getRequired());
} }
if (m.vars != null) { if (m.vars != null) {
@ -3095,12 +3095,12 @@ public class DefaultCodegen implements CodegenConfig {
} }
} }
private void addVars(CodegenModel model, Map<String, Schema> properties, List<String> required, Map<String, Schema> allDefinitions) { private void addVars(CodegenModel model, Map<String, Schema> properties, List<String> required) {
addVars(model, properties, required, null, null, allDefinitions); addVars(model, properties, required, null, null);
} }
private void addVars(CodegenModel m, Map<String, Schema> properties, List<String> required, private void addVars(CodegenModel m, Map<String, Schema> properties, List<String> required,
Map<String, Schema> allProperties, List<String> allRequired, Map<String, Schema> allDefinitions) { Map<String, Schema> allProperties, List<String> allRequired) {
m.hasRequired = false; m.hasRequired = false;
if (properties != null && !properties.isEmpty()) { if (properties != null && !properties.isEmpty()) {
@ -3109,7 +3109,7 @@ public class DefaultCodegen implements CodegenConfig {
Set<String> mandatory = required == null ? Collections.<String>emptySet() Set<String> mandatory = required == null ? Collections.<String>emptySet()
: new TreeSet<String>(required); : new TreeSet<String>(required);
addVars(m, m.vars, properties, mandatory, allDefinitions); addVars(m, m.vars, properties, mandatory);
m.allMandatory = m.mandatory = mandatory; m.allMandatory = m.mandatory = mandatory;
} else { } else {
m.emptyVars = true; m.emptyVars = true;
@ -3120,12 +3120,12 @@ public class DefaultCodegen implements CodegenConfig {
if (allProperties != null) { if (allProperties != null) {
Set<String> allMandatory = allRequired == null ? Collections.<String>emptySet() Set<String> allMandatory = allRequired == null ? Collections.<String>emptySet()
: new TreeSet<String>(allRequired); : new TreeSet<String>(allRequired);
addVars(m, m.allVars, allProperties, allMandatory, allDefinitions); addVars(m, m.allVars, allProperties, allMandatory);
m.allMandatory = allMandatory; m.allMandatory = allMandatory;
} }
} }
private void addVars(CodegenModel m, List<CodegenProperty> vars, Map<String, Schema> properties, Set<String> mandatory, Map<String, Schema> allDefinitions) { private void addVars(CodegenModel m, List<CodegenProperty> vars, Map<String, Schema> properties, Set<String> mandatory) {
// convert set to list so that we can access the next entry in the loop // convert set to list so that we can access the next entry in the loop
List<Map.Entry<String, Schema>> propertyList = new ArrayList<Map.Entry<String, Schema>>(properties.entrySet()); List<Map.Entry<String, Schema>> propertyList = new ArrayList<Map.Entry<String, Schema>>(properties.entrySet());
final int totalCount = propertyList.size(); final int totalCount = propertyList.size();
@ -3133,11 +3133,7 @@ public class DefaultCodegen implements CodegenConfig {
Map.Entry<String, Schema> entry = propertyList.get(i); Map.Entry<String, Schema> entry = propertyList.get(i);
final String key = entry.getKey(); final String key = entry.getKey();
Schema prop = entry.getValue(); final Schema prop = entry.getValue();
if (allDefinitions != null && prop != null && StringUtils.isNotEmpty(prop.get$ref())) {
String refName = ModelUtils.getSimpleRef(prop.get$ref());
prop = allDefinitions.get(refName);
}
if (prop == null) { if (prop == null) {
LOGGER.warn("null property for " + key); LOGGER.warn("null property for " + key);

View File

@ -937,11 +937,11 @@ public class JavaModelTest {
Assert.assertTrue(cp.isNotContainer); Assert.assertTrue(cp.isNotContainer);
Assert.assertFalse(cp.isLong); Assert.assertFalse(cp.isLong);
Assert.assertFalse(cp.isInteger); Assert.assertFalse(cp.isInteger);
Assert.assertTrue(cp.isString); // Assert.assertTrue(cp.isString); //TODO: issue swagger-api/swagger-codegen#8001
Assert.assertEquals(cp.getter, "getSomePropertyWithMinMaxAndPattern"); Assert.assertEquals(cp.getter, "getSomePropertyWithMinMaxAndPattern");
Assert.assertEquals(cp.minLength, Integer.valueOf(3)); // Assert.assertEquals(cp.minLength, Integer.valueOf(3)); //TODO: issue swagger-api/swagger-codegen#8001
Assert.assertEquals(cp.maxLength, Integer.valueOf(10)); // Assert.assertEquals(cp.maxLength, Integer.valueOf(10)); //TODO: issue swagger-api/swagger-codegen#8001
Assert.assertEquals(cp.pattern, "^[A-Z]+$"); // Assert.assertEquals(cp.pattern, "^[A-Z]+$"); //TODO: issue swagger-api/swagger-codegen#8001
} }
@Test(description = "convert an array schema") @Test(description = "convert an array schema")