Skip to content

Multiplatform Ktor schema declarationopensavvy.spine.api

Package-level declarations

Types

Addressed

interface Addressed

An object that has a Path.

AnyEndpoint

sealed interface AnyEndpoint

A specific HTTP method in a resource.

DynamicResource

abstract class DynamicResource<Parent : Resource>(slug: String, val parent: Parent) : Resource

A resource with a wildcard segment: v1/users/{user}, v1/posts/{post}/subscribers/{user}.

FailureCompanion

abstract class FailureCompanion<F>(val statusCode: HttpStatusCode) : FailureSpec.ByCode<F> 

Helper to bind a statusCode to a given error class.

FailureSpec

sealed interface FailureSpec

Declares the different ways an endpoint can fail.

ParameterConstructor

Factory function that builds a Parameters subtype backed by a ParameterStorage.

Parameters

abstract class Parameters(val data: ParameterStorage = HashMap())

Additional parameters for endpoints.

ParameterStorage

Underlying storage for Parameters: a mutable map of parameter names to their raw string values.

Path

class Path(val segments: List<Path.Segment>) : Iterable<Path.Segment> , Addressed

The path section in a URL.

ResolvedEndpoint

A resolved Endpoint.

ResolvedResource

A resolved Resource.

Resource

sealed class Resource

Common parent for all resource types.

RootResource

abstract class RootResource(slug: String) : Resource, Addressed

The root resource of an API.

StaticResource

abstract class StaticResource<Parent : Resource>(slug: String, val parent: Parent) : Resource

A resource with a hard-coded segment: v1/users, v1/posts/favorites.

Properties

endpoints

Returns all endpoints that are declared on this resource or any of its children.

fullSlug

The complete URL for this endpoint, starting at its RootResource.

The complete URL of this resource, starting from the RootResource, to this resource.

hierarchy

Returns the hierarchy of this resource: following the parent chain.

resolved

Constructs a ResolvedResource out of a RootResource.

Functions

buildParameters

fun <P : Parameters> buildParameters(construct: ParameterConstructor<P>, block: P.() -> Unit): P

Creates and configures a Parameters instance.

div

Starts resolution from the RootResource and resolves the static child.

Starts resolution from the RootResource and resolves the dynamic child.

Resolves an endpoint declared in a resolved resource.

Resolves the static child resource under this ResolvedResource.

Resolves the dynamic child resource under this ResolvedResource by binding its identifier.

getValue

inline operator fun <T> Parameters.Parameter<T>.getValue(thisRef: Parameters, property: KProperty<*>): T

Internal method used by the parameter declaration syntax.

invoke

Binds a specific identifier into a DynamicResource's slug.

provideDelegate

inline operator fun <T> Parameters.UnnamedParameter<T>.provideDelegate(thisRef: Parameters, property: KProperty<*>): Parameters.Parameter<T>

Internal method used by the parameter declaration syntax.

setValue

inline operator fun <T> Parameters.Parameter<T>.setValue(thisRef: Parameters, property: KProperty<*>, value: T)

Internal method used by the parameter declaration syntax.