Skip to content

C# API Reference

C# API Reference v0.17.0-rc.11

Functions

SchemaQueryOnly()

Create a simple schema configuration with only Query type.

This is a convenience function for schemas that only have queries.

Returns:

A QueryOnlyConfig with default settings

Signature:

public static QueryOnlyConfig SchemaQueryOnly()

Example:

var result = SchemaQueryOnly();

Returns: QueryOnlyConfig


SchemaQueryMutation()

Create a schema configuration with Query and Mutation types.

This is a convenience function for schemas with queries and mutations but no subscriptions.

Returns:

A QueryMutationConfig with default settings

Signature:

public static QueryMutationConfig SchemaQueryMutation()

Example:

var result = SchemaQueryMutation();

Returns: QueryMutationConfig


SchemaFull()

Create a schema configuration with all three root types.

This is a convenience function for fully-featured schemas.

Returns:

A FullSchemaConfig with default settings

Signature:

public static FullSchemaConfig SchemaFull()

Example:

var result = SchemaFull();

Returns: FullSchemaConfig


Types

ApiKeyConfig

API Key authentication configuration

Field Type Default Description
Keys List<string> Valid API keys
HeaderName string serde(default = "default_api_key_header") Header name to check (e.g., "X-API-Key")

AsyncApiConfig

AsyncAPI HTTP endpoint configuration

Field Type Default Description
Enabled bool Enable AsyncAPI endpoints (default: false)
Spec object? null Pre-registered AsyncAPI spec to serve from GET /asyncapi.json

BackgroundJobMetadata

Field Type Default Description
Name string The name
RequestId string? null Request id
Methods
CreateDefault()

Signature:

public BackgroundJobMetadata CreateDefault()

Example:

var result = BackgroundJobMetadata.CreateDefault();

Returns: BackgroundJobMetadata


BackgroundTaskConfig

Configuration for in-process background task execution.

Field Type Default Description
MaxQueueSize nuint 1024 Maximum queue size
MaxConcurrentTasks nuint 128 Maximum concurrent tasks
DrainTimeoutSecs ulong 30 Drain timeout secs
Methods
CreateDefault()

Signature:

public BackgroundTaskConfig CreateDefault()

Example:

var result = BackgroundTaskConfig.CreateDefault();

Returns: BackgroundTaskConfig


CompressionConfig

Compression configuration shared across runtimes

Field Type Default Description
Gzip bool true Enable gzip compression
Brotli bool true Enable brotli compression
MinSize nuint Minimum response size to compress (bytes)
Quality uint Compression quality (0-11 for brotli, 0-9 for gzip)
Methods
CreateDefault()

Signature:

public CompressionConfig CreateDefault()

Example:

var result = CompressionConfig.CreateDefault();

Returns: CompressionConfig


ContactInfo

Contact information

Field Type Default Description
Name string? null Name of the contact person or organisation.
Email string? null Contact email address.
Url string? null URL pointing to the contact information page.

CorsConfig

CORS configuration for a route

Field Type Default Description
AllowedOrigins List<string> new List<string>() Allowed origins
AllowedMethods List<string> new List<string>() Allowed methods
AllowedHeaders List<string> new List<string>() Allowed headers
ExposeHeaders List<string>? null Expose headers
MaxAge uint? null Maximum age
AllowCredentials bool? null Allow credentials
Methods
AllowedMethodsJoined()

Get the cached joined methods string for preflight responses

Signature:

public string AllowedMethodsJoined()

Example:

var result = instance.AllowedMethodsJoined();

Returns: string

AllowedHeadersJoined()

Get the cached joined headers string for preflight responses

Signature:

public string AllowedHeadersJoined()

Example:

var result = instance.AllowedHeadersJoined();

Returns: string

IsOriginAllowed()

Check if an origin is allowed (O(1) with wildcard, O(n) for exact match)

Signature:

public bool IsOriginAllowed(string origin)

Example:

var result = instance.IsOriginAllowed("value");

Parameters:

Name Type Required Description
Origin string Yes The origin

Returns: bool

