Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Sweet web apis with Compojure & Swagger

License

NotificationsYou must be signed in to change notification settings

metosin/compojure-api

Repository files navigation

Stuff on top ofCompojure for making sweet web apis.

Latest version

Clojars Project

For information and help

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).

Examples

Hello World

(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)})))

Api with Schema & Swagger-docs

(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))))

swagger-api

More samples

This repo containsa sample application.

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

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

Quick start for new project

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-test

License

Copyright © 2014-2015Metosin Oy

Distributed under the Eclipse Public License, the same as Clojure.


[8]ページ先頭

©2009-2025 Movatter.jp