0

Trying to create an API for the first time in GCP and getting the following error

ERROR: (gcloud.api-gateway.api-configs.create) API Config's backend has no rules. If using gRPC, be sure to specify the 'rules[]' under the 'Backend' field. See https://cloud.google.com/endpoints/docs/grpc-service-config/reference/rpc/google.api#backendrule for more details.

However, if I try to add a backend to the yaml file, I am getting the following error.

ERROR: (gcloud.api-gateway.api-configs.create) INVALID_ARGUMENT: Cannot convert to service config. 'location: "unknown location" kind: ERROR message: "Invalid OpenAPI file. Please fix the schema errors:\nerror: object instance has properties which are not allowed by the schema: ["backend"]\n level: "error"\n schema: {"loadingURI":"http://swagger.io/v2/schema.json#","pointer":""}\n instance: {"pointer":""}\n domain: "validation"\n keyword: "additionalProperties"\n unwanted: ["backend"]"

This is the bare bones yaml file I am using.

swagger: '2.0'
info:
  title: sayHello
  version: '1.0'
  description: sayHello
schemes:
  - https
produces:
  - application/json
consumes:
  - application/json
backend:
  rules:
    - selector: "*"
      address: https://abc.cloudfunctions.net/sayHello
paths:
  '/getPoints/{clientId}':
    parameters:
      - type: string
        name: clientId
        in: path
        required: true
definitions: {}
responses:
  '200':
    description: Success
    schema:
      type: string
    examples: {}
    headers: {}

What am I missing? Somehow, not able to find much resources around adding backend rules to the service config file. Not even able to get the spec to validate against.

Any help would be appreciated.

Helen
  • 87,344
  • 17
  • 243
  • 314
Ganesh
  • 1
  • 1

1 Answers1

0

Wherever the conversion was done from JSON to YAML or created YAML file is incorrect, please fix it first, then the error will be resolved.