IsMethodAllowed()

Check if a method is allowed (O(1) with wildcard, O(n) for exact match)

Signature:

public bool IsMethodAllowed(string method)

Example:

var result = instance.IsMethodAllowed("value");

Parameters:

Name Type Required Description
Method string Yes The method

Returns: bool

CreateDefault()

Signature:

public CorsConfig CreateDefault()

Example:

var result = CorsConfig.CreateDefault();

Returns: CorsConfig


DynamicSchemaConfig

Configuration for building and executing a dynamic-SDL schema.

Field Type Default Description
IntrospectionEnabled bool Whether introspection queries (__schema, __type) are permitted.
MaxComplexity nuint? null Maximum query complexity (null = unlimited).
MaxDepth nuint? null Maximum query depth (null = unlimited).
FieldErrors List<FieldErrorSpec> new List<FieldErrorSpec>() Field-level errors to inject at specific response paths.

FieldErrorSpec

A field-level error to inject at a specific response path.

path is the dot-separated sequence of field names from the operation root to the field that should fail, e.g. "user" for a top-level field or "order.customer" for a nested one.

Field Type Default Description
Path string Dot-separated path to the field that should error.
Message string The error message to surface for that field.

FullSchemaConfig

Configuration for fully-featured schemas with Query, Mutation, and Subscription types

Field Type Default Description
IntrospectionEnabled bool true Enable introspection queries
ComplexityLimit nuint? null Maximum query complexity (None = unlimited)
DepthLimit nuint? null Maximum query depth (None = unlimited)
Methods
CreateDefault()

Signature:

public FullSchemaConfig CreateDefault()

Example:

var result = FullSchemaConfig.CreateDefault();

Returns: FullSchemaConfig


GraphQlRouteConfig

Configuration for GraphQL routes

Provides a builder pattern for configuring GraphQL route parameters for the Spikard HTTP server's routing system.

Methods
New()

Create a new GraphQL route configuration with defaults

Default values:

  • path: "/graphql"
  • method: "POST"
  • enable_playground: false

Signature:

public GraphQlRouteConfig New()

Example:

var result = GraphQlRouteConfig.New();

Returns: GraphQlRouteConfig

Path()

Set the HTTP path for the GraphQL endpoint

Signature:

public GraphQlRouteConfig Path(string path)

Example:

var result = instance.Path("value");

Parameters:

Name Type Required Description
Path string Yes The URL path (e.g., "/graphql", "/api/graphql")

Returns: GraphQlRouteConfig

Method()

Set the HTTP method for the GraphQL endpoint

Signature:

public GraphQlRouteConfig Method(string method)

Example:

var result = instance.Method("value");

Parameters:

Name Type Required Description
Method string Yes The HTTP method (typically "POST")

Returns: GraphQlRouteConfig

EnablePlayground()

Enable or disable the GraphQL Playground UI

Signature:

public GraphQlRouteConfig EnablePlayground(bool enable)

Example:

var result = instance.EnablePlayground(true);

Parameters:

Name Type Required Description
Enable bool Yes Whether to enable playground

Returns: GraphQlRouteConfig

Description()

Set a custom description for documentation

Signature:

public GraphQlRouteConfig Description(string description)

Example:

var result = instance.Description("value");

Parameters:

Name Type Required Description
Description string Yes Documentation string

Returns: GraphQlRouteConfig

GetPath()

Get the configured path

Signature:

public string GetPath()

Example:

var result = instance.GetPath();

Returns: string

GetMethod()

Get the configured method

Signature:

public string GetMethod()

Example:

var result = instance.GetMethod();

Returns: string

IsPlaygroundEnabled()

Check if playground is enabled

Signature:

public bool IsPlaygroundEnabled()

Example:

var result = instance.IsPlaygroundEnabled();

Returns: bool

GetDescription()

Get the description if set

Signature:

public string? GetDescription()

Example:

var result = instance.GetDescription();

Returns: string?

CreateDefault()

Signature:

public GraphQlRouteConfig CreateDefault()

Example:

var result = GraphQlRouteConfig.CreateDefault();

