Skip to content

Overriding path parameter names not helpful with additional_bindings #2642

Open
@yinzara

Description

🚀 Feature

This is a follow-up to PR #2562

After attempting to implement this change in our codebase, unfortunately this doesn't help my team very much.

We use the additional_mappings attribute of the google.api.http extension to provide alternative path parameter formats for a required parameter of the entity which means depending on the additional_mappings the name of the parameter should be different.

In the below example we have a Foo resource that has a parent property of which a bing/* or bash/* resource name is allowed for the parent.

// Creates a new Foo given a parent
    rpc CreateFoo(CreateFooRequest) returns (Foo) {
        option (google.api.http)              = {
          post: "/v1/{parent=bing/*}/Foo"
          body: "foo"
          additional_bindings: {
              post: "/v1/{parent=bash/*}/Foo"
              body: "foo"
          }
        };
    }

This generates two different OpenAPI path mappings, one for POST /v1/{parent}/Foo and one for POST /v1/{parent_1}/Foo. Unfortunately one of them has the path parameter regex restriction for "bash/" and the other "bing/" and there is nothing visible in the Swagger UI of a difference between them (you just have very confused users why they can use one and not the other).

There are two acceptable outputs IMHO:

Either two endpoints POST /v1/{bingParent}/Foo and POST /v1/{bashParent}/Foo. This is unfortunately impossible with the current design for the path name replacements as you annotate the field on the Message which is the same between both.

OR

One endpoint POST /v1/{parent}/Foo with the parent parameter being some kind of regular expression combination that allows either bing/* or bash/*. This would require some really smart processing to determine that everything about the URLs is identical except the restriction on the path parameter and combine the two into a single OpenAPI endpoint. This seems like the "more correct" solution and would greatly simplify our output. This would be a change to my prior PR that adds "_1" suffixes on the path parameters to instead merge together two identical endpoints and make the path parameter regex support both standards.

Thoughts?

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions