Search code examples
c#postmangrpc.net-6.0

For a GRPC Service in NET 6, Postman is showing bool properties as [] when they have a false value


If I use bool as type in the proto file Postman doesn't even show the property, if I use google.protobuf.BoolValue as type it shows "is_valid": {} when is_valid = false in C#, but it works when is_valid = true, so why it doesn't show anything when it's false?

Proto example:

syntax = "proto3";

option csharp_namespace = "xxx.Organization.V1.Contracts";

import "google/protobuf/wrappers.proto";
import "protos/txp/common/api/query/range.proto";
import "protos/txp/common/filters/string_filter.proto";
import "protos/txp/organization/v1/timezone.proto";

package txp.organization.v1;

    message AddressValidationResponse {
        Address address = 1;
        google.protobuf.BoolValue is_valid = 2;
        google.protobuf.BoolValue is_non_postal = 3;
        repeated google.protobuf.StringValue errors = 4;
        google.protobuf.StringValue success_message = 5;
        google.protobuf.StringValue address_precision = 6;
        Results results = 7;
    }

Auto-generated C# code for is_valid field:

/// <summary>Field number for the "is_valid" field.</summary>
public const int IsValidFieldNumber = 2;
private static readonly pb::FieldCodec<bool?> _single_isValid_codec = pb::FieldCodec.ForStructWrapper<bool>(18);
private bool? isValid_;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public bool? IsValid {
  get { return isValid_; }
  set {
    isValid_ = value;
  }
}

Postman Response:

enter image description here Thanks!


Solution

  • Found the reason for this, in these cases Postman won't show porperties when their value equals to its default value, so no big deal for me. But maybe there's a way to make these properties show anyway in case somebody needs them to show.