Interface IBowireOpenApiAdapter
- Namespace
- Kuestenlogik.Bowire.Protocol.Rest
- Assembly
- Kuestenlogik.Bowire.Protocol.Rest.dll
Seam between the REST protocol plugin and the OpenAPI parsing
library. Bowire.Protocol.Rest itself has NO compile-time reference
to Microsoft.OpenApi; the actual parsing implementation
lives in one of the optional adapter packages
(Kuestenlogik.Bowire.Protocol.Rest.OpenApi3, future
.OpenApi2), discovered at runtime via
BowireOpenApiAdapterRegistry.
public interface IBowireOpenApiAdapter
Remarks
Why a seam at all. Microsoft.OpenApi had a major version
bump from 2.x to 3.x with a redesigned API surface. ASP.NET Core
10's built-in AddOpenApi() still depends on the 2.x line;
embedded hosts that mix Bowire's REST plugin with ASP.NET's own
OpenAPI generator would otherwise hit a single-DLL-version collision
at runtime. Splitting the parser into version-specific adapter
packages lets each consumer pick the version that matches the rest
of their app — the REST plugin stays version-agnostic and falls back
to "no schema discovery, no mock-from-OpenAPI" when no adapter is
registered.
Public contract: every method returns Bowire's own DTOs
(BowireServiceInfo, BowireRecording),
never leaking Microsoft.OpenApi.* types across the seam.
Properties
OpenApiLibraryMajorVersion
Major version of the Microsoft.OpenApi library this
adapter is built against. Used by
BowireOpenApiAdapterRegistry to pick the right
implementation when more than one adapter package is loaded
(rare — typically only when a sideloaded plugin pulls in a
second adapter). The registry prefers the adapter whose
OpenApiLibraryMajorVersion matches the
Microsoft.OpenApi assembly already loaded into the
process; falls back to the lowest-numbered candidate when no
match is available.
int OpenApiLibraryMajorVersion { get; }
Property Value
Methods
BuildMockRecordingFromFileAsync(string, CancellationToken)
Read an OpenAPI document from disk and synthesise a
BowireRecording with one step per operation +
schema-generated example responses. Drives
bowire mock --schema <path>.
Task<BowireRecording> BuildMockRecordingFromFileAsync(string path, CancellationToken ct)
Parameters
pathstringctCancellationToken
Returns
FetchAndDiscoverAsync(string, HttpClient, CancellationToken)
Fetch the OpenAPI document at docUrl via
http and convert it into a list of Bowire
services + the API base URL the workbench should fire requests
at. Returns null when the URL isn't reachable, returns
non-OpenAPI content, or the parse otherwise fails — the REST
plugin treats null as "this URL isn't an OpenAPI doc" and lets
sibling protocol plugins try the same URL.
Task<BowireOpenApiDiscoveryResult?> FetchAndDiscoverAsync(string docUrl, HttpClient http, CancellationToken ct)
Parameters
docUrlstringhttpHttpClientctCancellationToken
Returns
ParseAndDiscoverAsync(string, string, CancellationToken)
Parse OpenAPI/Swagger document text (JSON or YAML) without an HTTP fetch. Used for documents uploaded via the workbench's schema upload surface or pasted into the discovery prompt.
Task<BowireOpenApiDiscoveryResult?> ParseAndDiscoverAsync(string content, string sourceLabel, CancellationToken ct)
Parameters
contentstringVerbatim document body — JSON or YAML.
sourceLabelstringDisplay label for the document; surfaces in caches and recordings.
ctCancellationTokenCancellation token.