Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
5382810
fix(downgrader): a $ref cut at recursion in a copy reused later tells…
claude Nov 1, 2026
479b9ac
Merge remote-tracking branch 'origin/main' into claude/project-thread…
claude Nov 1, 2026
34ef504
fix(downgrader): keep a oneOf of object literals, and an additionalPr…
claude Nov 1, 2026
c750171
Merge remote-tracking branch 'origin/main' into claude/project-thread…
claude Nov 1, 2026
39f4ca4
fix(downgrader): follow a propertyNames $ref on only through $refs be…
claude Nov 1, 2026
f695074
Merge remote-tracking branch 'origin/main' into claude/project-thread…
claude Nov 1, 2026
c09da8c
fix(downgrader): rerun the conversion for a schema that loses a restr…
claude Nov 1, 2026
e9f7f25
fix(downgrader): follow an alias chain through inlined $refs and tagg…
claude Nov 1, 2026
905a75a
Merge remote-tracking branch 'origin/main' into claude/project-thread…
claude Nov 1, 2026
997f21b
perf(downgrader): skip the second pass when no not or oneOf kept its …
claude Nov 1, 2026
cb16050
Merge remote-tracking branch 'origin/main' into claude/project-thread…
claude Nov 1, 2026
7d46cbc
fix(downgrader): count an object that requires a readOnly or writeOnl…
claude Nov 1, 2026
9962db1
perf(downgrader): check one-way required properties without a closure…
claude Nov 1, 2026
9811aeb
refactor(downgrader): count any readOnly or writeOnly schema as loose
claude Nov 1, 2026
b320e25
Merge remote-tracking branch 'origin/main' into claude/project-thread…
claude Nov 1, 2026
6de99ef
refactor(downgrader): count a schema met again mid-cycle as loose, in…
claude Nov 1, 2026
11a7506
Merge remote-tracking branch 'origin/main' into claude/project-thread…
claude Nov 1, 2026
dd53f1c
refactor(downgrader): replace any $ref into items or additionalProper…
claude Nov 1, 2026
811283c
Merge remote-tracking branch 'origin/main' into claude/project-thread…
claude Nov 1, 2026
3c7ab4b
refactor(downgrader): follow a propertyNames $ref through one $ref only
claude Nov 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 7 additions & 12 deletions packages/downgrader/src/v3.1-to-v3.0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -513,18 +513,13 @@ function isUnevaluatedAdditional(schema: Record<string, unknown>): boolean {
// property of its own, which 3.0 can express. A reusable enum is a `$ref` to it.
function enumNames(schema: Record<string, unknown>, ctx: Context): string[] | undefined {
// Followed alone or beside annotations, such as the `description` Zod writes
// for a described use, and along a chain of them, since other keywords
// beside a `$ref` narrow the names further.
let names = schema.propertyNames
const visited = new Set<unknown>()
for (
let ref = getRef(names);
ref !== undefined && isAnnotatedRef(names as Record<string, unknown>) && !visited.has(names);
ref = getRef(names)
) {
visited.add(names)
names = resolvePointer(ref, ctx)
}
// for a described use, since other keywords beside it narrow the names
// further. A target that is a `$ref` again holds no names here.
const ref = getRef(schema.propertyNames)
const names =
ref !== undefined && isAnnotatedRef(schema.propertyNames as Record<string, unknown>)
? resolvePointer(ref, ctx)
: schema.propertyNames
if (!isRecord(names)) {
return undefined
}
Expand Down
9 changes: 3 additions & 6 deletions packages/downgrader/tests/v3.1-to-v3.0.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2430,7 +2430,7 @@ describe('downgradeSchemaV31ToV30', () => {
})
})

it('follows a propertyNames $ref on through a $ref beside only annotations, and no further', () => {
it('follows a propertyNames $ref through one $ref only', () => {
const r = '#/components/schemas/'
const schemas = convert({
components: {
Expand All @@ -2448,11 +2448,8 @@ describe('downgradeSchemaV31ToV30', () => {
},
},
}).components?.schemas
expect(schemas?.ByAlias).toEqual({
type: 'object',
properties: { en: { type: 'string' }, fr: { type: 'string' } },
additionalProperties: false,
})
// A target that is a $ref again holds no names, so the record loses them.
expect(schemas?.ByAlias).toEqual({ type: 'object', additionalProperties: { type: 'string' } })
expect(schemas?.NotEnglish).toEqual({})
})

Expand Down
Loading