Interface IBowireUploadedSchemaReader

Namespace
Kuestenlogik.Bowire
Assembly
Kuestenlogik.Bowire.dll

A protocol plugin that imports schema documents core cannot read (#991, #994).

public interface IBowireUploadedSchemaReader

Remarks

Core stores what the workbench uploads and merges it into discovery, so the workbench, bowire discover and the MCP tool agree on what a URL offers. For a .proto it can do the reading itself. Every other format belongs to the plugin that speaks its protocol: a compiled descriptor set needs the protobuf runtime, GraphQL SDL a GraphQL parser, an EDMX document the OData model library. Core references none of them and should not start to, because every host that embeds Bowire would carry them.

So a plugin declares the kinds it imports, and core asks through this interface: once when a document is uploaded, to refuse one that is not what its name says, and again when discovery lists what is stored. The upload endpoint routes a file to a kind by the extensions declared here; the file picker accepts what the loaded plugins declare.

Properties

UploadedSchemaKinds

The schema kinds this plugin imports.

IReadOnlyList<BowireUploadedSchemaKind> UploadedSchemaKinds { get; }

Property Value

IReadOnlyList<BowireUploadedSchemaKind>

Methods

LooksLikeUploadedSchema(string, ReadOnlyMemory<byte>)

Whether document looks like a document of kind.

bool LooksLikeUploadedSchema(string kind, ReadOnlyMemory<byte> document)

Parameters

kind string
document ReadOnlyMemory<byte>

Returns

bool

Remarks

Asked only when the file name does not settle the kind: several kinds declare the extension (.json is OpenAPI, AsyncAPI and OpenRPC), or none does. A cheap look at the head of the document is enough, e.g. its top-level key or root element; the full read happens in ReadUploadedSchema(string, ReadOnlyMemory<byte>, string). The default says no, which suits a kind whose extensions are its own.

ReadUploadedSchema(string, ReadOnlyMemory<byte>, string)

The services one document of kind describes, in the shape the plugin's own discovery returns them.

IReadOnlyList<BowireServiceInfo> ReadUploadedSchema(string kind, ReadOnlyMemory<byte> document, string sourceName)

Parameters

kind string

One of UploadedSchemaKinds.

document ReadOnlyMemory<byte>

The document as it was uploaded.

sourceName string

The file name it was uploaded under.

Returns

IReadOnlyList<BowireServiceInfo>

Exceptions

FormatException

The bytes are not a document of this kind.