Repository navigation
docs: a Swashbuckle schema filter for ranges and sets (#49) - #605
Merged
Merged
Conversation
Swashbuckle describes a type from its public properties: a range is an object with "length", a value set an object with "values", "count" and "isEmpty", a range set an array of those objects. None of it is what the API sends. docs/serialization.md gets a "Swashbuckle" section with a schema filter to copy, ValueRangesSchemaFilter, which gives each type the schema the documented Microsoft.AspNetCore.OpenApi transformer gives: the range and multirange literal as a string with its pattern, a value set as an array of unique elements. As with the transformer, the AspNetCore test project compiles the filter and SwashbuckleSchemaFilterTests holds the doc to it verbatim. The tests generate a real Swashbuckle 11.0.1 document both ways and check that the filter's patterns are the transformer's text. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Swashbuckle describes a range set as a list of ranges, so its schema carried "items" beside the string type the filter set. Replace clears them, and the multirange test asserts it; it fails without the line. The bullet saying Swashbuckle 10 works too goes: it was not run here. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 30, 2026
Open
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.
Closes #49
For both lines: this merges into
main, then is cherry-picked with-xintorelease/10.x(the port PR follows). Documentation and its test only; no package changes.Problem
docs/serialization.mddocuments an OpenAPI schema transformer forMicrosoft.AspNetCore.OpenApi, but many consumers use Swashbuckle. Swashbuckle describes a type from its public properties. Measured with Swashbuckle 11.0.1 on this branch:DateRangeis{"type":"object","properties":{"length":…}};StringSetis an object withvalues,countandisEmpty;DateRangeSetis an array of those range objects.None of that is what the API sends.
Change
test/CodoMetis.ValueRanges.AspNetCore.Tests/ValueRangesSchemaFilter.cs(new): anISchemaFilterthat gives each type the schema the transformer gives, with the same three branches and the same two patterns. A range or variant becomes a string with the range-literal pattern, a range set a string with the multirange pattern, and a value settype: array,uniqueItems: truewithitemsfrom the element's own schema. It also drops the properties Swashbuckle wrote. It usesIOpenApiSchemaand casts toOpenApiSchemato mutate, as Swashbuckle's v10 migration guide prescribes.docs/serialization.md: a "Swashbuckle" section under "OpenAPI" that carries the filter verbatim, its registration (AddSwaggerGen(o => o.SchemaFilter<ValueRangesSchemaFilter>())) and three "Good to know" bullets.Swashbuckle.AspNetCore11.0.1, which uses Microsoft.OpenApi 3.11, the versionMicrosoft.AspNetCore.OpenApi11 uses.Docs:row under### Addedof[11.0.0-preview.3]in the root and core changelogs. AGENTS.md names the second verbatim snippet.Tests
SwashbuckleSchemaFilterTests(new, 7 tests) generate a real Swashbuckle document throughTestServer:propertiesleft, and noitemson a range set (Swashbuckle writes a range set as a list of ranges; the second commit drops them, and the test fails without that line);DocumentedSnippet_IsThisFileholds the doc to the compiled copy. It failed before the doc section was written.AspNetCore tests: 99 pass. Conventions: 432 pass.
🤖 Generated with Claude Code