[Repo Assist] test: add DefinitionPath.Parse unit tests and PreferNullable coverage#370
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>
There was a problem hiding this comment.
Pull request overview
Adds new unit tests to improve coverage of OpenAPI v3 schema compilation helpers, specifically around $ref definition-path parsing and PreferNullable=true behavior in type mapping.
Changes:
- Add a new v3 test module covering
DefinitionPath.Parse(prefix handling, namespace splitting, and failure cases). - Extend v3 type-mapping tests to cover
PreferNullable=truefor optional value types (Nullable<T>vsOption<T>). - Add a new
compilePropertyTypeWithhelper to compile schemas under non-defaultDefinitionCompileroptions.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| tests/SwaggerProvider.Tests/v3/Schema.TypeMappingTests.fs | Adds PreferNullable=true unit tests for optional value-type property mapping. |
| tests/SwaggerProvider.Tests/v3/Schema.TestHelpers.fs | Introduces compilePropertyTypeWith to compile schemas with configurable provideNullable. |
| tests/SwaggerProvider.Tests/v3/Schema.DefinitionPathTests.fs | New test suite validating DefinitionPath.Parse behavior and error cases. |
| tests/SwaggerProvider.Tests/SwaggerProvider.Tests.fsproj | Includes the new Schema.DefinitionPathTests.fs in the test project compile list. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
/repo-assist address inline review comments |
|
✗ Repo Assist encountered failed, see workflow run. |
|
@copilot address inline review comments (don't update pr description) |
…able assertions, and comment wording Agent-Logs-Url: https://github.com/fsprojects/SwaggerProvider/sessions/39b1a730-3011-42c1-84c3-eb4a4ce202c3 Co-authored-by: sergey-tihon <1197905+sergey-tihon@users.noreply.github.com>
Addressed all three inline review comments in commit
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ia private core helper Agent-Logs-Url: https://github.com/fsprojects/SwaggerProvider/sessions/2592f70e-57ed-4977-9913-daaaccdd91e4 Co-authored-by: sergey-tihon <1197905+sergey-tihon@users.noreply.github.com>
🤖 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)