APIs-guru / google-discovery-to-swagger

Script for converting Google Discovery format into OpenAPI (swagger) 3.0
MIT License
59 stars 17 forks source link

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

Open sommmen opened 2 years ago

sommmen commented 2 years ago

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?

MikeRalphson commented 2 years ago

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.