Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Generated schemas keep OpenAPI `nullable`, so required-but-nullable fields reject null

未关闭
#1,024 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
72/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
冷清
技术栈
github, javascript, openapi

调研方向

从 script/build-schema 开始,检查它如何选择 GitHub OpenAPI 快照,然后将该来源与 descriptions-next/ 进行比较。重新生成 schema/dereferenced/settings.json,并验证 issue 中所示的 nullable 配置;当 required_status_checks 和 restrictions 在 draft 2020-12 下接受 null,且不依赖 nullable 时,即表示完成。

由索引模型根据 Issue 内容生成。

描述

bug

The schemas in schema/dereferenced/ declare "$schema": "https://json-schema.org/draft/2020-12/schema", but script/build-schema copies subschemas out of GitHub's OpenAPI 3.0 description, which marks null-able fields with nullable: true. That keyword doesn't exist in JSON Schema draft 2020-12, so any compliant validator ignores it and the fields reject null.

This bites exactly where the GitHub API forces null into configs. The update-branch-protection endpoint requires required_status_checks, enforce_admins, and restrictions to be present, and documents "Set to null to disable". A minimal config:

branches:
  - name: main
    protection:
      required_status_checks: null
      enforce_admins: true
      restrictions: null

fails validation against the current schema/dereferenced/settings.json:

$.branches[0].protection.required_status_checks: None is not of type 'object'
$.branches[0].protection.restrictions: None is not of type 'object'

There are 13-14 nullable: true occurrences per generated file, all silently dropped this way.

GitHub publishes an OpenAPI 3.1 variant of the same spec (descriptions-next/, same dated snapshots). 3.1 is natively JSON Schema 2020-12: those fields are type: [X, "null"] unions and nullable doesn't exist. Pointing the build at it makes the generated schemas actually conform to the dialect they declare, with no post-processing.

主要语言
JavaScript
星标
922
派生
227
平均合并
7 天 20 小时
30 天内合并 PR
1

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

github-community-projects/safe-settings 的其他 Issue

查看 github-community-projects/safe-settings 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。