Skip to content

Add TypedClient sample apps and fix client naming and Asp.Versioning imports - #64

Merged
davidkallesen merged 3 commits into
mainfrom
feature/missing-operationid-in-typedclient-support
Aug 18, 2026
Merged

Add TypedClient sample apps and fix client naming and Asp.Versioning imports#64
davidkallesen merged 3 commits into
mainfrom
feature/missing-operationid-in-typedclient-support

Conversation

@davidkallesen

Copy link
Copy Markdown
Contributor

Fixes two TypedClient generation defects and adds runnable console apps that
demonstrate how to consume the generated clients.

Generator fixes:

  • Client class naming
    The generated client type name was derived from the full project name, so a
    dotted name such as "Eloverblik.Api.ThirdPartyApi" produced an invalid
    identifier. HttpClientExtractor and ApiClientGenerator now use
    CasingHelper.GetLastNameSegment(projectName), yielding "ThirdPartyApiClient".

  • Asp.Versioning using import
    UsingStatementHelper matched the bare "ApiVersion" token, so ordinary
    client-side member access such as "parameters.ApiVersion" pulled in the
    server-only Asp.Versioning namespace and broke the build. The mapping now
    keys on the construction shape "new ApiVersion(" instead.

Both fixes are covered by new tests in HttpClientExtractorTests and
UsingStatementHelperTests.

Samples:

  • Restructured the ThirdParty-EPO-Clients and ThridParty-Typed-Clients folders
    and added the EloverblikThirdPartyApiClient TypedClient sample.
  • Added EloverblikThirdPartyApiClient-App console apps for both generation
    modes, showing host setup, IHttpClientFactory registration and the generated
    API surface. Authentication is handled by a BearerTokenProvider singleton
    read by a BearerTokenHandler on each request, since IHttpClientFactory pools
    handlers and Eloverblik exchanges a refresh token for a short-lived access
    token mid-session.
  • The paired apps make the mode differences explicit: EndpointPerOperation
    resolves per-operation endpoint interfaces from DI via the generated
    AddEloverblikApiThirdPartyApiEndpoints() and returns result wrappers with
    IsOk/IsUnauthorized branches, while TypedClient registers a single
    ThirdPartyApiClient typed client whose methods return payloads directly and
    throw HttpRequestException on non-success.
  • Both apps registered in Atc.Rest.Api.SourceGenerator.slnx.

@davidkallesen
davidkallesen merged commit 1200497 into main Aug 18, 2026
7 checks passed
@davidkallesen
davidkallesen deleted the feature/missing-operationid-in-typedclient-support branch August 18, 2026 12:15
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.

1 participant