无法从Openapiapp.yaml中解析Open API或Google服务配置规范 [英] Unable to parse Open API, or Google Service Configuration specification from openapiapp.yaml

查看:23
本文介绍了无法从Openapiapp.yaml中解析Open API或Google服务配置规范的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试严格遵循[本教程](https://cloud.google.com/community/tutorials/exposing-aspnet-webapi-using-dotnetcore-with-cloud-endpoints),但在尝试gcloud endpoints services deploy openapi.yaml时遇到以下错误:

错误:(gcloud.endpoint ts.services.ploy)无法从[SampleSolution]

解析Open API或Google服务配置规范

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

推荐答案

Swashuckle.AspNetCore现在支持OpenApi 3,但它也具有与Swagger v2的向后兼容性,方法是在Configure方法(Startup类)中使用:

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

这篇关于无法从Openapiapp.yaml中解析Open API或Google服务配置规范的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