ricr

Web framework with buit-in automatic OpenAPI/Swagger docs support web swagger openapi
0.4.0 Latest release Yanked release released
ricr-web/ricr
16

This repo seems to be no longer available at ricr-web/ricr.

Git synchronization failed . Last successful sync was .

Help find it again! … or have it archived.

Ricr

Build Status Gitter ISC

An HTTP Router In Crystal, with automatic Swagger/OpenAPI API docs generation.

Features

The Ricr web framework emphasise on type safety. By defining expected types for requests and responses, it also provides documentation.

  • Safe by returning an error at startup if routes conflict
  • Automatic cast of requests and responses with defined types
  • Automatic Swagger/OpenAPI documentation generation
  • More type safety with less boilerplates
  • Performance (at least on par with other web frameworks)
  • Enforce standards (e.g. a HEAD route has no request body)
  • Simple, customizable and modular

Installation

Add the dependency to your shard.yml:

dependencies:
  ricr:
    github: ricr-web/ricr

Documentation

https://ricr-web.github.io/ricr

Usage

Simple web server serving "/":

require "ricr"

server = Ricr.new

server.controller.add do
  get "public" do
    "Hello!"
  end
  
  post request_body: String do |body|
    body
  end
end

# For testing URLs
spawn { server.start }
sleep 0.5

server.client.get("/public").body          # => "Hello!"
server.client.post("/", body: "hey!").body # => "hey!"

More examples in EXAMPLES.md.

Swagger/OpenAPI documentation generation

Add icyleaf/swagger to the dependencies:

dependencies:
  swagger:
    github: icyleaf/swagger

Run shards install

require "ricr"
require "ricr/docs"

server = Ricr.new
server.controller.docs_route
server.start

The API docs are now available at http://localhost:3000/docs.

License

Copyright (c) 2020 Julien Reichardt - ISC License

ricr:
  github: ricr-web/ricr
  version: ~> 0.4.0
License ISC
Crystal none

Authors

Dependencies 0

Development Dependencies 2

  • ameba
    {'github' => 'crystal-ameba/ameba'}
  • swagger
    {'github' => 'icyleaf/swagger'}

Dependents 0

Last synced .
search fire star recently