Returns: GraphQlRouteConfig


GrpcConfig

Configuration for gRPC support

Controls how the server handles gRPC requests, including compression, timeouts, and protocol settings.

Stream Limits

This configuration enforces message-level size limits but delegates concurrent stream limiting to the HTTP/2 transport layer:

  • Message Size Limits: The max_message_size field is enforced per individual message (request or response) in both unary and streaming RPCs. When a single message exceeds this limit, the request is rejected with PAYLOAD_TOO_LARGE (HTTP 413).

  • Concurrent Stream Limits: The max_concurrent_streams is an advisory configuration passed to the HTTP/2 layer for connection-level stream negotiation. The HTTP/2 transport automatically enforces this limit and returns GOAWAY frames when exceeded. Applications should not rely on custom enforcement of this limit.

  • Stream Response Size Limits: The max_stream_response_bytes field caps the total encoded bytes emitted across a server-streaming or bidi-streaming response. When the cumulative size exceeds the limit, the stream is terminated with tonic.Status.resource_exhausted. Defaults to null (unbounded).

Field Type Default Description
Enabled bool true Enable gRPC support
MaxMessageSize nuint Maximum message size in bytes (for both sending and receiving) This limit applies to individual messages in both unary and streaming RPCs. When a single message exceeds this size, the request is rejected with HTTP 413 (Payload Too Large). Default: 4MB (4194304 bytes) Note: This limit does NOT apply to the total response size in streaming RPCs. For multi-message streams, the total response can exceed this limit as long as each individual message stays within the limit.
EnableCompression bool true Enable gzip compression for gRPC messages
RequestTimeout ulong? null Timeout for gRPC requests in seconds (None = no timeout)
MaxConcurrentStreams uint Maximum number of concurrent streams per connection (HTTP/2 advisory) This value is communicated to HTTP/2 clients as the server's flow control limit. The HTTP/2 transport layer enforces this limit automatically via SETTINGS frames and GOAWAY responses. Applications should NOT implement custom enforcement. Default: 100 streams per connection # Stream Limiting Strategy - Per Connection: This limit applies per HTTP/2 connection, not globally - Transport Enforcement: HTTP/2 handles all stream limiting; applications need not implement custom checks - Streaming Requests: In server streaming or bidi streaming, each logical RPC consumes one stream slot. Message ordering within a stream follows HTTP/2 frame ordering.
EnableKeepalive bool true Enable HTTP/2 keepalive
KeepaliveInterval ulong HTTP/2 keepalive interval in seconds
KeepaliveTimeout ulong HTTP/2 keepalive timeout in seconds
MaxStreamResponseBytes nuint? null Total byte cap across an entire streaming response. When Some(n), the streaming adapter aborts the stream with tonic.Status.resource_exhausted once the cumulative encoded message bytes exceed n. The stream yields the error item and then terminates. Per-message cap remains max_message_size. This limit applies to server-streaming and bidirectional-streaming RPCs only; unary RPCs are governed solely by max_message_size. Default: null (unbounded total response size).
Methods
CreateDefault()

Signature:

public GrpcConfig CreateDefault()

Example:

var result = GrpcConfig.CreateDefault();

Returns: GrpcConfig


IntoHandler

Convert user-facing handler functions into the low-level Handler trait.

Methods
IntoHandler()

Convert this value into a shared request handler.

Signature:

public Handler IntoHandler()

Example:

var result = instance.IntoHandler();

Returns: Handler


JsonRpcConfig

JSON-RPC server configuration

Field Type Default Description
Enabled bool true Enable JSON-RPC endpoint
EndpointPath string HTTP endpoint path for JSON-RPC requests (default: "/rpc")
EnableBatch bool Enable batch request processing (default: true)
MaxBatchSize nuint Maximum number of requests in a batch (default: 100)
Methods
CreateDefault()

Signature:

public JsonRpcConfig CreateDefault()

Example:

var result = JsonRpcConfig.CreateDefault();

Returns: JsonRpcConfig


JsonRpcMethodInfo

