All Projects → metosin → Compojure Api

metosin / Compojure Api

Licence: epl-1.0
Sweet web apis with Compojure & Swagger

Programming Languages

clojure
4091 projects
ring
36 projects

Projects that are alternatives of or similar to Compojure Api

Flama
🔥 Fire up your API with this flamethrower
Stars: ✭ 161 (-84.75%)
Mutual labels:  api, rest, swagger, openapi, schema
Fastapi
FastAPI framework, high performance, easy to learn, fast to code, ready for production
Stars: ✭ 39,588 (+3648.86%)
Mutual labels:  api, rest, swagger, openapi, async
Js Client
A Open-API derived JS + Node.js API client for Netlify
Stars: ✭ 170 (-83.9%)
Mutual labels:  api, rest, swagger, openapi
Goa
Design-based APIs and microservices in Go
Stars: ✭ 4,493 (+325.47%)
Mutual labels:  api, rest, swagger, openapi
Loopback Next
LoopBack makes it easy to build modern API applications that require complex integrations.
Stars: ✭ 3,972 (+276.14%)
Mutual labels:  api, rest, swagger, openapi
Proteus
Lean, mean, and incredibly fast JVM framework for web and microservice development.
Stars: ✭ 178 (-83.14%)
Mutual labels:  api, rest, swagger, openapi
Hapi Openapi
Build design-driven apis with OpenAPI (formerly swagger) 2.0 and hapi.
Stars: ✭ 196 (-81.44%)
Mutual labels:  api, rest, swagger, openapi
Fastapi Gino Arq Uvicorn
High-performance Async REST API, in Python. FastAPI + GINO + Arq + Uvicorn (w/ Redis and PostgreSQL).
Stars: ✭ 204 (-80.68%)
Mutual labels:  api, rest, swagger, async
Mockoon
Mockoon is the easiest and quickest way to run mock APIs locally. No remote deployment, no account required, open source.
Stars: ✭ 3,448 (+226.52%)
Mutual labels:  api, rest, swagger, openapi
Swagger Ui
Swagger UI is a collection of HTML, JavaScript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API.
Stars: ✭ 21,279 (+1915.06%)
Mutual labels:  rest, swagger, openapi
Swagger Parser
Swagger Spec to Java POJOs
Stars: ✭ 468 (-55.68%)
Mutual labels:  rest, swagger, openapi
Oas Kit
Convert Swagger 2.0 definitions to OpenAPI 3.0 and resolve/validate/lint
Stars: ✭ 516 (-51.14%)
Mutual labels:  api, swagger, openapi
Koa Rest Api Boilerplate
💯 Boilerplate for Node.js Koa RESTful API application with Docker, Swagger, Jest, CodeCov and CircleCI
Stars: ✭ 420 (-60.23%)
Mutual labels:  api, rest, swagger
Awesome Openapi3
😎 A list of awesome projects related to OpenAPI 3.0.x, curated by the community
Stars: ✭ 469 (-55.59%)
Mutual labels:  api, swagger, openapi
Dredd
Language-agnostic HTTP API Testing Tool
Stars: ✭ 3,770 (+257.01%)
Mutual labels:  api, swagger, openapi
Kin Openapi
OpenAPI 3.0 implementation for Go (parsing, converting, validation, and more)
Stars: ✭ 776 (-26.52%)
Mutual labels:  api, swagger, openapi
Parallec
Fast Parallel Async HTTP/SSH/TCP/UDP/Ping Client Java Library. Aggregate 100,000 APIs & send anywhere in 20 lines of code. Ping/HTTP Calls 8000 servers in 12 seconds. (Akka) www.parallec.io
Stars: ✭ 777 (-26.42%)
Mutual labels:  api, rest, async
Swagger Stats
API Observability. Trace API calls and Monitor API performance, health and usage statistics in Node.js Microservices.
Stars: ✭ 559 (-47.06%)
Mutual labels:  api, rest, swagger
Flask Restx
Fork of Flask-RESTPlus: Fully featured framework for fast, easy and documented API development with Flask
Stars: ✭ 1,050 (-0.57%)
Mutual labels:  api, rest, swagger
Swagger Core
Examples and server integrations for generating the Swagger API Specification, which enables easy access to your REST API
Stars: ✭ 6,898 (+553.22%)
Mutual labels:  rest, swagger, openapi

