{"id":13746109,"url":"https://github.com/metosin/compojure-api","last_synced_at":"2025-05-13T17:11:28.737Z","repository":{"id":49022793,"uuid":"15700966","full_name":"metosin/compojure-api","owner":"metosin","description":"Sweet web apis with Compojure \u0026 Swagger","archived":false,"fork":false,"pushed_at":"2024-11-04T20:35:42.000Z","size":3354,"stargazers_count":1119,"open_issues_count":55,"forks_count":150,"subscribers_count":35,"default_branch":"master","last_synced_at":"2025-05-03T00:03:42.683Z","etag":null,"topics":["api","async","clojure","clojure-spec","http","metosin-stable","openapi","rest","ring","schema","swagger"],"latest_commit_sha":null,"homepage":"http://metosin.github.io/compojure-api/doc/","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"epl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/metosin.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG-1.1.x.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-01-07T10:00:52.000Z","updated_at":"2025-04-17T22:30:08.000Z","dependencies_parsed_at":"2024-05-27T22:28:49.946Z","dependency_job_id":"dadd71f3-e7a3-46b1-8614-085bf47b7c8f","html_url":"https://github.com/metosin/compojure-api","commit_stats":{"total_commits":1808,"total_committers":54,"mean_commits":33.48148148148148,"dds":0.355641592920354,"last_synced_commit":"2facea002da916310dc3468b8a0f5c440761c31c"},"previous_names":[],"tags_count":97,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metosin%2Fcompojure-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metosin%2Fcompojure-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metosin%2Fcompojure-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metosin%2Fcompojure-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/metosin","download_url":"https://codeload.github.com/metosin/compojure-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253990470,"owners_count":21995774,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","async","clojure","clojure-spec","http","metosin-stable","openapi","rest","ring","schema","swagger"],"created_at":"2024-08-03T06:00:47.070Z","updated_at":"2025-05-13T17:11:23.726Z","avatar_url":"https://github.com/metosin.png","language":"Clojure","readme":"# Compojure-api\n\n**Psst!** If you're starting a new project, why not try out [reitit](https://github.com/metosin/reitit)?\n\nStuff on top of [Compojure](https://github.com/weavejester/compojure) for making sweet web apis.\n\n- [Schema](https://github.com/Prismatic/schema) \u0026 [clojure.spec](https://clojure.org/about/spec) (2.0.0) for input \u0026 output data coercion\n- [Swagger](http://swagger.io/) for api documentation, via [ring-swagger](https://github.com/metosin/ring-swagger) \u0026 [spec-tools](https://github.com/metosin/spec-tools)\n- [Async](https://github.com/metosin/compojure-api/wiki/Async) with async-ring, [manifold](https://github.com/ztellman/manifold) and [core.async](https://github.com/clojure/core.async) (2.0.0)\n- Client negotiable formats: [JSON](http://www.json.org/), [EDN](https://github.com/edn-format/edn) \u0026 [Transit](https://github.com/cognitect/transit-format), optionally [YAML](http://yaml.org/) and [MessagePack](http://msgpack.org/)\n- Data-driven [resources](https://github.com/metosin/compojure-api/wiki/Resources-and-Liberator)\n- [Bi-directional](https://github.com/metosin/compojure-api/wiki/Routing#bi-directional-routing) routing\n- Bundled middleware for common api behavior ([exception handling](https://github.com/metosin/compojure-api/wiki/Exception-handling), parameters \u0026 formats)\n- Extendable route DSL via [metadata handlers](https://github.com/metosin/compojure-api/wiki/Creating-your-own-metadata-handlers)\n- Route functions \u0026 macros for putting things together, including the [Swagger-UI](https://github.com/wordnik/swagger-ui) via [ring-swagger-ui](https://github.com/metosin/ring-swagger-ui)\n- Requires Clojure 1.9.0 \u0026 Java 1.8\n\n[API Docs](http://metosin.github.io/compojure-api/doc/) \u0026 [Wiki](https://github.com/metosin/compojure-api/wiki)\n\n## Latest version\n\n[![Clojars Project](http://clojars.org/metosin/compojure-api/latest-version.svg)](http://clojars.org/metosin/compojure-api)\n\nLatest non-alpha: `[metosin/compojure-api \"1.1.14\"]`.\n\nSee [CHANGELOG](https://github.com/metosin/compojure-api/blob/master/CHANGELOG.md) for details.\n\n## For information and help\n\n### [Read the Version 1.0 Blog Post](http://www.metosin.fi/blog/compojure-api-100/)\n\n### [Schema \u0026 Spec Coercion with 2.0.0](https://github.com/metosin/compojure-api/wiki/Coercion)\n\n### [Check wiki for documentation](https://github.com/metosin/compojure-api/wiki)\n\n[Clojurians slack](https://clojurians.slack.com/) ([join](http://clojurians.net/)) has a channel [#ring-swagger](https://clojurians.slack.com/messages/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).\n\n## Examples\n\n### Hello World Api\n\n```clj\n(require '[compojure.api.sweet :refer :all])\n(require '[ring.util.http-response :refer :all])\n\n(def app\n  (api\n    (GET \"/hello\" []\n      :query-params [name :- String]\n      (ok {:message (str \"Hello, \" name)}))))\n```\n\n### Hello World, async\n\n```clj\n(require '[compojure.api.sweet :refer :all])\n(require '[clojure.core.async :as a])\n\n(GET \"/hello-async\" []\n  :query-params [name :- String]\n  (a/go\n    (a/\u003c! (a/timeout 500))\n    (ok {:message (str \"Hello, \" name)})))\n```\n\n\u003csub\u003e* requires server to be run in [async mode](https://github.com/metosin/compojure-api/wiki/Async)\u003c/sub\u003e\n\n### Hello World, async \u0026 data-driven\n\n```clj\n(require '[compojure.api.sweet :refer :all])\n(require '[clojure.core.async :as a])\n(require '[schema.core :as s])\n\n(context \"/hello-async\" []\n  (resource\n    {:get\n     {:parameters {:query-params {:name String}}\n      :responses {200 {:schema {:message String}}\n                  404 {}\n                  500 {:schema s/Any}}\n      :handler (fn [{{:keys [name]} :query-params}]\n                 (a/go\n                   (a/\u003c! (a/timeout 500))\n                   (ok {:message (str \"Hello, \" name)})))}}))\n```\n\n\u003csub\u003e* Note that empty body responses can be specified with `{}` or `{:schema s/Any}`\n\n### Hello World, async, data-driven \u0026 clojure.spec\n\n```clj\n(require '[compojure.api.sweet :refer :all])\n(require '[clojure.core.async :as a])\n(require '[clojure.spec.alpha :as s])\n\n(s/def ::name string?)\n(s/def ::message string?)\n\n(context \"/hello-async\" []\n  (resource\n    {:coercion :spec\n     :get {:parameters {:query-params (s/keys :req-un [::name])}\n           :responses {200 {:schema (s/keys :req-un [::message])}}\n           :handler (fn [{{:keys [name]} :query-params}]\n                      (a/go\n                        (a/\u003c! (a/timeout 500))\n                        (ok {:message (str \"Hello, \" name)})))}}))\n```\n\n### Api with Schema \u0026 Swagger-docs\n\n```clj\n(require '[compojure.api.sweet :refer :all])\n(require '[schema.core :as s])\n\n(s/defschema Pizza\n  {:name s/Str\n   (s/optional-key :description) s/Str\n   :size (s/enum :L :M :S)\n   :origin {:country (s/enum :FI :PO)\n            :city s/Str}})\n\n(def app\n  (api\n    {:swagger\n     {:ui \"/api-docs\"\n      :spec \"/swagger.json\"\n      :data {:info {:title \"Sample API\"\n                    :description \"Compojure Api example\"}\n             :tags [{:name \"api\", :description \"some apis\"}]\n             :consumes [\"application/json\"]\n             :produces [\"application/json\"]}}}\n\n    (context \"/api\" []\n      :tags [\"api\"]\n\n      (GET \"/plus\" []\n        :return {:result Long}\n        :query-params [x :- Long, y :- Long]\n        :summary \"adds two numbers together\"\n        (ok {:result (+ x y)}))\n\n      (POST \"/echo\" []\n        :return Pizza\n        :body [pizza Pizza]\n        :summary \"echoes a Pizza\"\n        (ok pizza)))))\n```\n\n![swagger-api](https://raw.githubusercontent.com/wiki/metosin/compojure-api/swagger-api.png)\n\n## More samples\n\n* official samples: https://github.com/metosin/compojure-api/tree/master/examples\n* great full app: https://github.com/yogthos/memory-hole\n* 2.0.0 sample: https://github.com/metosin/c2\n* RESTful CRUD APIs Using Compojure-API and Toucan: https://www.demystifyfp.com/clojure/blog/restful-crud-apis-using-compojure-api-and-toucan-part-1/\n* clojurice, An opinionated starter app for full-stack web applications in Clojure: https://github.com/jarcane/clojurice\n* Web Development with Clojure, Second Edition: https://pragprog.com/book/dswdcloj2/web-development-with-clojure-second-edition\n\nTo try it yourself, clone this repository and do either:\n\n1. `lein run`\n2. `lein repl` \u0026 `(go)`\n\n## Quick start for a new project\n\nUse a Leiningen template, with or without tests:\n\n```\nlein new compojure-api my-api\nlein new compojure-api my-api +midje\nlein new compojure-api my-api +clojure-test\n```\n\n## License\n\nCopyright © 2014-2019 [Metosin Oy](http://www.metosin.fi) and contributors.\n\nDistributed under the Eclipse Public License, see `LICENSE`.\n","funding_links":[],"categories":["Clojure","server","Web Framework"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmetosin%2Fcompojure-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmetosin%2Fcompojure-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmetosin%2Fcompojure-api/lists"}