JSON-RPC method metadata for routes that support JSON-RPC

This struct captures the metadata needed to expose HTTP routes as JSON-RPC methods, enabling discovery and documentation of RPC-compatible endpoints.

Field Type Default Description
MethodName string The JSON-RPC method name (e.g., "user.create")
Description string? null Optional description of what the method does
ParamsSchema object? null Optional JSON Schema for method parameters
ResultSchema object? null Optional JSON Schema for the result
Deprecated bool /* serde(default) */ Whether this method is deprecated
Tags List<string> /* serde(default) */ Tags for categorizing and grouping methods

JwtConfig

JWT authentication configuration

Field Type Default Description
Secret string Secret key for JWT verification
Algorithm string serde(default = "default_jwt_algorithm") Required algorithm (HS256, HS384, HS512, RS256, etc.)
Audience List<string>? null Required audience claim
Issuer string? null Required issuer claim
Leeway ulong /* serde(default) */ Leeway for expiration checks (seconds)

LicenseInfo

License information

Field Type Default Description
Name string SPDX license identifier or display name (e.g. "MIT").
Url string? null URL to the full license text.

OpenApiConfig

OpenAPI configuration

Field Type Default Description
Enabled bool false Enable OpenAPI generation (default: false for zero overhead)
Title string "API" API title
Version string "1.0.0" API version
Description string? null API description (supports markdown)
SwaggerUiPath string Path to serve Swagger UI (default: "/docs")
RedocPath string Path to serve Redoc (default: "/redoc")
OpenapiJsonPath string Path to serve OpenAPI JSON spec (default: "/openapi.json")
Contact ContactInfo? null Contact information
License LicenseInfo? null License information
Servers List<ServerInfo> new List<ServerInfo>() Server definitions
SecuritySchemes Dictionary<string, SecuritySchemeInfo> new Dictionary<string, SecuritySchemeInfo>() Security schemes (auto-detected from middleware if not provided)
Methods
CreateDefault()

Signature:

public OpenApiConfig CreateDefault()

Example:

var result = OpenApiConfig.CreateDefault();

Returns: OpenApiConfig


ParseRequest

Request body for POST /asyncapi/parse

Field Type Default Description
Spec object Spec

ParseResult

Full parse result returned by POST /asyncapi/parse

Field Type Default Description
SpecVersion string Spec version
Title string Title
ApiVersion string Api version
Channels List<ParsedChannel> Channels
Operations List<ParsedOperation> Operations
Messages List<ParsedMessage> Messages

ParsedChannel

A single channel extracted from an AsyncAPI spec

Field Type Default Description
Name string Channel key from the spec (e.g. "chat/messages")
Address string Channel address / path
Messages List<string> Message names declared on this channel
Bindings object? null Bindings (ws / http / amqp / …) as raw JSON for forward-compatibility

ParsedMessage

A resolved message (name + JSON Schema)

Field Type Default Description
Name string Message name
Schema object? null Resolved JSON Schema for the message payload, if available

ParsedOperation

A single operation extracted from an AsyncAPI spec

Field Type Default Description
Name string Operation name
Action string Operation action: "send" or "receive"
Channel string Channel reference (resolved to the channel name)

ProblemDetails

RFC 9457 Problem Details for HTTP APIs

A machine-readable format for specifying errors in HTTP API responses. Per RFC 9457, all fields are optional. The type field defaults to "about:blank" if not specified.

Content-Type

Responses using this struct should set:

Content-Type: application/problem+json
{
  "type": "<https://spikard.dev/errors/validation-error",>
  "title": "Request Validation Failed",
  "status": 422,
  "detail": "2 validation errors in request body",
  "errors": [...]
}
Field Type Default Description
TypeUri string A URI reference that identifies the problem type. Defaults to "about:blank" when absent. Should be a stable, human-readable identifier for the problem type.
Title string A short, human-readable summary of the problem type. Should not change from occurrence to occurrence of the problem.
Status ushort The HTTP status code generated by the origin server. This is advisory; the actual HTTP status code takes precedence.
Detail string? null A human-readable explanation specific to this occurrence of the problem.
Instance string? null A URI reference that identifies the specific occurrence of the problem. It may or may not yield further information if dereferenced.
Extensions Dictionary<string, object> Extension members - problem-type-specific data. For validation errors, this typically contains an "errors" array.
Methods
WithDetail()

