Annotation based JSON API framework with built in param conversion

Annotation based JSON API web framework with built in param conversion inspired by Symfony Routing. Also supports form data and ECR rendering.


  • Extensible and customizable to fit all use cases
  • Make working with JSON APIs in Crystal much easier
  • Be easy to adopt and start using effectively
  • Remove unneeded boilerplate code to convert route/body params to correct type
  • Easy serialization via CrSerializer

Swagger - Swagger contains a OpenAPI / Swagger universal documentation generator and server handler.

Swagger is low-level library which generate output compatible with Swagger / OpenAPI Spec 3.0.1, and wrapped many friendly APIs let developer understand and use it easier.

builder =
  title: "Simple App API Demo",
  version: "1.0.0",
  description: "Simple App API Demo document written by Crystal",
  terms_url: "",
  license:"MIT", ""),
  contact:"icyleaf", "", "")

builder.add("User", "object", ["id", "integer", "int32", example: 1),"nickname", example: "icyleaf wang"),"username", example: "icyleaf"),"email", example: ""),"bio", "Personal bio"),

builder.add("Users", "User Resources", ["get", "/users", "List users", parameters: ["page", "query", "integer", "Current page", default_value: 1, format: "int32"),"limit", "query", "integer", "How many items to return at one time (max 100)", default_value: 50, format: "int32"),
  ]),"get", "/users/{id}", "Get user by id", parameters: ["id", "path")], responses: ["200", "Success response"),"404", "Not found user")
  ], request:"User")),"post", "/users", "Create user",
    request:["username", required: true, description: "The name of user"),"email", "string", required: true, description: "Email"),"gender", "integer", default_value: 0, description: "Man or Female"),"password", required: true, description: "Set your password"),"confirm_password", required: true, description: "Confirm password"),
    ], "Form data", "application/x-www-form-urlencoded"),
    responses: ["200", "Success response", "User"),"404", "Not found user")
  ),"get", "/user/{id}", "Get user by id", parameters: ["id", "path")], responses: ["200", "Success response"),"404", "Not found user")
  ], deprecated: true)

builder.add("{port}/{version}/api", "Development", ["port", "3000", ["3000"], "API port"),"version", "v2", ["v2", "v3"], description: "API version"),
builder.add("", "Production"))