Google API Gateway OpenApi Swaagger 2.0 to CloudRun Parameter configured for Path turns out in query instead of path

Viewed 14

I'm testing an API Gateway setup on Google Cloud to access specific endpoints on a service deployed on Cloud Run. I'm following the steps shown here. We need to authenticate using an API Key, so the API Key specific configuration that went into the API Gateway config was picked from this documentation.

The API Gateway config is as shown below:

# api_gateway_config.yaml
swagger: '2.0'
info:
  title: myappapi
  description: API with Cloudrun Backend
  version: 1.0.0
schemes:
  - https
produces:
  - application/json
paths:
  /:
    get:
      summary: Greet a User from service
      operationId: hello
      x-google-backend:
        address: https://myappapi-asldfjoiewjfv-uc.a.run.app/
      security:
      - api_key: []
      responses:
        '200':
          description: A successful response
          schema:
            type: string
  /reports/results/{id}:
    get:
      summary: Get Report Results for specified report id
      operationId: GetReportResults
      x-google-backend:
        address: https://myappapi-asldfjoiewjfv-uc.a.run.app/v1/reports/results/{id}
      parameters:
        - in: path
          name: id
          required: true
          type: integer
      security:
      - api_key: []
      responses:
        '200':
          description: A successful response
          schema:
            type: string

securityDefinitions:
  # This section configures basic authentication with an API Key.
  api_key:
    type: "apiKey"
    name: "key"
    in: "query"

For a sample call to the /reports/results endpoint as http://myappapi/reports/results/1, the expectation is for calls to get converted to https://myappapi-asldfjoiewjfv-uc.a.run.app/v1/reports/results/1?key=MyAPIKeyHere. But instead they turn out as https://myappapi-asldfjoiewjfv-uc.a.run.app/v1/reports/results?key=MyAPIKeyHere&id=1

Is there a way to get the API calls go as https://myappapi-asldfjoiewjfv-uc.a.run.app/v1/reports/results/1?key=MyAPIKeyHere ?

Thanks in Advance!

0 Answers
Related