Releases: metosin/compojure-api
Releases · metosin/compojure-api
0.23.0
- 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=3
should result inx
being[1 2 3]
.
- BREAKING:
:validation-errors :error-handler
,:validation-errors :catch-core-errors?
and:exceptions :exception-handler
options have been removed.- These have been replaced with general
:exceptions :handlers
options. - 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
context
fromcompojure.api.sweet
tocompojure.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"
0.22.2
0.22.1
0.22.0
- Optional integration with Component.
Use either:components
-option ofapi-middleware
orwrap-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-matcher
allowing 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
:swagger
just 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"
0.21.0
:multipart-params
now sets:consumes ["multipart/form-data"]
and:form-params
sets
:consumes ["application/x-www-form-urlencoded"]
- experimental: File upload support using
compojure.api.upload
namespace.
(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 helpfulIllegalArgumentException
will 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-middleware
options 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.core_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"
0.20.4
- 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"}))))
0.20.3
- 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"
0.20.1
- 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"
0.20.0
- New restructuring for
:no-docs
(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/describe
is now imported intocompojure.api.sweet
for easy use. If your code
refers to it directly, you need remove the direct reference.
Swagger 2.0 -support
Migration Guide
- Routes are collected always from the root (
defapi
orcompojure.api.routes/api-root
within that) compojure.api.routes/with-routes
is 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-M2
yourself from the source.
- breaking: api ordering is not implemented.
- breaking: restructuring
:nickname
is now:operationId
- breaking: restructuring
:notes
is now:description
swagger-docs
now 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-docs
to/swagger.json
. compojure.api.swagger/swaggered
is 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"
0.19.3
[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"