Skip to content

Releases: metosin/compojure-api

1.0.0

17 Feb 14:04
1.0.0
Compare
Choose a tag to compare

compare

  • updated dependencies:
[prismatic/schema "1.0.5"] is available but we use "1.0.4"

1.0.0-RC2

17 Feb 14:05
Compare
Choose a tag to compare
1.0.0-RC2 Pre-release
Pre-release

compare

  • 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 :basePath with swagger-routes, thanks to Hoxu.
  • Updated dependencies:
[metosin/ring-swagger "0.22.4"] is available but we use "0.22.3"

1.0.0-RC1

17 Feb 14:05
Compare
Choose a tag to compare
1.0.0-RC1 Pre-release
Pre-release

compare

  • 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 changes

  • BREAKING Vanilla Compojure routes will not produce any swagger-docs (as they do not satisfy the
    Routing protocol. 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
      the Routing protocol. Default implementation logs invalid routes as WARNINGs.
  • 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* => GET
    • ANY* => ANY
    • HEAD* => HEAD
    • PATCH* => PATCH
    • DELETE* => DELETE
    • OPTIONS* => OPTIONS
    • POST* => PUT
    • context* => context
    • defroutes* => defroutes
  • BREAKING swagger-docs and swagger-ui are now longer in compojure.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-routes function, mounting both the swagger-ui and swagger-docs and wiring them together
        • by default, mounts the swagger-ui to / and the swagger-spec to /swagger.json
      • via the old swagger-ui & swagger-docs (need to be separately imported from compojure.api.swagger).
      • see https://github.com/metosin/compojure-api/wiki/Swagger-integration for details
(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 => matcher as it is documented.
    Previously required a type => matcher map. Options are checked against type => matcher coercion input, and a
    descriptive error is thrown when api is created with the old options format.
  • BREAKING: Renamed middlewares to middleware and :middlewares key (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) :parameters key used by restructure-param
    has been renamed to :swagger.
    • will break at macro-expansion time with helpful exception
  • BREAKING public-resource-routes & public-resources are removed from compojure.api.middleware.
  • BREAKING: compojure.api.legacy namespace has been removed.

Migration guide

https://github.com/metosin/compojure-api/wiki/Migration-Guide-to-1.0.0

Other stuff

  • Additional route functions/macros in compojure.api.core:
    • routes & letroutes, just like in the Compojure, but supporting Routing
    • undocumented - works just like routes but without any route definitions. Can be used to wrap legacy routes which setting the api option to fail on missing docs.
  • top-level api is 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"]

0.24.5

17 Jan 18:47
0.24.5
Compare
Choose a tag to compare

compare

[metosin/ring-swagger "0.22.3"] is available

0.24.4

17 Jan 18:47
Compare
Choose a tag to compare

compare

[metosin/ring-swagger "0.22.2"] is available
[metosin/ring-swagger-ui "2.1.4-0"] is available
[potemkin "0.4.3"] is available

0.24.3

17 Jan 18:47
Compare
Choose a tag to compare

compare

  • 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"

0.24.2

17 Jan 18:47
Compare
Choose a tag to compare

compare

  • 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 api and 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"

0.24.1

17 Jan 18:46
Compare
Choose a tag to compare

compare

  • uses [Ring-Swagger "0.22.1"]
  • clojure.tools.logging is used with default uncaugt exception handling if it's found
    on the classpath. Fixes #172.
  • Both api and defapi produce 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"

0.24.0

08 Nov 10:26
Compare
Choose a tag to compare

compare

  • BREAKING: Dropped support for Clojure 1.6
  • BREAKING: Supports and depends on Schema 1.0.
  • Uses upstream ring-middleware-format
    instead of Metosin fork.
  • Uses now linked instead of
    ordered for maps where order matters.
  • swagger-ui now supports passing arbitrary options to SwaggerUI
    (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"

0.23.1

08 Nov 10:26
Compare
Choose a tag to compare

compare

  • Routes are kept in order for swagger docs, Fixes #138.