Compojure-api Build Status

Psst! If you're starting a new project, why not try out reitit?

Stuff on top of Compojure for making sweet web apis.

API Docs & Wiki

Latest version

Clojars Project

Latest non-alpha: [metosin/compojure-api "1.1.13"].

See CHANGELOG for details.

For information and help

Read the Version 1.0 Blog Post

Schema & Spec Coercion with 2.0.0

Check wiki for documentation

Clojurians slack (join) has a channel #ring-swagger for talk about any libraries using Ring-swagger. You can also ask questions about Compojure-api and Ring-swagger on other channels at Clojurians Slack or at #clojure on Freenode IRC (mention compojure-api or ring-swagger to highlight us).

Examples

Hello World Api

(require '[compojure.api.sweet :refer :all])
(require '[ring.util.http-response :refer :all])

(def app
  (api
    (GET "/hello" []
      :query-params [name :- String]
      (ok {:message (str "Hello, " name)}))))

Hello World, async

(require '[compojure.api.sweet :refer :all])
(require '[clojure.core.async :as a])

(GET "/hello-async" []
  :query-params [name :- String]
  (a/go
    (a/<! (a/timeout 500))
    (ok {:message (str "Hello, " name)})))

* requires server to be run in async mode

Hello World, async & data-driven

(require '[compojure.api.sweet :refer :all])
(require '[clojure.core.async :as a])
(require '[schema.core :as s])

(context "/hello-async" []
  (resource
    {:get
     {:parameters {:query-params {:name String}}
      :responses {200 {:schema {:message String}}
                  404 {}
                  500 {:schema s/Any}}
      :handler (fn [{{:keys [name]} :query-params}]
                 (a/go
                   (a/<! (a/timeout 500))
                   (ok {:message (str "Hello, " name)})))}}))

* Note that empty body responses can be specified with {} or {:schema s/Any}

Hello World, async, data-driven & clojure.spec

(require '[compojure.api.sweet :refer :all])
(require '[clojure.core.async :as a])
(require '[clojure.spec.alpha :as s])

(s/def ::name string?)
(s/def ::message string?)

(context "/hello-async" []
  (resource
    {:coercion :spec
     :get {:parameters {:query-params (s/keys :req-un [::name])}
           :responses {200 {:schema (s/keys :req-un [::message])}}
           :handler (fn [{{:keys [name]} :query-params}]
                      (a/go
                        (a/<! (a/timeout 500))
                        (ok {:message (str "Hello, " name)})))}}))

Api with Schema & Swagger-docs

(require '[compojure.api.sweet :refer :all])
(require '[schema.core :as s])

(s/defschema Pizza
  {:name s/Str
   (s/optional-key :description) s/Str
   :size (s/enum :L :M :S)
   :origin {:country (s/enum :FI :PO)
            :city s/Str}})

(def app
  (api
    {:swagger
     {:ui "/api-docs"
      :spec "/swagger.json"
      :data {:info {:title "Sample API"
                    :description "Compojure Api example"}
             :tags [{:name "api", :description "some apis"}]
             :consumes ["application/json"]
             :produces ["application/json"]}}}

    (context "/api" []
      :tags ["api"]

      (GET "/plus" []
        :return {:result Long}
        :query-params [x :- Long, y :- Long]
        :summary "adds two numbers together"
        (ok {:result (+ x y)}))

      (POST "/echo" []
        :return Pizza
        :body [pizza Pizza]
        :summary "echoes a Pizza"
        (ok pizza)))))

swagger-api

More samples

To try it yourself, clone this repository and do either:

  1. lein run
  2. lein repl & (go)

Quick start for a new project

Use a Leiningen template, with or without tests:

lein new compojure-api my-api
lein new compojure-api my-api +midje
lein new compojure-api my-api +clojure-test

License

Copyright © 2014-2019 Metosin Oy and contributors.

Distributed under the Eclipse Public License, see LICENSE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].