Multiplatform Ktor schema declaration • opensavvy.spine.api
Package-level declarations¶
Types¶
Addressed¶
interface Addressed
An object that has a Path.
AnyEndpoint¶
sealed interface AnyEndpoint
DynamicResource¶
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¶
typealias ParameterConstructor<P> = (ParameterStorage) -> P
Factory function that builds a Parameters subtype backed by a ParameterStorage.
Parameters¶
abstract class Parameters(val data: ParameterStorage = HashMap())
Additional parameters for endpoints.
ParameterStorage¶
typealias ParameterStorage = MutableMap<String, String>
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¶
class ResolvedEndpoint<E : AnyEndpoint> : Addressed
A resolved Endpoint.
ResolvedResource¶
class ResolvedResource<R : Resource> : Addressed
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¶
A resource with a hard-coded segment: v1/users, v1/posts/favorites.
Properties¶
endpoints¶
val Resource.endpoints: Sequence<AnyEndpoint>
Returns all endpoints that are declared on this resource or any of its children.
fullSlug¶
val AnyEndpoint.fullSlug: String
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¶
val <R : RootResource> R.resolved: ResolvedResource<R>
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¶
operator fun <Root : RootResource, Child : StaticResource<Root>> Root.div(child: Child): ResolvedResource<Child>
Starts resolution from the RootResource and resolves the static child.
operator fun <Root : RootResource, Child : DynamicResource<Root>> Root.div(child: DynamicResource.Identified<Root, Child>): ResolvedResource<Child>
Starts resolution from the RootResource and resolves the dynamic child.
operator fun <R : Resource, Endpoint : AnyEndpoint> ResolvedResource<R>.div(endpoint: Endpoint): ResolvedEndpoint<Endpoint>
Resolves an endpoint declared in a resolved resource.
operator fun <Current : Resource, Child : StaticResource<Current>> ResolvedResource<Current>.div(child: Child): ResolvedResource<Child>
Resolves the static child resource under this ResolvedResource.
operator fun <Current : Resource, Child : DynamicResource<Current>> ResolvedResource<Current>.div(child: DynamicResource.Identified<Current, Child>): ResolvedResource<Child>
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.