forked from loafle/openapi-generator-original
[Protobuf-Schema] Added nullable (#11073)
This commit is contained in:
parent
fbb61658df
commit
d5979d3180
@ -254,6 +254,9 @@ public class ProtobufSchemaCodegen extends DefaultCodegen implements CodegenConf
|
|||||||
if (Boolean.TRUE.equals(var.isArray)) {
|
if (Boolean.TRUE.equals(var.isArray)) {
|
||||||
var.vendorExtensions.put("x-protobuf-type", "repeated");
|
var.vendorExtensions.put("x-protobuf-type", "repeated");
|
||||||
}
|
}
|
||||||
|
else if (Boolean.TRUE.equals(var.isNullable && var.isPrimitiveType)) {
|
||||||
|
var.vendorExtensions.put("x-protobuf-type", "optional");
|
||||||
|
}
|
||||||
|
|
||||||
// add x-protobuf-data-type
|
// add x-protobuf-data-type
|
||||||
// ref: https://developers.google.com/protocol-buffers/docs/proto3
|
// ref: https://developers.google.com/protocol-buffers/docs/proto3
|
||||||
@ -500,9 +503,14 @@ public class ProtobufSchemaCodegen extends DefaultCodegen implements CodegenConf
|
|||||||
int index = 1;
|
int index = 1;
|
||||||
for (CodegenParameter p : op.allParams) {
|
for (CodegenParameter p : op.allParams) {
|
||||||
// add x-protobuf-type: repeated if it's an array
|
// add x-protobuf-type: repeated if it's an array
|
||||||
|
|
||||||
if (Boolean.TRUE.equals(p.isArray)) {
|
if (Boolean.TRUE.equals(p.isArray)) {
|
||||||
p.vendorExtensions.put("x-protobuf-type", "repeated");
|
p.vendorExtensions.put("x-protobuf-type", "repeated");
|
||||||
} else if (Boolean.TRUE.equals(p.isMap)) {
|
}
|
||||||
|
else if (Boolean.TRUE.equals(p.isNullable && p.isPrimitiveType)) {
|
||||||
|
p.vendorExtensions.put("x-protobuf-type", "optional");
|
||||||
|
}
|
||||||
|
else if (Boolean.TRUE.equals(p.isMap)) {
|
||||||
LOGGER.warn("Map parameter (name: {}, operation ID: {}) not yet supported", p.paramName, op.operationId);
|
LOGGER.warn("Map parameter (name: {}, operation ID: {}) not yet supported", p.paramName, op.operationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user