struct Koa

Defined in:

koa.cr
koa/global.cr
koa/route.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new #

[View source]

Class Method Detail

def self.array(name : String, type : String, *, desc : String | Nil = nil) #

Defines an array schema


[View source]
def self.auth(key : String) #

Adds a registered authentication method to the succeeding route.


[View source]
def self.auth(keys : Array(String)) #

Sets the list of authentication methods of the succeeding route.


[View source]
def self.basic_auth(key : String) #

Adds a Basic authentication method.


[View source]
def self.bearer_auth(key : String, format : String) #

Adds a Bearer authentication method.


[View source]
def self.binary(name : String, *, desc : String | Nil = nil) #

Defines a binary schema


[View source]
def self.body(*, type = "application/json", required = true, desc : String | Nil = nil, ref : String | Nil = nil) #

Specifies the required request body of the succeeding route.


[View source]
def self.cookie(name : String, *, desc : String | Nil = nil, required = true, type : String = "string", low_priority = false) #

Adds a cookie parameter to the succeeding route.


[View source]
def self.cookie_auth(key : String, name : String) #

Adds a API Key authentication method.


[View source]
def self.delete(path : String) #

Registers a delete route.

This method will be invoked by the monkey-patched Kemal, and you don't need to call it manually.


[View source]
def self.describe(summary : String, desc : String | Nil = nil) #

Sets summary and description (optional) of the succeeding route.


[View source]
def self.generate : OpenAPI::Document | Nil #

Generates an instance of OpenAPI::Document that contains the API specification.

You can get the YAML or JSON representation using to_yaml or to_json


[View source]
def self.get(path : String) #

Registers a get route.

This method will be invoked by the monkey-patched Kemal, and you don't need to call it manually.


[View source]
def self.global_tag(name : String, *, desc : String | Nil = nil) #

[View source]
def self.header(name : String, *, desc : String | Nil = nil, required = true, type : String = "string", low_priority = false) #

Adds a header parameter to the succeeding route.


[View source]
def self.init(title : String, *, desc : String | Nil = nil, version = "1.0.0") #

Initializes Koa and sets the Info object of the API.


[View source]
def self.object(name : String, schema : Hash(String, String), *, desc : String | Nil = nil) #

Defines an object schema


[View source]
def self.options(path : String) #

Registers a options route.

This method will be invoked by the monkey-patched Kemal, and you don't need to call it manually.


[View source]
def self.patch(path : String) #

Registers a patch route.

This method will be invoked by the monkey-patched Kemal, and you don't need to call it manually.


[View source]
def self.path(name : String, *, desc : String | Nil = nil, required = true, type : String = "string", low_priority = false) #

Adds a path parameter to the succeeding route.


[View source]
def self.post(path : String) #

Registers a post route.

This method will be invoked by the monkey-patched Kemal, and you don't need to call it manually.


[View source]
def self.put(path : String) #

Registers a put route.

This method will be invoked by the monkey-patched Kemal, and you don't need to call it manually.


[View source]
def self.query(name : String, *, desc : String | Nil = nil, required = true, type : String = "string", low_priority = false) #

Adds a query parameter to the succeeding route.


[View source]
def self.response(status : UInt32, desc : String = "OK", *, ref : String | Nil = nil, media_type = "application/json") #

Adds a response to the succeeding route.

The response {"200" => "OK"} is automatically added, and you can overwrite it with Koa.response "200", "New description".


[View source]
def self.server(url : String, desc : String | Nil = nil) #

Adds a server to the server list.


[View source]
def self.tag(tag : String) #

Adds a tag to the succeeding route.


[View source]
def self.tags(tags : Array(String)) #

Sets the tags of the succeeding route.


[View source]

Instance Method Detail

def initialize #

[View source]