- BREAKING: Drop support for Java 6, Java 7.
- Support Java 13.
- Update dependencies.
Maintenance release, adding several patches from 2.0 branch.
- Backport: Fix context child resolution with compojure-bindings #370
- Backport: merge-vector #311
- Backport: Fix metadata position on defmacro to activate CIDER indent style #261
-
BREAKING: in
compojure.api.swagger, theswagger-uiandswagger-docsnow take options map withpathkey instead of separate optional path & vararg opts.- normally you would use swagger api-options or
swagger-routesand thus be unaffected of this.
- normally you would use swagger api-options or
-
updated dependencies:
[prismatic/plumbing "0.5.4"] is available but we use "0.5.3"
[compojure "1.6.0"] is available but we use "1.5.2"
[prismatic/schema "1.1.6"] is available but we use "1.1.3"
[ring-middleware-format "0.7.2"] is available but we use "0.7.0"
[metosin/ring-http-response "0.9.0"] is available but we use "0.8.1"
[metosin/ring-swagger "0.24.1"] is available but we use "0.22.14"- Updated dependencies to avoid a path traversal vulnerability in Ring.
[compojure "1.5.2"] is available but we use "1.5.1"
[metosin/ring-http-response "0.8.1"] is available but we use "0.8.0"
[metosin/ring-swagger "0.22.14"] is available but we use "0.22.11"
[metosin/ring-swagger-ui "2.2.8"] is available but we use "2.2.5-0"- Fix
:header-paramswith resources, #254 - updated dependencies:
[frankiesardo/linked "1.2.9"] is available but we use "1.2.7"
[metosin/ring-swagger "0.22.11"] is available but we use "0.22.10"
[metosin/ring-swagger-ui "2.2.5-0"] is available but we use "2.2.2-0"-
Lot's of new swagger-bindings from Ring-swagger:
schema.core.defrecordorg.joda.time.LocalTime- primitive arrays, fixes #177
s/Anyin body generates empty object instead of nil
-
Bundled with latest swagger-ui
2.2.2-0 -
Updated deps:
[metosin/ring-swagger "0.22.10"] is available but we use "0.22.9"
[metosin/ring-swagger-ui "2.2.2-0"] is available but we use "2.2.1-0"-
Bundled with the latest Swagger-ui (2.2.1-0)
-
Updated deps:
[metosin/ring-swagger-ui "2.2.1-0"] is available but we use "2.1.4-0":content-typeof user-defined formats are pushed into Swagger:producesand:consumes, thanks to Waldemar.
(def custom-json-format
(ring.middleware.format-response/make-encoder cheshire.core/generate-string "application/vnd.vendor.v1+json"))
(api
{:format {:formats [custom-json-format :json :edn]}}
...)- New api-options
[:api :disable-api-middleware?]to disable the api-middleware completely. With this set,apionly produces the (reverse) route-tree + set's swagger stuff and sets schema coercions for the api.- Thanks to Alan Malloy for contributing!
(api
{:api {:disable-api-middleware? true}
;; Still available
:swagger {:ui "/api-docs"
:spec "/swagger.json"
:data {:info {:title "api"}}}}
...):datainswagger-routescan be overridden even if run outside ofapi:
(def app
(routes
(swagger-routes
{:ui "/api-docs"
:spec "/swagger.json"
:data {:info {:title "Kikka"}
:paths {"/ping" {:get {:summary "ping get"}}}}})
(GET "/ping" [] "pong"))))- unsetting
:formatoption inapi-middlewarecauses all format-middlewares not to mount - unsetting
:exceptionsoption inapi-middlewarecauses the exception handling to be disabled - unsetting
:coerciontranslates to same as setting it to(constantly nil)
(api
{:exceptions nil ;; disable exception handling
:format nil ;; disable ring-middleware-format
:coercion nil} ;; disable all schema-coercion
;; this will be really thrown
(GET "/throw" []
(throw (new RuntimeException))))- updated dependencies:
[prismatic/schema "1.1.3"] is available but we use "1.1.2"
[frankiesardo/linked "1.2.7"] is available but we use "1.2.6"-
fix reflection warning with logging, thanks to Matt K.
-
Empty contexts (
/) don't accumulate to the path, see weavejester/compojure#125 -
NOTE: update of
ring-http-responsehad a breaking change: -
updated dependencies:
[compojure "1.5.1"] is available but we use "1.5.0"
[metosin/ring-http-response "0.8.0"] is available but we use "0.7.0"
[cheshire "5.6.3"] is available but we use "5.6.1"- updated dependencies:
[prismatic/schema "1.1.2"] is available but we use "1.1.1"
[metosin/ring-http-response "0.7.0"] is available but we use "0.6.5"
[metosin/ring-swagger "0.22.9"] is available but we use "0.22.8"
[reloaded.repl "0.2.2"] is available but we use "0.2.1"
[peridot "0.4.4"] is available but we use "0.4.3"
[reloaded.repl "0.2.2"] is available but we use "0.2.1"-
Response headers are mapped correctly, fixes #232
-
updated dependencies:
[metosin/ring-swagger "0.22.8"] is available but we use "0.22.7"- Allow usage of run-time parameters with
:swagger.
(let [runtime-data {:x-name :boolean
:operationId "echoBoolean"
:description "Ehcoes a boolean"
:parameters {:query {:q s/Bool}}}]
(api
(GET "/route" []
:swagger runtime-data
(ok {:it "works"}))))- Copy & coerce compojure
:route-paramsinto:path-paramswith resources- Fixes #231.
(resource
{:parameters {:path-params {:id s/Int}}
:responses {200 {:schema s/Int}}
:handler (fnk [[:path-params id]]
(ok (inc id)))})- updated dependencies:
[prismatic/schema "1.1.1"] is available but we use "1.1.0"- BREAKING: Move
compojure.api.swgger/validatetocompojure.api.validator/validate. - BREAKING: If a
resourcedoesn't define a handler for a givenrequest-methodor for top-level, nil is returned (instead of throwing exeption) - BREAKING Resource-routing is done by
context. Trying to return acompojure.api.routing/Routefrom an endpoint likeANYwill throw descriptive (runtime-)exception.
(context "/hello" []
(resource
{:description "hello-resource"
:responses {200 {:schema {:message s/Str}}}
:post {:summary "post-hello"
:parameters {:body-params {:name s/Str}}
:handler (fnk [[:body-params name]]
(ok {:message (format "hello, %s!" name)}))}
:get {:summary "get-hello"
:parameters {:query-params {:name s/Str}}
:handler (fnk [[:query-params name]]
(ok {:message (format "hello, %s!" name)}))}}))- api-level swagger-options default to
{:ui nil, :spec nil}. Setting up just the spec or ui, doesn't automatically setup the other (like previously) - Strip nils from
:middleware, fixes #228 describeworks with anonymous body-schemas (via ring-swagger0.22.7), Fixes #168- Support compojure-api apps in Google App Engine by allowing scjsv to be excluded (uses json-schema-validator, which uses rogue threads):
[metosin/compojure-api "1.1.0" :exclusions [[metosin/scjsv]]]- updated dependencies:
[metosin/ring-swagger "0.22.7"] is available but we use "0.22.6"
[prismatic/plumbing "0.5.3"] is available but we use "0.5.2"
[cheshire "5.6.1"] is available but we use "5.5.0"- Parameter order is unreversed for fnk-style destructurings for small number of paramerers, fixes #224
- Moved internal coercion helpers from
compojure.api.metatocompojure.api.coerce. - New
compojure.api.resource/resource(also incompojure.api.sweet) for building resource-oriented services
(defn resource
"Creates a nested compojure-api Route from enchanced ring-swagger operations map and options.
By default, applies both request- and response-coercion based on those definitions.
Options:
- **:coercion** A function from request->type->coercion-matcher, used
in resource coercion for :body, :string and :response.
Setting value to `(constantly nil)` disables both request- &
response coercion. See tests and wiki for details.
Enchancements to ring-swagger operations map:
1) :parameters use ring request keys (query-params, path-params, ...) instead of
swagger-params (query, path, ...). This keeps things simple as ring keys are used in
the handler when destructuring the request.
2) at resource root, one can add any ring-swagger operation definitions, which will be
available for all operations, using the following rules:
2.1) :parameters are deep-merged into operation :parameters
2.2) :responses are merged into operation :responses (operation can fully override them)
2.3) all others (:produces, :consumes, :summary,...) are deep-merged by compojure-api
3) special key `:handler` either under operations or at top-level. Value should be a
ring-handler function, responsible for the actual request processing. Handler lookup
order is the following: operations-level, top-level, exception.
4) request-coercion is applied once, using deep-merged parameters for a given
operation or resource-level if only resource-level handler is defined.
5) response-coercion is applied once, using merged responses for a given
operation or resource-level if only resource-level handler is defined.
Note: Swagger operations are generated only from declared operations (:get, :post, ..),
despite the top-level handler could process more operations.
Example:
(resource
{:parameters {:query-params {:x Long}}
:responses {500 {:schema {:reason s/Str}}}
:get {:parameters {:query-params {:y Long}}
:responses {200 {:schema {:total Long}}}
:handler (fn [request]
(ok {:total (+ (-> request :query-params :x)
(-> request :query-params :y))}))}
:post {}
:handler (constantly
(internal-server-error {:reason \"not implemented\"}))})"
([info]
(resource info {}))
([info options]
(let [info (merge-parameters-and-responses info)
root-info (swaggerize (root-info info))
childs (create-childs info)
handler (create-handler info options)]
(routes/create nil nil root-info childs handler))))- updated dependencies:
[compojure "1.5.0"] is available but we use "1.4.0"
[prismatic/schema "1.1.0"] is available but we use "1.0.5"
[metosin/ring-swagger "0.22.6"] is available but we use "0.22.4"- For response coercion, the original response is available in
ex-dataunder:response. This can be used in logging, "what did the route try to return". Thanks to Tim Gilbert. - Response coercion uses the
:defaultcode if available and response code doesn't match
(GET "/" []
:responses {200 {:schema {:ping s/Str}}
:default {:schema {:error s/int}}}
...)- updated dependencies:
[prismatic/schema "1.0.5"] is available but we use "1.0.4"- Swagger-routes mounted via api-options are mounted before other routes, fixes #218
- Routes are now resolved also from from Vars, fixes #219
- Better handling of
:basePathwithswagger-routes, thanks to Hoxu. - Updated dependencies:
[metosin/ring-swagger "0.22.4"] is available but we use "0.22.3"- Move from compile-time to runtime route resolution.
- Most of the internal macro magic has been vaporized
- Uses internally (invokable) Records & Protocols, allowing easier integration to 3rd party libs like Liberator
- even for large apps (100+ routes), route compilation takes now millis, instead of seconds
- sub-routes can be created with normal functions (or values), making it easier to:
- pass in app-level dependencies from libs like Component
- reuse shared request-handling time parameters like path-parameters and authorization info
(defn more-routes [db version]
(routes
(GET "/version" []
(ok {:version version}))
(POST "/thingie" []
(ok (thingie/create db)))))
(defn app [db]
(api
(context "/api/:version" []
:path-params [version :- s/Str]
(more-routes db version)
(GET "/kikka" []
(ok "kukka")))))-
BREAKING Vanilla Compojure routes will not produce any swagger-docs (as they do not satisfy the
Routingprotocol. They can still be used for handling request, just without docs.- a new api-level option
[:api :invalid-routes-fn]to declare how to handle routes not satisfying theRoutingprotocol. Default implementation logs invalid routes as WARNINGs.
- a new api-level option
-
BREAKING compojure.core imports are removed from
compojure.api.sweet:let-request,routing,wrap-routes
-
BREAKING Asterix (
*) is removed from route macro & function names, as there is no reason to mix compojure-api & compojure route macros.GET*=>GETANY*=>ANYHEAD*=>HEADPATCH*=>PATCHDELETE*=>DELETEOPTIONS*=>OPTIONSPOST*=>PUTcontext*=>contextdefroutes*=>defroutes
-
BREAKING
swagger-docsandswagger-uiare no longer incompojure.api.sweet- Syntax was hairy and when configuring the spec-url it needed to be set to both in order to work
- In future, there are multiple ways of setting the swagger stuff:
- via api-options
:swagger(has no defaults) - via
swagger-routesfunction, mounting both theswagger-uiandswagger-docsand wiring them together- by default, mounts the swagger-ui to
/and the swagger-spec to/swagger.json
- by default, mounts the swagger-ui to
- via the old
swagger-ui&swagger-docs(need to be separately imported fromcompojure.api.swagger). - see https://github.com/metosin/compojure-api/wiki/Swagger-integration for details
- via api-options
(defapi app
(swagger-routes)
(GET "/ping" []
(ok {:message "pong"})))
(defapi app
{:swagger {:ui "/", :spec "/swagger.json"}}
(GET "/ping" []
(ok {:message "pong"})))-
BREAKING: api-level coercion option is now a function of
request => type => matcheras it is documented. Previously required atype => matchermap. Options are checked againsttype => matchercoercion input, and a descriptive error is thrown when api is created with the old options format. -
BREAKING: Renamed
middlewarestomiddlewareand:middlewareskey (restructuring) to:middleware- will break at macro-expansion time with helpful exception
-
BREAKING: Middleware must be defined as data: both middleware macro and :middleware restructuring take a vector of middleware containing either
- a) fully configured middleware (function), or
- b) a middleware templates in form of
[function args] - You can also use anonymous or lambda functions to create middleware with correct parameters,
these are all identical:
[[wrap-foo {:opts :bar}]][#(wrap-foo % {:opts :bar})][(fn [handler] (wrap-foo handler {:opts :bar}))]
- Similar to duct
-
BREAKING: (Custom restructuring handlers only)
:parameterskey used byrestructure-paramhas been renamed to:swagger.- will break at macro-expansion time with helpful exception
-
BREAKING
public-resource-routes&public-resourcesare removed fromcompojure.api.middleware. -
BREAKING:
compojure.api.legacynamespace has been removed.
https://github.com/metosin/compojure-api/wiki/Migration-Guide-to-1.0.0
-
Additional route functions/macros in
compojure.api.core:routes&letroutes, just like in the Compojure, but supportingRoutingundocumented- works just likeroutesbut without any route definitions. Can be used to wrap legacy routes which setting the api option to fail on missing docs.
-
top-level
apiis now just function, not a macro. It takes an optional options maps and a top-level route function. -
Coercer cache is now at api-level with 10000 entries.
-
Code generated from restructured route macros is much cleaner now
-
Coercion is on by default for standalone (apiless) endpoints.
(fact "coercion is on for apiless routes"
(let [route (GET "/x" []
:query-params [x :- Long]
(ok))]
(route {:request-method :get :uri "/x" :query-params {}}) => throws))- Removed deps:
[backtick "0.3.3"]-
Fixed path parameter handling in cases where path parameter is followed by an extension (#196, metosin/ring-swagger#82)
-
Added
compojure.api.exception/with-logginghelper to add logging to exception handlers.- Check extended wiki guide on exception handling
-
Updated deps:
[metosin/ring-swagger "0.22.3"] is available- Updated deps:
[metosin/ring-swagger "0.22.2"] is available
[metosin/ring-swagger-ui "2.1.4-0"] is available
[potemkin "0.4.3"] is available-
coercer-cache is now per Route instead beeing global and based on a FIFO size 100 cache. Avoids potential memory leaks when using anonymous coercion matchers (which never hit the cache).
-
Updated deps:
[prismatic/schema "1.0.4"] is available but we use "1.0.3"- Memoize coercers (for
schema&matcher-input) for better performance.- Tests show 0-40% lower latency, depending on input & output schema complexity.
- Tested by sending json-strings to
apiand reading json-string out. - Measured a 80% lower latency with a real world large Schema.
- Updated deps:
[potemkin "0.4.2"] is available but we use "0.4.1"- uses
[Ring-Swagger "0.22.1"] clojure.tools.loggingis used with default uncaugt exception handling if it's found on the classpath. Fixes #172.- Both
apianddefapiproduce identical swagger-docs. Fixes #159 - allow any swagger data to be overriden at runtime either via swagger-docs or via middlewares. Fixes #170.
[metosin/ring-swagger "0.22.1"] is available but we use "0.22.0"
[metosin/ring-swagger-ui "2.1.3-4"] is available but we use "2.1.3-2"
[prismatic/plumbing "0.5.2] is available but we use "0.5.1"- BREAKING: Dropped support for Clojure 1.6
- BREAKING: Supports and depends on Schema 1.0.
- BREAKING:
ring-middleware-formataccepts transit options in a new format:
;; pre 0.24.0:
(api
{:format {:response-opts {:transit-json {:handlers transit/writers}}
:params-opts {:transit-json {:options {:handlers transit/readers}}}}}
...)
;; 0.24.0 +
(api
{:format {:response-opts {:transit-json {:handlers transit/writers}}
:params-opts {:transit-json {:handlers transit/readers}}}}
...)- Uses upstream ring-middleware-format instead of Metosin fork.
- Uses now linked instead of ordered for maps where order matters.
swagger-uinow supports passing arbitrary options toSwaggerUI(metosin/ring-swagger#67).
- Updated deps:
[prismatic/schema "1.0.3"] is available but we use "0.4.4"
[prismatic/plumbing "0.5.1] is available but we use "0.4.4"
[metosin/schema-tools "0.7.0"] is available but we use "0.5.2"
[metosin/ring-swagger "0.22.0"] is available but we use "0.21.0"
[metosin/ring-swagger-ui "2.1.3-2"] is available but we use "2.1.2"- Routes are kept in order for swagger docs, Fixes #138.
- Ring-swagger 0.21.0
- BREAKING: new signature for dispatching custom JSON Schema transformations, old signature will break (nicely at compile-time), see Readme for details.
- Support for collections in query parameters. E.g.
:query-params [x :- [Long]]& url?x=1&x=2&x=3should result inxbeing[1 2 3].
- BREAKING:
:validation-errors :error-handler,:validation-errors :catch-core-errors?and:exceptions :exception-handleroptions have been removed.- These have been replaced with general
:exceptions :handlersoptions. - Fails nicely at compile-time
- BREAKING: New handler use different arity than old handler functions.
- new arguments: Exception, ex-info and request.
- These have been replaced with general
- Move
contextfromcompojure.api.sweettocompojure.api.legacy. Usecontext*instead. - Updated deps:
[metosin/ring-swagger "0.21.0-SNAPSHOT"] is available but we use "0.20.4"
[compojure "1.4.0"] is available but we use "1.3.4"
[prismatic/schema "0.4.4"] is available but we use "0.4.3"
[metosin/ring-http-response "0.6.5"] is available but we use "0.6.3"
[metosin/schema-tools "0.5.2"] is available but we use "0.5.1"
[metosin/ring-swagger-ui "2.1.2"] is available but we use "2.1.5-M2"
[peridot "0.4.1"] is available but we use "0.4.0"- fixes 150
[metosin/ring-http-response "0.6.3"] is available but we use "0.6.2"
[midje "1.7.0"] is available but we use "1.7.0-SNAPSHOT"-
Optional integration with Component. Use either
:components-option ofapi-middlewareorwrap-components-middleware to associate the components with your API. Then you can use:components-restructuring to destructure your components using letk syntax. -
fix for #123
-
support for pluggable coercion, at both api-level & endpoint-level with option
:coercion. See thethe tests.- coercion is a function of type -
ring-request->coercion-type->coercion-matcherallowing protocol-based coercion in the future ** BREAKING**: if you have created custom restructurings usingsrc-coerce, they will break (nicely at compile-time)
- coercion is a function of type -
-
new restucturing
:swaggerjust for swagger-docs. Does not do any coercion.
(GET* "/documented" []
:swagger {:responses {200 {:schema User}
404 {:schema Error
:description "Not Found"} }
:paramerers {:query {:q s/Str}
:body NewUser}}}
...)[cheshire "5.5.0"] is available but we use "5.4.0"
[backtick "0.3.3"] is available but we use "0.3.2"
[lein-ring "0.9.6"] is available but we use "0.9.4":multipart-paramsnow sets:consumes ["multipart/form-data"]and:form-paramssets:consumes ["application/x-www-form-urlencoded"]- experimental: File upload support using
compojure.api.uploadnamespace.
(POST* "/upload" []
:multipart-params [file :- TempFileUpload]
:middlewares [wrap-multipart-params]
(ok (dissoc file :tempfile))))- breaking: use plain Ring-Swagger 2.0 models with
:responses. A helpfulIllegalArgumentExceptionwill be thrown at compile-time with old models. - new way:
:responses {400 {:schema ErrorSchema}}
:responses {400 {:schema ErrorSchema, :description "Eror"}}- allow configuring of Ring-Swagger via
api-middlewareoptions with key:ring-swagger:
(defapi app
{:ring-swagger {:ignore-missing-mappings? true}})
(swagger-docs)
(swagger-ui)
...)- Bidirectinal routing, inspired by bidi - named routes &
path-for:
(fact "bidirectional routing"
(let [app (api
(GET* "/api/pong" []
:name :pong
(ok {:pong "pong"}))
(GET* "/api/ping" []
(moved-permanently (path-for :pong))))]
(fact "path-for resolution"
(let [[status body] (get* app "/api/ping" {})]
status => 200
body => {:pong "pong"}))))- a validator for the api
(require '[compojure.api.sweet :refer :all])
(require '[compojure.api.swagger :refer [validate])
(defrecord NonSwaggerRecord [data])
(def app
(validate
(api
(swagger-docs)
(GET* "/ping" []
:return NonSwaggerRecord
(ok (->NonSwaggerRecord "ping"))))))
; clojure.lang.Compiler$CompilerException: java.lang.IllegalArgumentException:
; don't know how to create json-type of: class compojure.api.integration_test.NonSwaggerRecord- updated dependencies:
[metosin/ring-swagger "0.20.4"] is available but we use "0.20.3"
[metosin/ring-http-response "0.6.2"] is available but we use "0.6.1"
[metosin/ring-swagger-ui "2.1.5-M2"]
[prismatic/plumbing "0.4.4"] is available but we use "0.4.3"
[prismatic/schema "0.4.3"] is available but we use "0.4.2"- response descriptions can be given also with run-time meta-data (
with-meta), fixes #96- in next MINOR version, we'll switch to (Ring-)Swagger 2.0 format.
(context* "/responses" []
:tags ["responses"]
(GET* "/" []
:query-params [return :- (s/enum :200 :403 :404)]
:responses {403 ^{:message "spiders?"} {:code s/Str} ; old
404 (with-meta {:reason s/Str} {:message "lost?"})} ; new
:return Total
:summary "multiple returns models"
(case return
:200 (ok {:total 42})
:403 (forbidden {:code "forest"})
:404 (not-found {:reason "lost"}))))- welcome
compojure.api.core/api, the work-horse behindcompojure.api.core/defapi. - lexically bound route-trees, generated by
api, pushed to request via ring-swagger middlewares.- no more
+compojure-api-routes+littering the handler namespaces.
- no more
- fixes #101
- fixes #102
- update dependencies:
[metosin/ring-swagger "0.20.3"] is available but we use "0.20.2"
[prismatic/plumbing "0.4.3"] is available but we use "0.4.2"
[peridot "0.4.0"] is available but we use "0.3.1"
[compojure "1.3.4"] is available but we use "1.3.3"
[lein-ring "0.9.4"] is available but we use "0.9.3"- use ring-swagger middleware swagger-data injection instead of own custom mechanism.
- fixed #98: 2.0 UI works when running with context on (Servlet-based) app-servers.
- Preserve response-schema names, fixes #93.
- updated dependencies:
[metosin/ring-swagger "0.20.2"] is available but we use "0.20.0"
[prismatic/schema "0.4.2"] is available but we use "0.4.1"-
New restructuring for
:no-doc(a boolean) - endpoints with this don't get api documentation. -
Fixed #42 -
defroutes*now does namespace resolution for the source used for route peeling and source linking (the macro magic) -
Fixed #91 -
defroutes*are now automatically accessed over a Var for better development flow. -
Fixed #89.
-
Fixed #82.
-
Fixed #71, ring-swagger-ui is now a dependency.
-
breaking
ring.swagger.json-schema/describeis now imported intocompojure.api.sweetfor easy use. If your code refers to it directly, you need remove the direct reference.
- Routes are collected always from the root (
defapiorcompojure.api.routes/api-rootwithin that) compojure.api.routes/with-routesis nowcompojure.api.routes/api-root- breaking requires the latest swagger-ui to work
[metosin/ring-swagger-ui "2.1.1-M2"]to get things pre-configured- or package
2.1.1-M2yourself from the source.
- breaking: api ordering is not implemented.
- breaking: restructuring
:nicknameis now:operationId - breaking: restructuring
:notesis now:description swagger-docsnow takes any valid Swagger Spec data in. Using old format gives a warning is to STDOUT.
(swagger-docs
{:info {:version "1.0.0"
:title "Sausages"
:description "Sausage description"
:termsOfService "http://helloreverb.com/terms/"
:contact {:name "My API Team"
:email "[email protected]"
:url "http://www.metosin.fi"}
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}}
:tags [{:name "kikka", :description "kukka"}]})- Swagger-documentation default uri is changed from
/api/api-docsto/swagger.json. compojure.api.swagger/swaggeredis deprecated - not relevant with 2.0. Works, but prints out a warning to STDOUT ** in 2.0, apis are categorized by Tags, one can set them either to endpoints or to paths:
(GET* "/api/pets/" []
:tags ["pet"]
(ok ...))(context* "/api/pets" []
:tags ["pet"]
(GET* "/" []
:summary "get all pets"
(ok ...)))- updated deps:
[metosin/ring-swagger "0.20.0"] is available but we use "0.19.4"
[prismatic/schema "0.4.1"] is available but we use "0.4.0"[prismatic/plumbing "0.4.2"] is available but we use "0.4.1"
[prismatic/schema "0.4.1"] is available but we use "0.4.0"
[potemkin "0.3.13"] is available but we use "0.3.12"
[compojure "1.3.3"] is available but we use "1.3.2"
[metosin/ring-swagger "0.19.4"] is available but we use "0.19.3"- Compatibility with swagger-ui
2.1.0-M2-[metosin/ring-swagger-ui "2.1.0-M2-2] - updated deps:
[metosin/ring-swagger "0.19.3"] is available but we use "0.19.2"- avoid reflection fixes by Michael Blume
- one can now wrap body & response-models in predicates and get the swagger docs out:
:return (s/maybe User)
:responses {200 (s/maybe User)
400 (s/either Cat Dog)}- updated deps:
[metosin/ring-swagger "0.19.2"] is available but we use "0.19.1"- added destructuring for
:headers, thanks to tchagnon! :path-paramallows any keywords, needed for the partial parameter matching withcontext*- BREAKING: parameters are collected in (Ring-)Swagger 2.0 format, might break client-side
compojure.api.meta/restructure-paramdispatch functions - for the swagger documentation part. See https://github.com/metosin/ring-swagger/blob/master/test/ring/swagger/swagger2_test.clj & https://github.com/metosin/compojure-api/blob/master/src/compojure/api/meta.clj for examples of the new schemas. context*to allow setting meta-data to mid-routes. Mid-route meta-data are deep-merged into endpoint swagger-definitions at compile-time. At runtime, code is executed in place.
(context* "/api/:kikka" []
:summary "summary inherited from context"
:path-params [kikka :- s/Str] ; enforced here at runtime
:query-params [kukka :- s/Str] ; enforced here at runtime
(GET* "/:kakka" []
:path-params [kakka :- s/Str] ; enforced here at runtime
(ok {:kikka kikka
:kukka kukka
:kakka kakka})))- updated deps:
[prismatic/plumbing "0.4.1"] is available but we use "0.3.7"
[potemkin "0.3.12"] is available but we use "0.3.11"
[prismatic/schema "0.4.0"] is available but we use "0.3.7"
[metosin/ring-http-response "0.6.1"] is available but we use "0.6.0"
[metosin/ring-swagger "0.19.0"] is available but we use "0.18.1"
[lein-ring "0.9.3"] is available but we use "0.9.2"- Support passing options to specific format middlewares (merged into defaults):
(defapi app
{:format {:formats [:json-kw :yaml-kw :edn :transit-json :transit-msgpack]
:params-opts {}
:response-opts {}}
:validation-errors {:error-handler nil
:catch-core-errors? nil}
:exceptions {:exception-handler default-exception-handler}}
...)- import
compojure.core/wrap-routesintocompojure.api.sweet - BREAKING: in
compojure.api.middleware,ex-info-supportis now parameterizablewrap-exception- fixes #68
- Update dependencies
[prismatic/plumbing "0.3.7"] is available but we use "0.3.5"
[compojure "1.3.2"] is available but we use "1.3.1"
[prismatic/schema "0.3.7"] is available but we use "0.3.3"
[metosin/ring-swagger "0.18.0"] is available but we use "0.15.0"
[metosin/ring-http-response "0.6.0"] is available but we use "0.5.2"
[metosin/ring-middleware-format "0.6.0"] is available but we use "0.5.0"
- Depend on forked version of
ring-middleware-format- Transit support should now work
- If you are depending on ring-middleware-format directly, you'll want to either update your dependency or exclude one from Compojure-api
- Update dependencies:
[cheshire "5.4.0"] is available but we use "5.3.1"
[metosin/ring-swagger-ui "2.0.24"] is available but we use "2.0.17"
[lein-ring "0.9.0"] is available but we use "0.8.13"- fix #53
- update deps:
[compojure "1.3.1"] is available but we use "1.2.1"
[metosin/ring-swagger "0.15.0"] is available but we use "0.14.1"
[peridot "0.3.1"] is available but we use "0.3.0"- fix anonymous Body & Return model naming issue 56 by Michael Blume
- update deps:
[prismatic/schema "0.3.3"] is available but we use "0.3.2"
[metosin/ring-http-response "0.5.2"] is available but we use "0.5.1"- use
[org.tobereplaced/lettercase "1.0.0"]for camel-casing (see metosin/compojure-api-examples#1 (comment)) - updated deps:
[metosin/ring-swagger "0.14.1"] is available but we use "0.14.0"- support for
:form-parameters, thanks to Thomas Whitcomb - update deps:
[prismatic/plumbing "0.3.5"] is available but we use "0.3.3"
[potemkin "0.3.11"] is available but we use "0.3.8"
[compojure "1.2.1"] is available but we use "1.1.9"
[prismatic/schema "0.3.2"] is available but we use "0.2.6"
[metosin/ring-http-response "0.5.1"] is available but we use "0.5.0"
[metosin/ring-swagger "0.14.0"] is available but we use "0.13.0"
[lein-ring "0.8.13"] is available but we use "0.8.11"- Fixed #47:
:middlewaresbroke route parameters
- Compiled without AOT
- Removed
:yaml-in-htmland:clojurefrom default response formats
- Some cleaning
- Requires now Clojure 1.6.0 for
clojure.walk
- Requires now Clojure 1.6.0 for
- Support other formats in addition to JSON
- Uses the ring-middleware-format to parse requests and encode responses
- Fixes #43: Middlewares added to route with :middlewares shouldn't leak to other routes in same context anymore
- Update to latest
ring-swagger
- Update to latest
ring-swagger- Fixes #16: If Schema has many properties, they are now shown in correct order on Swagger-UI
hash-maploses the order if it has enough propertiesUse flatland.ordered.map/ordered-map when Schema has many properties and you want to keep the order intact(s/defschema Thingie (ordered-map :a String ...))
- Fixes #16: If Schema has many properties, they are now shown in correct order on Swagger-UI
- Use latest
ring-swagger :bodyand others no langer take description as third param, instead use:body [body (describe Schema "The description")]describeworks also for Java classes:query-params [x :- (describe Long "first-param")]- And inside defschema
(s/defschema Schema {:sub (describe [{:x Long :y String}] "Array of stuff")})
- return model coercion returns
500instead of400, thanks to @phadej! - added support for returning primitives, thanks to @phadej!
(GET* "/plus" []
:return Long
:query-params [x :- Long {y :- Long 1}]
:summary "x+y with query-parameters. y defaults to 1."
(ok (+ x y))):responsesrestructuring to (error) return codes and models, thanks to @phadej!
(POST* "/number" []
:return Total
:query-params [x :- Long y :- Long]
:responses {403 ^{:message "Underflow"} ErrorEnvelope}
:summary "x-y with body-parameters."
(let [total (- x y)]
(if (>= total 0)
(ok {:total (- x y)})
(forbidden {:message "difference is negative"}))))- support for
s/Uuidvia latestring-swagger. - fail-fast (with client-typos): remove default implementation from
compojure.api.meta/restructure-param
- restructure
:header-params(fixes #31) - remove vanilla compojure-examples, internal cleanup
- allow primitives as return types (with help of
[metosin/ring-swagger 0.10.2])- all primitives are supported when wrapped into sequences and sets
- directly, only
Stringis supported as Ring doesn't support others- in future, there could be a special return value coercer forcing all other primitives as Strings
- first take on removing the global route state => instead of global
swaggeratom, there is one defined+routes+var per namespace- requires a
compojure.api.core/with-routeson api root to generate and hold the+routes+(automatically bundled withdefapi)
- requires a
- update ring-swagger to
0.10.1to get support fors/Keywordas a nested schema key.
- possibly breaking change:
middlewaresmacro and:middlewaresrestructuring now use thread-first to apply middlewares - update ring-swagger to
0.9.1with support for vanillaschema.core/defschemaschemas- big internal cleanup, removing model var-resolutions, lot's of internal fns removed
- added
defroutestocompojure.api.legacy - removed defns from
compojure.api.common:->Long,fn->,fn->> - cleaner output from
compojure.api.meta/restructure(doesn't generate emptylets&letks)
- added
compojure.api.legacyns to have the old Compojure HTTP-method macros (GET,POST,...)
- Update dependencies:
[prismatic/plumbing "0.3.1"] is available but we use "0.2.2"
[compojure "1.1.8"] is available but we use "1.1.7"
[prismatic/schema "0.2.3"] is available but we use "0.2.2"
[metosin/ring-swagger "0.8.8"] is available but we use "0.8.7"
[peridot "0.3.0"] is available but we use "0.2.2"
- Really updated ring-swagger dependency as I forgot that last with previous release
- remove non-first trailing spaces from Compojure-routes for swagger-docs.
- updated dependencies:
[metosin/ring-swagger "0.8.7"][metosin/ring-swagger-ui "2.6.16-2"]
- Moved swagger-ui handler to ring-swagger
-
updated dependencies:
[compojure "1.1.7"][prismatic/schema "0.2.2"][metosin/ring-swagger "0.8.5"]
-
consumesandproducesare now feed toring-swaggerbased on the installed middlewares.
- fix for #19
- change signature of
restructure-paramto receive key, value and the accumulator. Remove the key from accumulator parameters by default. No more alpha. - separate restructuring into own namespace
meta - new:
:middlewaresrestructuring to support adding middlewares to routes:
(DELETE* "/user/:id" []
:middlewares [audit-support (for-roles :admin)]
(ok {:name "Pertti"})))- breaking change:
with-middlewareis renamed tomiddlewares& it applies middlewares in reverse order - more docs on creating own metadata DSLs
- use
clojure.walk16internally
- fixed #12
- added http-kit example
- renamed
clojure.walktoclojure.walk16 - writing routes to
swaggeratom happens now at runtime, not compile-time. Works with AOT.
- All
compojure.api.corerestructuring are now usingrestructure-parammultimethod to allow external extensions. ALPHA.
- FIXED #9
swaggeredresources are now collected in order
- fixed bug with missing
+compojure-api-request+when having both Compojure destructuring & Compojure-api destructuring in place - added support for
:body-params(with strict schema):
(POST* "/minus" []
:body-params [x :- Long y :- Long]
:summary "x-y with body-parameters"
(ok {:total (- x y)}))- update
ring-swaggerto0.8.4to get better basepath-resolution (with reverse-proxies)
- support for Schema-aware
:path-parametersandquery-parameters:
(GET* "/sum" []
:query-params [x :- Long y :- Long]
:summary "sums x & y query-parameters"
(ok {:total (+ x y)}))
(GET* "/times/:x/:y" []
:path-params [x :- Long y :- Long]
:summary "multiplies x & y path-parameters"
(ok {:total (* x y)}))swagger-uiindex-redirect work also under a context when running in an legacy app-server. Thanks to Juha Syrjälä for the PR.
- use
instanceof?to match records instead of=with class. Apps can now be uberwarred withlein ring uberwar.
- update
ring-swaggerto0.8.3, generate path-parameters on client side
- update
ring-swaggerto0.8.1, all JSON-schema generation now done there.
- coerce return values with smart destructuring, thanks to Arttu Kaipiainen.
- update
ring-http-responseto0.4.0 - handle json-parse-errors by returning JSON
- rewrite
compojure.api.core-integration-testusingperidot.core
- Swagger path resolution works now with Compojure regular expression matching in URL parameters. Thanks to Arttu Kaipiainen.
(context "/api" []
(GET* ["/item/:name" :name #"[a-z/]+"] [name] identity))- Sets really work now with smart destructuring of
GET*andPOST*. Addeds tests to verify.
- update
ring-swaggerto0.7.3 - initial support for smart query parameter destructuring (arrays and nested params don't get swagger-ui love yet - but work otherwise ok)
(GET* "/echo" []
:return Thingie
:query [thingie Thingie]
(ok thingie)) ;; here be coerced thingie- Breaking change:
compojure.api.routes/defroutesis nowcompojure.api.core/defroutes*to avoid namespace clashes & promote it's different. - FIXED #4
- reverted "Compojures args-vector is now optional with
compojure.api.coreweb methods"
- reverted "Compojures args-vector is now optional with
- removed the Compojure Var pimp. Extended meta-data syntax no longer works with vanilla Compojure but requires the extended macros from
compojure.api.core. - update to
Ring-Swaggerto0.7.2
- date-format can be overridden in the
json-response-support, thanks to Dmitry Balakhonskiy - Update
Ring-Swaggerto0.7.1giving support for nested Maps:
(defmodel Customer {:id String
:address {:street String
:zip Long
:country {:code Long
:name String}}})- schema-aware body destructuring with
compojure.api.coreweb methods does now automatic coercion for the body - Compojures args-vector is now optional with
compojure.api.coreweb methods
(POST* "/customer"
:return Customer
:body [customer Customer]
(ok customer))) ;; we have a coerced customer here- update
ring-swaggerto0.7.0- support for
schema/maybeandschema/both - consume
Date&DateTimeboth with and without milliseconds:"2014-02-18T18:25:37.456Z"&"2014-02-18T18:25:37Z"
- support for
- name-parameter of
swaggeredis stripped out of spaces.
- update
ring-swaggerto0.6.0- support for LocalDate.
- updated example to cover all the dates.
swaggereddoesn't have to contain container-element (contextetc.) within, endpoints are ok:
(swaggered "ping"
:description "Ping api"
(GET* "/ping" [] (ok {:ping "pong"})))- body parameter in
POST*andPUT*now allows model sequences:
(POST* "/pizzas" []
:body [pizzas [NewPizza] {:description "new pizzas"}]
(ok (add! pizzas)))- update
ring-swaggerto0.5.0to get support for Data & DateTime.
swaggeredcan now follow symbols pointing to acompojure.api.routes/defroutesroute definition to allow better route composition.compojure.api.sweetnow usescompojure.api.routes/defroutesinstead ofcompojure.core/defroutes
- Fixed JSON Array -> Clojure Set coercing with Strings
- Initial public version