V10.2.0/support api alias - #34
Conversation
Added comprehensive unit test coverage for SemanticApiVersion compatibility with standard ApiVersion. Tests verify equality, hash code consistency, and parser support for shorthand semantic version formats (major only and major.minor).
Introduced Codebelt.Extensions.Asp.Versioning.FunctionalTests project with end-to-end test scenarios covering production and non-production compatibility use cases. Tests verify semantic version behavior across real middleware and application context. Updated solution file to include the new test project.
Updated namespace documentation and DocFX publishing configuration to reflect semantic version compatibility feature. Clarified behavior of SemanticApiVersion equality and comparison semantics. Updated site navigation and doc build metadata.
The type RestfulApiVersionReader was defined with a filename that did not match its name. Correct the filename to follow naming conventions and improve discoverability.
Add the 'Test' suffix to functional test class names to align with the naming conventions defined in copilot-instructions.md. Improves discoverability and consistency across the test suite.
…ation
Reflect changes in SemanticApiVersion behavior: Equals no longer treats patch-zero versions as equivalent to ApiVersion, and Parse rejects non-fully-qualified semantic versions ('1' and '1.2'). Update test expectations and test method names to document the stricter validation rules.
Normalize line endings from CRLF to LF for consistent source formatting across the codebase.
Introduce a new public API parser that maps friendly version aliases (major, major-minor, major-minor-patch) to their corresponding semantic API versions. This enables callers to use shortened tokens like '1' or '1.2' while the application works with canonical ApiVersion instances. Includes factory methods for single and multiple version support with fallback to default parsing.
Remove the private nested AliasApiVersionParser class from SemanticApiVersionCompatibilityTest and use the newly extracted public ApiVersionAliasParser instead. This eliminates code duplication and leverages the extracted implementation.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #34 +/- ##
==========================================
- Coverage 99.60% 99.45% -0.16%
==========================================
Files 10 11 +1
Lines 510 553 +43
Branches 82 86 +4
==========================================
+ Hits 508 550 +42
- Misses 2 3 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Greptile SummaryThis PR introduces
Confidence Score: 5/5Safe to merge; core alias-parsing logic is correct and well-validated. The two findings are design observations about DI registration ordering that do not break anything under the standard .NET single-type resolution path. The new
Important Files Changed
Sequence Diagram%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant Client
participant Reader as RestfulApiVersionReader
participant Alias as ApiVersionAliasParser
participant Fallback as DefaultParser
participant Router as AspVersioningRouter
Client->>Reader: "v=1 in Accept header"
Reader->>Alias: TryParse 1
alt alias match
Alias-->>Reader: SemanticApiVersion 1.0.0
else no alias found
Alias->>Fallback: TryParse 1
Fallback-->>Alias: ApiVersion 1.0
Alias-->>Reader: ApiVersion 1.0
end
Reader->>Router: resolved ApiVersion
Router-->>Client: 204 No Content
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
participant Client
participant Reader as RestfulApiVersionReader
participant Alias as ApiVersionAliasParser
participant Fallback as DefaultParser
participant Router as AspVersioningRouter
Client->>Reader: "v=1 in Accept header"
Reader->>Alias: TryParse 1
alt alias match
Alias-->>Reader: SemanticApiVersion 1.0.0
else no alias found
Alias->>Fallback: TryParse 1
Fallback-->>Alias: ApiVersion 1.0
Alias-->>Reader: ApiVersion 1.0
end
Reader->>Router: resolved ApiVersion
Router-->>Client: 204 No Content
Reviews (2): Last reviewed commit: "🐛 fix and clarify semantic version alia..." | Re-trigger Greptile |
Clarify the ApiVersionAliasParser behavior in AddRestfulApiVersioning remarks and explain when applications need to explicitly register additional aliases. Fix incorrect test class reference in SemanticApiVersionDefaultCompatibilityTest constructor and correct the invalid version string in SemanticApiVersionTest assertion.
This pull request introduces support for API version aliasing using semantic version formats, making it easier for clients to specify API versions with shortened or compatibility-oriented tokens (like
1,1.0, or1.0.0). It adds a new parser for handling these aliases, updates the service registration to use the parser, and includes comprehensive functional tests to ensure compatibility. Documentation and solution files are also updated accordingly.API Version Alias Support:
ApiVersionAliasParserclass that resolves friendly API version aliases (e.g.,1,1.0,1.0.0) to canonicalApiVersioninstances, with fallback to the default parser. This enables flexible version token handling in APIs.AddRestfulApiVersioningto automatically register the alias parser when a semantic default version is used, and introduced a newAddApiVersionParserextension method for custom parser registration.Testing:
Codebelt.Extensions.Asp.Versioning.FunctionalTeststo the solution. [1] [2]SemanticApiVersionCompatibilityTestandSemanticApiVersionDefaultCompatibilityTestto verify that API endpoints correctly route requests using various semantic version formats and aliases. [1] [2]Documentation and Solution Updates:
.docfx/toc.ymland.docfx/docfx.jsonto reflect new documentation structure and ensure correct file references. [1] [2]