Skip to content

feat: Refactor API structure to introduce versioned interfaces#666

Merged
frasermolyneux merged 1 commit intomainfrom
feature/api-meta-endpoint
Feb 21, 2026
Merged

feat: Refactor API structure to introduce versioned interfaces#666
frasermolyneux merged 1 commit intomainfrom
feature/api-meta-endpoint

Conversation

@frasermolyneux
Copy link
Owner

This pull request introduces version selector interfaces and implementations for the ApiInfo and ApiHealth endpoints, aligning them with the existing versioned pattern used for GeoLookup. The changes update the client, fakes, service registration, and documentation to ensure all API endpoints are accessed through versioned selectors, improving consistency and extensibility. Additionally, the API Management policy is updated to allow anonymous access to health and info endpoints.

API Versioning and Client Updates:

  • Introduced IVersionedApiHealthApi and IVersionedApiInfoApi interfaces, and their implementations (VersionedApiHealthApi, VersionedApiInfoApi) to provide versioned access to health and info endpoints, similar to IVersionedGeoLookupApi. [1] [2]
  • Updated IGeoLocationApiClient and GeoLocationApiClient to expose ApiInfo and ApiHealth as versioned properties (IVersionedApiInfoApi, IVersionedApiHealthApi) instead of direct endpoint interfaces. [1] [2] [3]
  • Removed the unversioned IVersionedGeoLookupApi interface from the abstractions package and clarified in documentation that version selector interfaces are defined in the client package. [1] [2]

Testing and Fakes:

  • Added FakeVersionedApiHealthApi and FakeVersionedApiInfoApi classes for testing, updated FakeGeoLocationApiClient to use these, and adjusted tests to access versioned endpoints (ApiInfo.V1, ApiHealth.V1). [1] [2] [3] [4] [5]
  • Updated service registration in both the main and testing packages to register the new versioned interfaces, ensuring correct DI resolution. [1] [2]

API Management Policy:

  • Modified API Management policy to allow anonymous (unauthenticated) access to /vX/health and /vX/info endpoints, while requiring JWT validation for all other endpoints. [1] [2]

Other:

  • Minor: Added a root endpoint ("/") to the API for health checks or basic connectivity.

These changes collectively standardize versioning across all API endpoints, simplify future version additions, and improve testability and security configuration.

…prove client access to health and info endpoints
Copilot AI review requested due to automatic review settings February 21, 2026 20:11
@github-actions
Copy link
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@sonarqubecloud
Copy link

@github-actions
Copy link
Contributor

🏗️ Terraform Plan

🌍 Environment: dev

✅ Validate — Passed

✅ Plan

Count
🔄 Change 2
📋 Resource Details
Action Resource
🔄 Update azurerm_api_management_product_policy.api_product_policy
🔄 Update azurerm_api_management_subscription.web

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request refactors the API client structure to use versioned interfaces for all endpoints (ApiInfo, ApiHealth, and GeoLookup), ensuring consistency across the client API surface. It also updates the APIM product policy to allow anonymous access to health and info endpoints.

Changes:

  • Introduced IVersionedApiInfoApi and IVersionedApiHealthApi interfaces with their implementations, aligning the API info and health endpoints with the existing versioned pattern used for GeoLookup
  • Updated IGeoLocationApiClient to expose versioned properties for all endpoints, requiring consumers to access endpoints via .V1 property (e.g., client.ApiInfo.V1.GetApiInfo())
  • Modified APIM product policy to conditionally bypass JWT validation for health and info endpoints while requiring authentication for all other endpoints

Reviewed changes

Copilot reviewed 14 out of 16 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
terraform/azurerm_api_management_product_policy.tf Added conditional JWT validation with regex pattern to allow anonymous access to health and info endpoints
src/MX.GeoLocation.Api.V1/Program.cs Added root endpoint for basic connectivity checks
src/MX.GeoLocation.Api.Client.V1/ServiceCollectionExtensions.cs Removed redundant using statement and registered new versioned interface implementations
src/MX.GeoLocation.Api.Client.V1/IGeoLocationApiClient.cs Updated properties to use versioned interfaces for ApiInfo and ApiHealth
src/MX.GeoLocation.Api.Client.V1/GeoLocationApiClient.cs Updated constructor and properties to use versioned interfaces
src/MX.GeoLocation.Api.Client.V1/ApiVersionSelectors.cs Defined new version selector interfaces for ApiHealth and ApiInfo
src/MX.GeoLocation.Api.Client.V1/ApiVersionSelectorImplementations.cs Implemented version selector wrapper classes for ApiHealth and ApiInfo
src/MX.GeoLocation.Api.Client.V1/Api/V1/ApiInfoApi.cs New file implementing the API info endpoint client
src/MX.GeoLocation.Api.Client.V1/Api/V1/ApiHealthApi.cs New file implementing the API health endpoint client
src/MX.GeoLocation.Api.Client.Testing/ServiceCollectionExtensions.cs Registered new versioned interfaces in the fake client setup
src/MX.GeoLocation.Api.Client.Testing/FakeGeoLocationApiClient.cs Added fake implementations for new versioned interfaces
src/MX.GeoLocation.Api.Client.Testing.Tests/ServiceCollectionExtensionsTests.cs Added assertions for new versioned interface registrations
src/MX.GeoLocation.Api.Client.Testing.Tests/FakeGeoLocationApiClientTests.cs Updated tests to use versioned access pattern (.V1 property)
src/MX.GeoLocation.Abstractions.V1/README.md Updated documentation to clarify version selector interfaces are in client package
src/MX.GeoLocation.Abstractions.V1/Interfaces/IVersionedGeoLookupApi.cs Removed file, moved interface to client package
docs/testing.md Updated documentation to reflect versioned access pattern for health and info endpoints

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants