Repository navigation
docs(downgrader): word the NSwag nullable component note as NSwag's own gap - #144
Merged
Merged
Conversation
…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
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- NSwag nullable-component note reworded — The bullet at
packages/downgrader/README.md:286now attributes NSwag's "writes a type it never defines" symptom to NSwag's own gap: a$refto a component that is aoneOfwith an object, enum, or$refbranch, 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$refwith its own id becomes such aoneOfwith the"null"branch), adds thatopenapi2tsclientwrites the same undefined type, and notes that from 3.1'sanyOfthe 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.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

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$refto any component that is aoneOfwith an object, enum, or$refbranch, and it does this in 3.1 too. For example,C = oneOf [$ref X, $ref Y], with or without adiscriminator, gives an undefinedVfrom both versions. A scalaroneOfis fine. So the gap is NSwag's own. The downgrader's only part is that a nullable enum or$refwith its own id, ananyOfin 3.1, becomes such aoneOfwith 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 checkpasses.Generated by Claude Code