- Notifications
You must be signed in to change notification settings - Fork147
Sweet web apis with Compojure & Swagger
License
metosin/compojure-api
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Stuff on top ofCompojure for making sweet web apis.
- API Docs
- Schema for input & output data coercion
- Swagger 2.0 for api documentation, viaring-swagger
- Extendable route DSL viametadata handlers
- Bi-directional routing
- Bundled middleware for common api behavior (exception mapping, data formats & serialization)
- Route macros for putting things together, including theSwagger-UI viaring-swagger-ui
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 (mentioncompojure-api orring-swagger to highlight us).
(nsexample (:require [compojure.api.sweet:refer:all] [ring.util.http-response:refer:all]))(defapiapp (GET*"/hello" []:query-params [name:- String] (ok {:message (str"Hello," name)})))
(nsexample (:require [compojure.api.sweet:refer:all] [ring.util.http-response:refer:all] [schema.core:as s]))(s/defschemaPizza {:name s/Str:size (s/enum:L:M:S):origin {:country (s/enum:FI:PO):city s/Str}})(defapiapp (swagger-ui) (swagger-docs {:info {:title"My Swagger API":description"Compojure Api example"}:tags [{:name"api",:description"sample api"}]}) (context*"/api" []:tags ["api"] (GET*"/hello" []:query-params [name:- String] (ok {:message (str"Hello," name)})) (POST*"/pizza" []:return Pizza:body [pizza Pizza]:summary"echoes a pizza" (ok pizza))))
This repo containsa sample application.
To try it yourself, clone this repository and do either:
lein runlein repl&(go)
Clone theexamples-repository.
Use a Leiningen template, with or without tests:
lein new compojure-api my-apilein new compojure-api my-api +midjelein new compojure-api my-api +clojure-testCopyright © 2014-2015Metosin Oy
Distributed under the Eclipse Public License, the same as Clojure.
About
Sweet web apis with Compojure & Swagger
Topics
Resources
License
Contributing
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
