Remove x-nullable extension support (#930)

This commit is contained in:
Jérémie Bresson 2018-08-30 07:54:34 +02:00 committed by GitHub
parent 62abd51a02
commit f987306a15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 17 deletions

View File

@ -77,8 +77,8 @@ import java.util.Set;
import java.util.TreeSet;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Stream;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class DefaultCodegen implements CodegenConfig {
private static final Logger LOGGER = LoggerFactory.getLogger(DefaultCodegen.class);
@ -1794,11 +1794,7 @@ public class DefaultCodegen implements CodegenConfig {
if (p.getWriteOnly() != null) {
property.isWriteOnly = p.getWriteOnly();
}
// use x-nullable
if (p.getExtensions() != null && p.getExtensions().get("x-nullable") != null) {
property.isNullable = Boolean.valueOf(p.getExtensions().get("x-nullable").toString());
} else if (p.getNullable() != null) { // use nullable defined in OAS3
if (p.getNullable() != null) {
property.isNullable = p.getNullable();
}
@ -2745,10 +2741,7 @@ public class DefaultCodegen implements CodegenConfig {
parameterSchema = new StringSchema().description("//TODO automatically added by openapi-generator due to missing type definition.");
}
// x-nullable extension in OAS2
if (parameter.getExtensions() != null && parameter.getExtensions().get("x-nullable") != null) {
codegenParameter.isNullable = Boolean.valueOf(parameter.getExtensions().get("x-nullable").toString());
} else if (Boolean.TRUE.equals(parameterSchema.getNullable())) { // use nullable defined in the spec
if (Boolean.TRUE.equals(parameterSchema.getNullable())) { // use nullable defined in the spec
codegenParameter.isNullable = true;
}
@ -4766,10 +4759,6 @@ public class DefaultCodegen implements CodegenConfig {
}
private void setParameterNullable(CodegenParameter parameter, CodegenProperty property) {
if (property.getVendorExtensions() != null && property.getVendorExtensions().get("x-nullable") != null) {
parameter.isNullable = Boolean.valueOf(property.getVendorExtensions().get("x-nullable").toString());
} else {
parameter.isNullable = property.isNullable;
}
parameter.isNullable = property.isNullable;
}
}

View File

@ -268,8 +268,7 @@ public class RubyClientCodegenTest {
CodegenParameter name = op.formParams.get(0);
Assert.assertFalse(name.isNullable);
CodegenParameter status = op.formParams.get(1);
// TODO comment out the following as there seems to be an issue with swagger parser not brining over the
// vendor extensions of the form parameter when creating the schema
// TODO comment out the following until https://github.com/swagger-api/swagger-parser/issues/820 is solved
//Assert.assertTrue(status.isNullable);
}
}