Gracefully handle property incompatibilities during an update
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 35/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 冷清
- 技术栈
- openapi
调研方向
从 issue 中的递归合并规则以及 upstream.yaml/fix.yaml 示例开始。检查 Overlay Specification 当前如何定义不兼容的 target 值和 update/copy 值,然后确定替换行为所需的规范性措辞。完成的标准是:规范能够明确解决 scalar-to-array 示例,而不要求单独的 remove 操作。
由索引模型根据 Issue 内容生成。
描述
Scenario: You have a broken upstream OpenAPI spec you don't control, and you're using an overlay to fix it.
Here's a minimal example. The upstream spec has a type: string property in a response body:
# upstream.yaml
openapi: 3.1.0
info:
title: Pet Store
version: 1.0.0
paths:
/pets:
get:
operationId: listPets
responses:
'200':
description: A list of pets
content:
application/json:
schema:
type: object
properties:
tag:
type: string
example: "indoor"
However when we try the API, we realize that tag is actually an array instead of a scalar string and the upstream OAS was incorrect. Natural overlay to fix it:
# fix.yaml
overlay: 1.0.0
info:
title: Fix broken tag
actions:
- target: $.paths['/pets'].get.responses['200'].content['application/json'].schema.properties.tag
update:
type: array
items:
type: string
example:
- "indoor"
When the overlay engine recursively merges the update object into the tag property, it eventually reaches the example key. The target value is a YAML scalar ("indoor") and the update value is a YAML sequence (["indoor"]). Per the spec:
Other property value combinations are incompatible and result in an error.
So this is an error condition — you can't fix a wrongly-typed field with a simple update: it's got to be removed and re-added.
The only way to fix the above scenario becomes:
overlay: 1.0.0
info:
title: Fix broken tag
actions:
- target: $.paths['/pets'].get.responses['200'].content['application/json'].schema.properties.tag.example
remove: true
- target: $.paths['/pets'].get.responses['200'].content['application/json'].schema.properties.tag
update:
type: array
items:
type: string
example:
- "indoor"
Which works but is both overly verbose and brittle because all incompatible fields have to be dropped from the target to be able to overlay without an error.
In my mind it might make more sense if the specification was a little more graceful here, specifically with regards to recursive merging behaviour (I.e. I think an error when the target and update/copy are incompatible is the right thing). Currently:
If a property exists in both update or copy and target object:
- A primitive value of the update or copy property replaces a primitive value of the target property.
- An array value of the update or copy property is concatenated with an array value of the target property.
- An object value of the update or copy property is recursively merged with an object value of the target property.
- Other property value combinations are incompatible and result in an error.
Would become:
If a property exists in both update or copy and target object:
- An array value of the update or copy property is concatenated with an array value of the target property.
- An object value of the update or copy property is recursively merged with an object value of the target property.
- Otherwise the property value of the update or copy property replaces the value of the target property.
- 主要语言
- JavaScript
- 星标
- 122
- 派生
- 38
- 平均合并
- 1 天 17 小时
- 30 天内合并 PR
- 9
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
OAI/Overlay-Specification 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 84/100
OAI/Overlay-Specification#415 ·
维护者通常 1 天内回复
-
ci: update the agenda template to lead us down the path of checking the spec repo可能已有人在做 @baywet 于 10 天前认领。 未关闭
OAI/Overlay-Specification#411 · 已指派 1 人 ·
维护者通常 1 天内回复
-
ci: add automation to sync from main -> dev -> vX.Y-dev branches可能已有人在做 @baywet 于 10 天前认领。 未关闭
OAI/Overlay-Specification#410 · 1 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
Revisit: should Overlays declare their target document format? (follow-up to #268)可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 5/5 一周以上 新手友好度 35/100
OAI/Overlay-Specification#367 · 3 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 35/100
OAI/Overlay-Specification#358 · 2 条评论 ·
维护者通常 1 天内回复
查看 OAI/Overlay-Specification 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 65/100
tshemsedinov/reslop#158 ·
维护者通常 1 天内回复
-
level/task type/bug
难度 2/5 1-3 小时 新手友好度 72/100
wazuh/wazuh-documentation#10398 ·
维护者通常 1 天内回复
-
app_installations reports an error on every repo or suborg change when the plugin is not configured未关闭
难度 2/5 1-3 小时 新手友好度 64/100
github-community-projects/safe-settings#1111 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复