forked from loafle/openapi-generator-original
Remove x-nullable extension support (#930)
This commit is contained in:
parent
62abd51a02
commit
f987306a15
@ -77,8 +77,8 @@ import java.util.Set;
|
|||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.stream.Stream;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class DefaultCodegen implements CodegenConfig {
|
public class DefaultCodegen implements CodegenConfig {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(DefaultCodegen.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(DefaultCodegen.class);
|
||||||
@ -1794,11 +1794,7 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
if (p.getWriteOnly() != null) {
|
if (p.getWriteOnly() != null) {
|
||||||
property.isWriteOnly = p.getWriteOnly();
|
property.isWriteOnly = p.getWriteOnly();
|
||||||
}
|
}
|
||||||
|
if (p.getNullable() != null) {
|
||||||
// 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
|
|
||||||
property.isNullable = p.getNullable();
|
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.");
|
parameterSchema = new StringSchema().description("//TODO automatically added by openapi-generator due to missing type definition.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// x-nullable extension in OAS2
|
if (Boolean.TRUE.equals(parameterSchema.getNullable())) { // use nullable defined in the spec
|
||||||
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
|
|
||||||
codegenParameter.isNullable = true;
|
codegenParameter.isNullable = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4766,10 +4759,6 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setParameterNullable(CodegenParameter parameter, CodegenProperty property) {
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -268,8 +268,7 @@ public class RubyClientCodegenTest {
|
|||||||
CodegenParameter name = op.formParams.get(0);
|
CodegenParameter name = op.formParams.get(0);
|
||||||
Assert.assertFalse(name.isNullable);
|
Assert.assertFalse(name.isNullable);
|
||||||
CodegenParameter status = op.formParams.get(1);
|
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
|
// TODO comment out the following until https://github.com/swagger-api/swagger-parser/issues/820 is solved
|
||||||
// vendor extensions of the form parameter when creating the schema
|
|
||||||
//Assert.assertTrue(status.isNullable);
|
//Assert.assertTrue(status.isNullable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user