Set the detail field

Signature:

public ProblemDetails WithDetail(string detail)

Example:

var result = instance.WithDetail("value");

Parameters:

Name Type Required Description
Detail string Yes The detail

Returns: ProblemDetails

WithInstance()

Set the instance field

Signature:

public ProblemDetails WithInstance(string instance)

Example:

var result = instance.WithInstance("value");

Parameters:

Name Type Required Description
Instance string Yes The instance

Returns: ProblemDetails

NotFound()

Create a not found error

Signature:

public ProblemDetails NotFound(string detail)

Example:

var result = ProblemDetails.NotFound("value");

Parameters:

Name Type Required Description
Detail string Yes The detail

Returns: ProblemDetails

MethodNotAllowed()

Create a method not allowed error

Signature:

public ProblemDetails MethodNotAllowed(string detail)

Example:

var result = ProblemDetails.MethodNotAllowed("value");

Parameters:

Name Type Required Description
Detail string Yes The detail

Returns: ProblemDetails

InternalServerError()

Create an internal server error

Signature:

public ProblemDetails InternalServerError(string detail)

Example:

var result = ProblemDetails.InternalServerError("value");

Parameters:

Name Type Required Description
Detail string Yes The detail

Returns: ProblemDetails

BadRequest()

Create a bad request error

Signature:

public ProblemDetails BadRequest(string detail)

Example:

var result = ProblemDetails.BadRequest("value");

Parameters:

Name Type Required Description
Detail string Yes The detail

Returns: ProblemDetails

ToJson()

Serialize to JSON string

Errors: Returns an error if the serialization fails.

Signature:

public string ToJson()

Example:

var result = instance.ToJson();

Returns: string

Errors: Throws Error.

ToJsonPretty()

Serialize to pretty JSON string

Errors: Returns an error if the serialization fails.

Signature:

public string ToJsonPretty()

Example:

var result = instance.ToJsonPretty();

Returns: string

Errors: Throws Error.


QueryMutationConfig

Configuration for schemas with Query and Mutation types

Field Type Default Description
IntrospectionEnabled bool true Enable introspection queries
ComplexityLimit nuint? null Maximum query complexity (None = unlimited)
DepthLimit nuint? null Maximum query depth (None = unlimited)
Methods
CreateDefault()

Signature:

public QueryMutationConfig CreateDefault()

Example:

var result = QueryMutationConfig.CreateDefault();

Returns: QueryMutationConfig


QueryOnlyConfig

Configuration for schemas with only Query type

Field Type Default Description
IntrospectionEnabled bool true Enable introspection queries
ComplexityLimit nuint? null Maximum query complexity (None = unlimited)
DepthLimit nuint? null Maximum query depth (None = unlimited)
Methods
CreateDefault()

Signature:

public QueryOnlyConfig CreateDefault()

Example:

var result = QueryOnlyConfig.CreateDefault();

Returns: QueryOnlyConfig


RateLimitConfig

Rate limiting configuration shared across runtimes

Field Type Default Description
PerSecond ulong 100 Requests per second
Burst uint 200 Burst allowance
IpBased bool true Use IP-based rate limiting
Methods
CreateDefault()

Signature:

public RateLimitConfig CreateDefault()

Example:

var result = RateLimitConfig.CreateDefault();

Returns: RateLimitConfig


Request


Response

HTTP Response with custom status code, headers, and content

Field Type Default Description
Content object? null Response body content
StatusCode ushort HTTP status code (defaults to 200)
Headers Dictionary<string, string> new Dictionary<string, string>() Response headers
Methods
SetHeader()

Set a header

Signature:

public void SetHeader(string key, string value)

Example:

instance.SetHeader("value", "value");

Parameters:

Name Type Required Description
Key string Yes The key
Value string Yes The value

