【问题标题】:swagger-codegen using JSON parser when YML is provided提供 YML 时使用 JSON 解析器的 swagger-codegen
【发布时间】:2020-01-14 15:06:22
【问题描述】:

尝试使用 swagger-codegen 为 PHP 生成 API 类。

[根据文档][1],它应该自动知道 JSON 和 YML 之间的区别。

看起来不是这样的:

docker run --rm -v ${PWD}:/local swaggerapi/swagger-codegen-cli generate \
    -i https://.../interface.yml \
    -l php \
    -o /local/out/php

例外:

[main] ERROR io.swagger.parser.SwaggerCompatConverter - failed to read resource listing
com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'openapi': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')
 at [Source: (String)"openapi: 3.0.1
info:
  title: Orders
  description: This API documentation describes all endpoints for orders
...

从 YML 生成客户端和实体的正确说明是什么?

【问题讨论】:

    标签: json yaml swagger-codegen


    【解决方案1】:

    您正在使用不支持 OpenAPI 3.0 的 Swagger Codegen 2.x

    改用 codegen 版本 3.x
    https://hub.docker.com/r/swaggerapi/swagger-codegen-cli-v3/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-07-30
      • 2015-10-13
      • 2020-05-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多