aws-api-gateway - 指向同一对象的 OpenAPI ref 不起作用
问题描述
definitions:
TestObject2:
type: object
properties:
key1:
type: string
TestObject:
type: object
properties:
name:
type: string
city:
type: string
coordinates:
$ref: '#/definitions/TestObject2'
directions:
$ref: '#/definitions/TestObject2'
如果我删除其中一个对 TestObject2 的引用,那么它就可以工作。但是,如果我将相同的引用添加到不同的属性,我看不到在 api 网关“模型”上创建的模型在日志中我看到:
paths:
'/my/custom/1.0/path/{param1}/{param2}/{param3}':
put:
parameters:
- in: path
name: param1
type: string
required: true
- in: path
name: param2
type: string
required: true
- in: path
name: param3
type: string
required: true
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
name:
type: string
city:
type: string
coordinates:
$ref: >-
#/paths/~1my~1custom~11.0~1path~1%7Bparam1%7D~1%7Bparam2%7D~1%7Bparam3%7D/put/requestBody/content/application~1json/schema/properties/directions
directions:
type: object
properties:
key1:
type: string
required:
- name
注意生成的坐标参考链接看起来很奇怪。它似乎没有使用 TestObject2,而是依赖于 TestObject.directions 中的 ref 链接。对于方向,TestObject2 被正确替换。
解决方案
事实证明,它与我定义架构的方式没有任何关系。我使用 swagger-cli 捆绑到一个文件中,默认情况下,swagger-cli 创建这些内部引用链接。我不得不添加一个尊重标志。这有效:
swagger-cli bundle apigateway/endpoints/main.api.yml --dereference --type yaml > apigateway/swagger.yml
推荐阅读
- maple - Maple - 未评估下标变量 T_0
- flutter-web - 使用 Flutter Web 1.9 打开外部链接
- laravel - laravel-5.8:此路由不支持 POST 方法。支持的方法:GET、HEAD
- haskell - Haskell - 函数评估
- python - Python:实际上在我的主文件旁边导入一个模块不起作用
- javascript - 在 NodeJS 中不使用换行符进行日志记录
- python - 如何使用 Scapy 实现 ARP ping?
- firebase - Firestore:有没有办法获取所有集合文档及其子集合文档
- php - WooCommerce 在注册后重定向到我的帐户而不是结帐
- puppet - 使用节点默认中的类运行 Puppet Agent 时出错