Returns: No return value.

SetCookie()

Set a cookie in the response

Signature:

public void SetCookie(string key, string value, bool secure, bool httpOnly, long maxAge, string domain, string path, string sameSite)

Example:

instance.SetCookie("value", "value", true, true, 42, "value", "value", "value");

Parameters:

Name Type Required Description
Key string Yes The key
Value string Yes The value
Secure bool Yes The secure
HttpOnly bool Yes The http only
MaxAge long? No The max age
Domain string? No The domain
Path string? No Path to the file
SameSite string? No The same site

Returns: No return value.

CreateDefault()

Signature:

public Response CreateDefault()

Example:

var result = Response.CreateDefault();

Returns: Response


RouteBuilder

Builder for defining a route.

Methods
New()

Create a new builder for the provided HTTP method and path.

Signature:

public RouteBuilder New(Method method, string path)

Example:

var result = RouteBuilder.New(new Method(), "value");

Parameters:

Name Type Required Description
Method Method Yes The method
Path string Yes Path to the file

Returns: RouteBuilder

HandlerName()

Assign an explicit handler name.

Signature:

public RouteBuilder HandlerName(string name)

Example:

var result = instance.HandlerName("value");

Parameters:

Name Type Required Description
Name string Yes The name

Returns: RouteBuilder

RequestSchemaJson()

Provide a raw JSON schema for the request body.

Signature:

public RouteBuilder RequestSchemaJson(object schema)

Example:

var result = instance.RequestSchemaJson(new Dictionary<string, object>());

Parameters:

Name Type Required Description
Schema object Yes The schema

Returns: RouteBuilder

ResponseSchemaJson()

Provide a raw JSON schema for the response body.

Signature:

public RouteBuilder ResponseSchemaJson(object schema)

Example:

var result = instance.ResponseSchemaJson(new Dictionary<string, object>());

Parameters:

Name Type Required Description
Schema object Yes The schema

Returns: RouteBuilder

ParamsSchemaJson()

Provide a raw JSON schema for request parameters.

Signature:

public RouteBuilder ParamsSchemaJson(object schema)

Example:

var result = instance.ParamsSchemaJson(new Dictionary<string, object>());

Parameters:

Name Type Required Description
Schema object Yes The schema

Returns: RouteBuilder

FileParamsJson()

Provide multipart file parameter configuration.

Signature:

public RouteBuilder FileParamsJson(object schema)

Example:

var result = instance.FileParamsJson(new Dictionary<string, object>());

Parameters:

Name Type Required Description
Schema object Yes The schema

Returns: RouteBuilder

Cors()

Attach a CORS configuration for this route.

Signature:

public RouteBuilder Cors(CorsConfig cors)

Example:

var result = instance.Cors(new CorsConfig());

Parameters:

Name Type Required Description
Cors CorsConfig Yes The cors config

Returns: RouteBuilder

Compression()

Attach a compression configuration for this route.

Signature:

public RouteBuilder Compression(CompressionConfig compression)

Example:

var result = instance.Compression(new CompressionConfig());

Parameters:

Name Type Required Description
Compression CompressionConfig Yes The compression config

Returns: RouteBuilder

BodyLimit()

Attach a per-route maximum request body size in bytes, overriding the server-global default.

Signature:

public RouteBuilder BodyLimit(nuint maxBytes)

Example:

var result = instance.BodyLimit(42);

Parameters:

Name Type Required Description
MaxBytes nuint Yes The max bytes

Returns: RouteBuilder

RequestTimeout()

Attach a per-route request timeout in seconds, overriding the server-global default.

Signature:

public RouteBuilder RequestTimeout(ulong seconds)

Example:

var result = instance.RequestTimeout(42);

Parameters:

Name Type Required Description
Seconds ulong Yes The seconds

Returns: RouteBuilder

Sync()

Mark the route as synchronous.

Signature:

public RouteBuilder Sync()

Example:

var result = instance.Sync();

Returns: RouteBuilder

HandlerDependencies()

Declare the dependency keys that must be resolved before this handler runs.

