提供 YML 时使用 JSON 解析器的 swagger-codegen

swagger-codegen using JSON parser when YML is provided

正在尝试使用 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 生成客户端和实体的正确说明是什么?

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

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