Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

[Schema Inaccuracy] Duplicate title properties and inline schemas

Đang mở
#4,622 3 bình luận 0 reaction 1 người được giao Xem trên GitHub

@bearcherian đang làm issue này rồi.

Từ ngày 27/3/2025.

Đánh giá

Issue này chưa được đánh giá.

Mô tả

documentation inaccuracy

Schema Inaccuracy

The schema contains many inline schemas (that should be using re-usable components) and many inline schemas and components that have duplicate title properties

This causes problems when using tools like json-schema-to-typescript where you end up with many TypeScript interfaces named User_3, Repository_1, etc.

Expected

No inline schemas for re-used definitions, or schemas that have the same title

Reproduction Steps

This script logs all duplicate title properties found

import schema from "./packages/openapi-webhooks/generated/api.github.com.json" with { type: "json" };
import { writeFileSync } from "node:fs";

function findDuplicateTitles(schema) {
  const seen = new Set();
  const duplicates = [];

  function traverse(obj, path = []) {
    if (typeof obj !== "object" || obj === null) return;

    if (obj.title) {
      const titlePath = path.join("/");
      if (seen.has(obj.title)) {
        duplicates.push({ title: obj.title, path: titlePath });
      } else {
        seen.add(obj.title);
      }
    }

    // Traverse properties like oneOf, anyOf, etc.
    for (const [key, value] of Object.entries(obj)) {
      if (Array.isArray(value)) {
        value.forEach((item, index) => traverse(item, [...path, key, index]));
      } else if (typeof value === "object") {
        traverse(value, [...path, key]);
      }
    }
  }

  traverse(schema);
  return duplicates;
}

async function main() {
  const duplicates = findDuplicateTitles(schema)
    .sort((a, b) => {
      if (a.title < b.title) return -1;
      if (a.title > b.title) return 1;
      return 0;
    })
    .map(({ title, path }) => `- [ ] Title: ${title}, Path: \`#/${path}\``);

  writeFileSync("duplicates.txt", duplicates.join("\n"));
}

main().catch(console.error);

Here is the list of duplicates I have found, which is too long to post directly into the issue body:
duplicates.txt

Ngôn ngữ chính
Không có dữ liệu ngôn ngữ
Star
1.6k
Fork
342
Merge trung bình
2 giờ 23 phút
Pull request đã merge (30 ngày)
57

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của github/rest-api-description

Tất cả issue của github/rest-api-description

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.