Signature:

public RouteBuilder HandlerDependencies(List<string> dependencies)

Example:

var result = instance.HandlerDependencies(new List<object>());

Parameters:

Name Type Required Description
Dependencies List<string> Yes The dependencies

Returns: RouteBuilder


SchemaConfig

Configuration for GraphQL schema building.

Encapsulates all schema-level configuration options including introspection control, complexity limits, and depth limits.

Field Type Default Description
IntrospectionEnabled bool true Enable introspection queries
ComplexityLimit nuint? null Maximum query complexity (None = unlimited)
DepthLimit nuint? null Maximum query depth (None = unlimited)
Methods
CreateDefault()

Signature:

public SchemaConfig CreateDefault()

Example:

var result = SchemaConfig.CreateDefault();

Returns: SchemaConfig


ServerConfig

Server configuration

Field Type Default Description
Host string "127.0.0.1" Host to bind to
Port ushort 8000 Port to bind to
Workers nuint 1 Number of Tokio runtime worker threads used by binding-managed server runtimes
EnableRequestId bool false Enable request ID generation and propagation
MaxBodySize nuint? 10485760 Maximum request body size in bytes (None = unlimited, not recommended)
RequestTimeout ulong? null Request timeout in seconds (None = no timeout)
Compression CompressionConfig? null Enable compression middleware
RateLimit RateLimitConfig? null Enable rate limiting
JwtAuth JwtConfig? null JWT authentication configuration
ApiKeyAuth ApiKeyConfig? null API Key authentication configuration
StaticFiles List<StaticFilesConfig> new List<StaticFilesConfig>() Static file serving configuration
GracefulShutdown bool true Enable graceful shutdown on SIGTERM/SIGINT
ShutdownTimeout ulong 30 Graceful shutdown timeout (seconds)
Asyncapi AsyncApiConfig? null AsyncAPI HTTP endpoint configuration
Openapi OpenApiConfig? null OpenAPI documentation configuration
Jsonrpc JsonRpcConfig? null JSON-RPC configuration
Grpc GrpcConfig? null gRPC configuration
BackgroundTasks BackgroundTaskConfig Background task executor configuration
EnableHttpTrace bool false Enable per-request HTTP tracing (tower-http TraceLayer)
Methods
CreateDefault()

Signature:

public ServerConfig CreateDefault()

Example:

var result = ServerConfig.CreateDefault();

Returns: ServerConfig


ServerInfo

Server information

Field Type Default Description
Url string Base URL of the server (e.g. "<https://api.example.com/v1">).
Description string? null Optional human-readable description of the server environment.

SseEvent

An individual SSE event

Represents a single Server-Sent Event to be sent to a connected client. Events can have an optional type, ID, and retry timeout for advanced scenarios.

SSE Format

Events are serialized to the following text format:

event: event_type
data: {"json":"value"}
id: event-123
retry: 3000
Field Type Default Description
EventType string? null Event type (optional)
Data object Event data (JSON value)
Id string? null Event ID (optional, for client-side reconnection)
Retry ulong? null Retry timeout in milliseconds (optional)
Methods
WithId()

Set the event ID for client-side reconnection support

Sets an ID that clients can use to resume from this point if they disconnect. The client sends this ID back in the Last-Event-ID header when reconnecting.

Signature:

public SseEvent WithId(string id)

Example:

var result = instance.WithId("value");

Parameters:

Name Type Required Description
Id string Yes Unique identifier for this event

Returns: SseEvent

WithRetry()

Set the retry timeout for client reconnection

Sets the time in milliseconds clients should wait before attempting to reconnect if the connection is lost. The client browser will automatically handle reconnection.

Signature:

public SseEvent WithRetry(ulong retryMs)

Example:

var result = instance.WithRetry(42);

Parameters:

Name Type Required Description
RetryMs ulong Yes Retry timeout in milliseconds

Returns: SseEvent


StaticFilesConfig

Static file serving configuration

