Skip to content

protoc-gen-swagger: json_names_for_fields=true does not respect json_name for *nested* path parameters #1187

Closed
@brocaar

Description

@brocaar

This is probably related to #1084 which was fixed by #1084.

Version: v1.14.3

service DeviceService {
    rpc Get(GetDeviceRequest) returns (GetDeviceResponse) {
        option (google.api.http) = {
            get: "/api/devices/{dev_eui}"
        };
    }

message GetDeviceRequest {
    // Device EUI (HEX encoded).
    string dev_eui = 1 [json_name = "devEUI"];
}

Does result in the expected endpoint: /api/devices/{devEUI}.

However, if the Protobuf definition is modified to:

service DeviceService {
    rpc Get(GetDeviceRequest) returns (GetDeviceResponse) {
        option (google.api.http) = {
            get: "/api/devices/{device.dev_eui}"
        };
    }

message GetDeviceRequest {v1.14.3
    Device device = 1;
}

message Device {
    // Device EUI (HEX encoded).
    string dev_eui = 1 [json_name = "devEUI"];
}

The expected endpoint would be: /api/devices/{device.devEUI}.
However, the actual generated endpoint is: /api/devices/{device.devEui}.

Could it be that in case of a nested argument, the GetJsonName() is not triggered?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions