[Repo Assist] test: add DefinitionPath.Parse unit tests and PreferNullable coverage#370
Draft
github-actions[bot] wants to merge 2 commits intomasterfrom
Draft
Conversation
Add 21 new unit tests: - v3/Schema.DefinitionPathTests.fs (16 tests): unit-tests for DefinitionPath.Parse covering simple names, one- and multi-level namespaces, PascalCase candidate generation, names with hyphens, and error cases (wrong prefix). DefinitionPath.Parse had no tests at all. - v3/Schema.TypeMappingTests.fs (+5 tests): PreferNullable mode tests verifying that optional value types produce Nullable<T> instead of Option<T> when provideNullable=true, and that required types and reference types are unaffected. - v3/Schema.TestHelpers.fs: add compilePropertyTypeWith helper that exposes the provideNullable parameter to enable the above tests. Test count: 295 → 316 (all pass). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
🤖 This is an automated pull request from Repo Assist, an AI assistant.
Summary
Adds 21 new unit tests covering two previously-untested areas:
1.
DefinitionPath.Parse(new file:v3/Schema.DefinitionPathTests.fs, 16 tests)DefinitionPath.Parseis the function that splits a JSON Reference path (e.g.#/components/schemas/My.Namespace.TypeName) into a namespace list, a raw type name, and a PascalCase candidate name. It has zero existing tests. The new tests cover:nicePascalNameMy.Pet→["My"],"Pet")#/components/schemas/prefix, Swagger 2#/definitions/path2.
PreferNullable=truetype mapping (additions tov3/Schema.TypeMappingTests.fs, 5 tests)When
DefinitionCompileris constructed withprovideNullable=true, optional value-type properties should produceNullable<T>instead ofOption<T>. These tests were entirely missing:optional boolean → Nullable<bool>optional integer → Nullable<int32>optional int64 → Nullable<int64>required integer → int32(unchanged — nullable wrapping is only for optional)optional string → string(reference types are never wrapped, regardless of mode)3.
compilePropertyTypeWithhelper (additions tov3/Schema.TestHelpers.fs)New helper that mirrors
compilePropertyTypebut exposes theprovideNullableflag, enabling thePreferNullabletests above and any future tests that need non-default compiler options.Rationale
DefinitionPath.Parseis called on every$refencountered in a schema, making it load-bearing code. Adding regression tests protects against future changes that inadvertently alter its namespace-splitting logic. ThePreferNullabletests document and protect a user-facing static parameter.Test Status
✅ Build: succeeded (
dotnet build)✅ Tests: 316/316 passed, 0 failed — up from 295 (21 new tests)
(
dotnet tests/SwaggerProvider.Tests/bin/Release/net10.0/SwaggerProvider.Tests.dll)