Field Type Default Description
Directory string Directory path to serve
RoutePrefix string URL path prefix (e.g., "/static")
IndexFile bool serde(default = "default_true") Fallback to index.html for directories
CacheControl string? null Cache-Control header value

TestingSseEvent

A single Server-Sent Event.

Field Type Default Description
Data string The data field of the event.

UploadFile

Represents an uploaded file from multipart/form-data requests.

This struct provides efficient access to file content with automatic base64 decoding and implements standard I/O traits for compatibility.

Field Type Default Description
Filename string Original filename from the client
ContentType string? null MIME type of the uploaded file
Size nuint? null Size of the file in bytes
Content byte\[\] File content (may be base64 encoded)
ContentEncoding string? null Content encoding type
Methods
AsBytes()

Get the raw file content as bytes.

This provides zero-copy access to the underlying buffer.

Signature:

public byte[] AsBytes()

Example:

var result = instance.AsBytes();

Returns: byte[]

ReadToString()

Read the file content as a UTF-8 string.

Errors:

Returns an error if the content is not valid UTF-8.

Signature:

public string ReadToString()

Example:

var result = instance.ReadToString();

Returns: string

Errors: Throws Error.

ContentTypeOrDefault()

Get the content type, defaulting to "application/octet-stream".

Signature:

public string ContentTypeOrDefault()

Example:

var result = instance.ContentTypeOrDefault();

Returns: string


ValidateRequest

Request body for POST /asyncapi/validate

Field Type Default Description
Spec object Spec
Channel string Channel
Message string Message
Payload object Payload

ValidationResponse

Response body for POST /asyncapi/validate

Field Type Default Description
Valid bool Valid
Errors List<string> Errors

Enums

Method

HTTP method

Value Description
Get Get
Post Post
Put Put
Patch Patch
Delete Delete
Head Head
Options Options
Connect Connect
Trace Trace

SecuritySchemeInfo

Security scheme types

Value Description
Http Http — Fields: Scheme: string, BearerFormat: string
ApiKey Api key — Fields: Location: string, Name: string

Errors

AppError

Error type for application builder operations.

Variant Description
Route Route registration failed.
Server Server/router construction failed.
Decode Failed to extract DTO from the request context.
GraphQl GraphQL route registration failed (e.g. an unrecognized schema_type).

GraphQlError

Errors that can occur during GraphQL operations

These errors are compatible with async-graphql error handling and can be converted to structured HTTP responses matching the project's error fixtures.

Variant Description
ExecutionError Error during schema execution Occurs when the GraphQL executor encounters a runtime error during query execution.
SchemaBuildError Error during schema building Occurs when schema construction fails due to invalid definitions or conflicts.
RequestHandlingError Error during request handling Occurs when the HTTP request cannot be properly handled or parsed.
SerializationError Serialization error Occurs during JSON serialization/deserialization of GraphQL values.
JsonError JSON parsing error Occurs when JSON input cannot be parsed.
ValidationError GraphQL validation error Occurs when a GraphQL query fails schema validation.
ParseError GraphQL parse error Occurs when the GraphQL query string cannot be parsed.
AuthenticationError Authentication error Occurs when request authentication fails.
AuthorizationError Authorization error Occurs when user lacks required permissions.
NotFound Not found error Occurs when a requested resource is not found.
RateLimitExceeded Rate limit error Occurs when rate limit is exceeded.
InvalidInput Invalid input error with validation details Occurs during input validation with detailed error information.
ComplexityLimitExceeded Query complexity limit exceeded Occurs when a GraphQL query exceeds the configured complexity limit.
DepthLimitExceeded Query depth limit exceeded Occurs when a GraphQL query exceeds the configured depth limit.
IntrospectionDisabled Introspection query rejected because introspection is disabled Occurs when a query selects __schema or __type while the schema was configured with introspection disabled.
InternalError Internal server error Occurs when an unexpected internal error happens.

SchemaError

Error type for schema building operations

Variant Description
BuildingFailed Generic schema building error
ValidationError Configuration validation error
ComplexityLimitExceeded Complexity limit exceeded
DepthLimitExceeded Depth limit exceeded

Edit this page on GitHub