google-discovery-to-swagger icon indicating copy to clipboard operation
google-discovery-to-swagger copied to clipboard

Question: Generated C# client does not work because of gRPC encoded parameter

Open sommmen opened this issue 2 years ago • 1 comments

Hiya,

I'm trying to list reviews via the google my business api.

I'm following this doc: https://developers.google.com/my-business/content/review-data#list_all_reviews

Which is this api: https://developers.google.com/my-business/reference/rest/v4/accounts.locations.reviews/list

This describes the following endpoint: GET https://mybusiness.googleapis.com/v4/accounts/{accountId}/locations/{locationId}/reviews `

Which gets translated to the following swagger definition:

  "/v4/{parent}/reviews":
    get:
      description: Returns the paginated list of reviews for the specified location. This operation is only valid if the specified location is verified.
      operationId: mybusiness.accounts.locations.reviews.list
      parameters:
        - description: The name of the location to fetch reviews for.
          in: path
          name: parent
          required: true
          schema:
            type: string

I'm using this document to genera a c# client with NSwag, but this has the issue that the parameter path gets url encoded (meaning the slashes are escaped), creating a malformed url.

My C# client now pushed out a request like so:

https://mybusiness.googleapis.com/v4/accounts%2F123456789123456789123%2Flocations%2F1234567891234567891/reviews?pageSize=50

While it should be:

https://mybusiness.googleapis.com/v4/accounts/123456789123456789123/locations/1234567891234567891/reviews?pageSize=50

Now this is not an issue with this generator, but it does make the swagger doc unusable. Does anyone know a way to specificy that the parameter should not be url encoded so that generated clients can create a proper request?

sommmen avatar May 09 '22 09:05 sommmen

Hmm, even if we could identify that the google format path parameter was multi-segment ({...+}) OpenAPI 3.0 / 3.1 only supports the allowReserved parameter property on in:query parameters.

MikeRalphson avatar Aug 26 '22 13:08 MikeRalphson