Skip to content

docs(downgrader): word the NSwag nullable component note as NSwag's own gap - #144

Merged
dinwwwh merged 1 commit into
mainfrom
claude/project-thread-rn4e2z
Oct 27, 2026
Merged

dinwwwh merged 1 commit into
mainfrom
claude/project-thread-rn4e2z

Conversation

@dinwwwh

@dinwwwh dinwwwh commented Oct 27, 2026

Copy link
Copy Markdown
Member

Requested by dinwwwh · project thread

Docs only. A follow-up to #143 that rewords the sentence it added to the NSwag bullet in packages/downgrader/README.md.

#143 framed the undefined type as a 3.0-only problem with the "null" branch. NSwag 14.7.1 actually writes an undefined type for a property, array item, or map value that is a $ref to any component that is a oneOf with an object, enum, or $ref branch, and it does this in 3.1 too. For example, C = oneOf [$ref X, $ref Y], with or without a discriminator, gives an undefined V from both versions. A scalar oneOf is fine. So the gap is NSwag's own. The downgrader's only part is that a nullable enum or $ref with its own id, an anyOf in 3.1, becomes such a oneOf with the "null" branch in 3.0.

The new wording says that. It also notes that NSwag's TypeScript client (openapi2tsclient) writes the same undefined type for the oRPC repro from #143: s!: S2 | undefined, and tsc fails with TS2304. From 3.1, both clients compile, and the C# one writes an empty class.

pnpm run check passes.


Generated by Claude Code

…wn gap

NSwag writes an undefined type for a property, item or map value $ref to
any component that is a oneOf with an object, enum or $ref branch, in 3.1
too. The downgrader's part is only that a nullable enum or $ref component
becomes such a oneOf. Also note NSwag's TypeScript client does the same.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VVaw7NPxfu22nwskVcvgwm
@dinwwwh dinwwwh self-assigned this Oct 27, 2026
@codecov

codecov Bot commented Oct 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@codspeed

codspeed Bot commented Oct 27, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 21 untouched benchmarks


Comparing claude/project-thread-rn4e2z (0c987b5) with main (bcf3ece)

Open in CodSpeed

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • NSwag nullable-component note reworded — The bullet at packages/downgrader/README.md:286 now attributes NSwag's "writes a type it never defines" symptom to NSwag's own gap: a $ref to a component that is a oneOf with an object, enum, or $ref branch, in both 3.0 and 3.1, rather than to the "null" branch the downgrader introduces. It keeps the 3.0-only causal chain (a nullable enum or $ref with its own id becomes such a oneOf with the "null" branch), adds that openapi2tsclient writes the same undefined type, and notes that from 3.1's anyOf the C# client emits an empty class and both compile.

Verified against the pinned NJsonSchema 11.6.1 in NSwag v14.7.1: RemoveNullability/GetOrGenerateTypeName reduce a oneOf to its first non-nullable branch, so any object/enum/$ref oneOf triggers the undefined type and the "null" branch is immaterial; NSwag maps every 3.x to SchemaType.OpenApi3, so 3.1 reproduces identically. External repros with no null branch (NSwag #4744, NJsonSchema #1765) corroborate. uncheck packages/downgrader/README.md passes.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@dinwwwh
dinwwwh merged commit e476ca2 into main Oct 27, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants