Search code examples
google-cloud-platformgatewayapi-gateway

I can't create a Gateway API Google Error: "Cannot convert to service config. 'location: "unknown location"


I'm trying to create an API gateway on Google Cloud Platform, after filling in all the fields and clicking on create gateway the following error message appears:

Cannot convert to service config. 'location: "unknown location" kind: ERROR message: "Unable to parse the content. while parsing a block mapping\n in 'reader', line 1, column 1:\n swagger: '2.0'\n ^\nexpected , but found BlockMappingStart\n in 'reader', line 2, column 5:\n info:\n ^\n\n at [Source: (StringReader); line: 1, column: 15]" '

I believe this is related to the configuration of the Yaml file that is required in the API Spec field as shown in the image below:

enter image description here

My yaml file is configured as follows:

swagger: '2.0'
    info:
      title: API Gateway for Cycle
      description: "Send a deal object for the data to be treated"
      version: "1.0.0"
    host: teste.apigateway.project-teste-homolog.cloud.goog
    schemes:
      - "https"
    produces:
      - "application/json"
    paths:
      "/data-verification-homologation":
        post:
          x-google-backend: 
            address: URL.example
          description: "Jailson esteve aqui =)"
          operationId: "dataVerification"
          parameters:
            -
              name: iataCode
              in: query
              required: true
              type: string
          responses:
            200:
              description: "Sucess"
              schema:
                type: string
            400:
              description: "Error"

I've already checked the following google documentation https://cloud.google.com/endpoints/docs/grpc/troubleshoot-config-deployment, but I couldn't solve the error.


Solution

  • Your indentation is incorrect.

    swagger: "2.0"
    info:
      title: "API Gateway for Cycle"
      description: ... 
    

    YAML requires very precise indentation.

    See YAML Swagger (OpenAPI) example here: https://swagger.io/docs/specification/basic-structure/