0

I try to follow exactly [this tutorial] (https://cloud.google.com/community/tutorials/exposing-aspnet-webapi-using-dotnetcore-with-cloud-endpoints ), but I get the following error at trying gcloud endpoints services deploy openapi.yaml :

ERROR: (gcloud.endpoints.services.deploy) Unable to parse Open API, or Google Service Configuration specification from [SampleSolution]

The body of openapi.yaml :

openapi: 3.0.1
info:
  title: Notes API
  version: v1
host: [google cloud project ID].appspot.com
paths:
  /WeatherForecast:
    get:
      tags:
        - WeatherForecast
      responses:
        '200':
          description: Success
          content:
            text/plain:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/WeatherForecast'
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/WeatherForecast'
            text/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/WeatherForecast'
components:
  schemas:
    WeatherForecast:
      type: object
      properties:
        date:
          type: string
          format: date-time
        temperatureC:
          type: integer
          format: int32
        temperatureF:
          type: integer
          format: int32
          readOnly: true
        summary:
          type: string
          nullable: true
      additionalProperties: false

2 Answers2

0

I only see two things there:

  1. openapi: 3.0.1. This should be swagger: "2.0" accordint ot the Basic structure of an OpenAPI document
  2. host: [google cloud project ID].appspot.com. This should contain the proper project Id.

UPDATE

After checking the composition of your file and the Endpoints openAPI Docs:

OpenAPI feature limitations:

  1. Currently, Cloud Endpoints accepts only version 2 of the OpenAPI Specification.

  2. The Components Section in the Swagger docs mentions that applies to openAPI3. This is not compatible with point 1.

  3. I suggest to remake your file following The basic structure of an OpenAPI document

Joss Baron
  • 1,441
  • 10
  • 13
  • host contains proper project id. I will try your solution and will give updates. – marynella02 Oct 06 '20 at 18:39
  • ERROR: (gcloud.endpoints.services.deploy) 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: [\"components\"]\n level: \"error\"\n schema: {\"loadingURI\":\"http://swagger.io/v2/schema.json#\",\"pointer\":\"\"}\n instance: {\"pointer\":\"\"}\n domain: \"validation\"\n keyword: \"additionalProperties\"\n unwanted: [\"components\"]" ' – marynella02 Oct 06 '20 at 18:43
  • I tried with swagger and I got this. Also I tried to delete components and schemas keys. – marynella02 Oct 06 '20 at 18:45
  • im trying to deploy the same code, i will update here when i have any insight – Joss Baron Oct 06 '20 at 21:21
  • hope you are able to make it work now. I had the same issue then I changed the format of the yaml to meet swagger 2.0 and it worked. – Karthick Trichy Chandrasekaran Jan 19 '21 at 11:07
0

Swashbuckle.AspNetCore now supports OpenApi 3, but it also has backwards compatibility with Swagger v2, by setting it up in Configure method (Startup class) with:

app.UseSwagger(c =>
                {
                    c.SerializeAsV2 = true;
                });