-
Notifications
You must be signed in to change notification settings - Fork 60
[repo-assist] perf/test: avoid obj[] alloc in getPropertyNamesAndInfos; add HTTP method + schema compilation tests (+13 tests, 425β438) #444
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
sergey-tihon
merged 5 commits into
master
from
repo-assist/improvements-20260519-3a1196a59358c79d
May 20, 2026
+163
β5
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e9541e4
perf/test: avoid obj[] in getPropertyNamesAndInfos; add HTTP method aβ¦
github-actions[bot] 004d204
ci: trigger checks
github-actions[bot] 7fb59db
Address reviewer comments: inherit=false, remove local compileV3Schemβ¦
Copilot 6acbaa2
Address reviewer comments: ReferenceEquals cache test, move v3 tests β¦
Copilot f69c6a7
Address reviewer comments: clarify AmbiguousMatchException safety, reβ¦
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
109 changes: 109 additions & 0 deletions
109
tests/SwaggerProvider.Tests/Schema.V3SchemaCompilationTests.fs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| module SwaggerProvider.Tests.Schema_V3SchemaCompilationTests | ||
|
|
||
| /// Tests for OpenAPI 3.0-specific schema compilation behaviour in the v3 | ||
| /// DefinitionCompiler pipeline. | ||
|
|
||
| open Xunit | ||
| open FsUnitTyped | ||
|
|
||
| // ββ allOf/oneOf/anyOf single-$ref wrapper collapse ββββββββββββββββββββββββββββ | ||
|
|
||
| // Tests for the DefinitionCompiler's explicit allOf/oneOf/anyOf single-$ref collapse | ||
| // branches, which release the name reservation for the wrapper schema and return | ||
| // the already-compiled referenced type directly via ReleaseNameReservation. | ||
| // This avoids emitting an empty wrapper type when a schema has no explicit properties | ||
| // and carries a single $ref inside allOf/oneOf/anyOf. | ||
|
|
||
| /// Minimal OpenAPI 3.0 document with a Pet schema and a PetRef schema that wraps | ||
| /// it via allOf with a single $ref. The compiler should collapse PetRef into Pet | ||
| /// rather than creating a new empty object type. | ||
| let private allOfSingleRefSchema = | ||
| """{ | ||
| "openapi": "3.0.0", | ||
| "info": { "title": "Test", "version": "1.0.0" }, | ||
| "paths": {}, | ||
| "components": { | ||
| "schemas": { | ||
| "Pet": { | ||
| "type": "object", | ||
| "properties": { | ||
| "id": { "type": "integer" }, | ||
| "name": { "type": "string" } | ||
| } | ||
| }, | ||
| "PetRef": { | ||
| "allOf": [ { "$ref": "#/components/schemas/Pet" } ] | ||
| } | ||
| } | ||
| } | ||
| }""" | ||
|
|
||
| /// Same schema but using oneOf instead of allOf. | ||
| let private oneOfSingleRefSchema = | ||
| """{ | ||
| "openapi": "3.0.0", | ||
| "info": { "title": "Test", "version": "1.0.0" }, | ||
| "paths": {}, | ||
| "components": { | ||
| "schemas": { | ||
| "Dog": { | ||
| "type": "object", | ||
| "properties": { "breed": { "type": "string" } } | ||
| }, | ||
| "DogRef": { | ||
| "oneOf": [ { "$ref": "#/components/schemas/Dog" } ] | ||
| } | ||
| } | ||
| } | ||
| }""" | ||
|
|
||
| /// Same schema but using anyOf instead of allOf. | ||
| let private anyOfSingleRefSchema = | ||
| """{ | ||
| "openapi": "3.0.0", | ||
| "info": { "title": "Test", "version": "1.0.0" }, | ||
| "paths": {}, | ||
| "components": { | ||
| "schemas": { | ||
| "Cat": { | ||
| "type": "object", | ||
| "properties": { "color": { "type": "string" } } | ||
| }, | ||
| "CatRef": { | ||
| "anyOf": [ { "$ref": "#/components/schemas/Cat" } ] | ||
| } | ||
| } | ||
| } | ||
| }""" | ||
|
|
||
| [<Fact>] | ||
| let ``allOf single $ref resolves to the referenced type without creating a new object type``() = | ||
| let types = compileV3Schema allOfSingleRefSchema false | ||
| // PetRef collapses into Pet via ReleaseNameReservation; the referenced type is present. | ||
| types |> List.exists(fun t -> t.Name = "Pet") |> shouldEqual true | ||
|
|
||
| [<Fact>] | ||
| let ``allOf single $ref does not produce a separate wrapper type``() = | ||
| let types = compileV3Schema allOfSingleRefSchema false | ||
| // PetRef's name reservation is released; no separate empty type named "PetRef" is emitted. | ||
| types |> List.exists(fun t -> t.Name = "PetRef") |> shouldEqual false | ||
|
|
||
| [<Fact>] | ||
| let ``oneOf single $ref resolves to the referenced type``() = | ||
| let types = compileV3Schema oneOfSingleRefSchema false | ||
| types |> List.exists(fun t -> t.Name = "Dog") |> shouldEqual true | ||
|
|
||
| [<Fact>] | ||
| let ``oneOf single $ref does not produce a separate wrapper type``() = | ||
| let types = compileV3Schema oneOfSingleRefSchema false | ||
| types |> List.exists(fun t -> t.Name = "DogRef") |> shouldEqual false | ||
|
|
||
| [<Fact>] | ||
| let ``anyOf single $ref resolves to the referenced type``() = | ||
| let types = compileV3Schema anyOfSingleRefSchema false | ||
| types |> List.exists(fun t -> t.Name = "Cat") |> shouldEqual true | ||
|
|
||
| [<Fact>] | ||
| let ``anyOf single $ref does not produce a separate wrapper type``() = | ||
| let types = compileV3Schema anyOfSingleRefSchema false | ||
| types |> List.exists(fun t -> t.Name = "CatRef") |> shouldEqual false |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.