(->optional-param schema param)
Removes a required param from the given schema and re-adds it as an optional param.
Removes a required param from the given schema and re-adds it as an optional param.
(api & body)
Returns a ring handler wrapped in compojure.api.middleware/api-middlware. Creates the route-table at api creation time and injects that into the request via middlewares. Api and the mounted api-middleware can be configured by optional options map as the first parameter:
(api
{:formats [:json-kw :edn :transit-msgpack :transit-json]
:exceptions {:handlers {:compojure.api.exception/default my-logging-handler}}
:api {:invalid-routes-fn (constantly nil)}
:swagger {:spec "/swagger.json"
:ui "/api-docs"
:data {:info {:version "1.0.0"
:title "My API"
:description "the description"}}}}
(context "/api" []
...))
:api
.
compojure.api.routes/log-invalid-child-routes
api-middleware
from api.compojure.api.swagger/swagger-routes
for details.Opinionated chain of middlewares for web apis. Takes optional options-map.
An error handler is a function of exception, ex-data and request to response.
When defining these options, it is suggested to use alias for the exceptions namespace,
e.g. [compojure.api.exception :as ex]
.
Default:
{::ex/request-validation ex/request-validation-handler
::ex/request-parsing ex/request-parsing-handler
::ex/response-validation ex/response-validation-handler
::ex/default ex/safe-handler}
Note: Because the handlers are merged into default handlers map, to disable default handler you
need to provide nil
value as handler.
Note: To catch Schema errors use {:schema.core/error ex/schema-error-handler}
.
:exceptions for compojure.api.middleware/wrap-exceptions (nil to unmount it)
:type
key in ExceptionInfo data.:format for ring-middleware-format middlewares (nil to unmount it)
[:json-kw :edn]
{:transit-json {:handlers readers}}
{:transit-json {:handlers writers}}
:ring-swagger options for ring-swagger's swagger-json method.
e.g. {:ignore-missing-mappings? true}
:coercion A function from request->type->coercion-matcher, used
in endpoint coercion for :body, :string and :response.
Defaults to (constantly compojure.api.middleware/default-coercion-matchers)
Setting value to nil disables all coercion
:components Components which should be accessible to handlers using :components restructuring. (If you are using api, you might want to take look at using wrap-components middleware manually.). Defaults to nil (middleware not mounted).
Returns a ring handler wrapped in compojure.api.middleware/api-middlware. Creates the route-table at api creation time and injects that into the request via middlewares. Api and the mounted api-middleware can be configured by optional options map as the first parameter: (api {:formats [:json-kw :edn :transit-msgpack :transit-json] :exceptions {:handlers {:compojure.api.exception/default my-logging-handler}} :api {:invalid-routes-fn (constantly nil)} :swagger {:spec "/swagger.json" :ui "/api-docs" :data {:info {:version "1.0.0" :title "My API" :description "the description"}}}} (context "/api" [] ...)) ### direct api options: - **:api** All api options are under `:api`. - **:invalid-routes-fn** A 2-arity function taking handler and a sequence of invalid routes (not satisfying compojure.api.route.Routing) setting value to nil ignores invalid routes completely. defaults to `compojure.api.routes/log-invalid-child-routes` - **:disable-api-middleware?** boolean to disable the `api-middleware` from api. - **:swagger** Options to configure the Swagger-routes. Defaults to nil. See `compojure.api.swagger/swagger-routes` for details. ### api-middleware options Opinionated chain of middlewares for web apis. Takes optional options-map. ### Exception handlers An error handler is a function of exception, ex-data and request to response. When defining these options, it is suggested to use alias for the exceptions namespace, e.g. `[compojure.api.exception :as ex]`. Default: {::ex/request-validation ex/request-validation-handler ::ex/request-parsing ex/request-parsing-handler ::ex/response-validation ex/response-validation-handler ::ex/default ex/safe-handler} Note: Because the handlers are merged into default handlers map, to disable default handler you need to provide `nil` value as handler. Note: To catch Schema errors use `{:schema.core/error ex/schema-error-handler}`. ### Options - **:exceptions** for *compojure.api.middleware/wrap-exceptions* (nil to unmount it) - **:handlers** Map of error handlers for different exception types, type refers to `:type` key in ExceptionInfo data. - **:format** for ring-middleware-format middlewares (nil to unmount it) - **:formats** sequence of supported formats, e.g. `[:json-kw :edn]` - **:params-opts** for *ring.middleware.format-params/wrap-restful-params*, e.g. `{:transit-json {:handlers readers}}` - **:response-opts** for *ring.middleware.format-params/wrap-restful-response*, e.g. `{:transit-json {:handlers writers}}` - **:ring-swagger** options for ring-swagger's swagger-json method. e.g. `{:ignore-missing-mappings? true}` - **:coercion** A function from request->type->coercion-matcher, used in endpoint coercion for :body, :string and :response. Defaults to `(constantly compojure.api.middleware/default-coercion-matchers)` Setting value to nil disables all coercion - **:components** Components which should be accessible to handlers using :components restructuring. (If you are using api, you might want to take look at using wrap-components middleware manually.). Defaults to nil (middleware not mounted).
(copy-json-schema-meta src dest)
Copies JSON schema metadata from one schema element to another. This is useful in cases where a transformation is being applied to a metadata schema element, and the metadata has to be copied from the original element to the transformed one.
Copies JSON schema metadata from one schema element to another. This is useful in cases where a transformation is being applied to a metadata schema element, and the metadata has to be copied from the original element to the transformed one.
(defapi name & body)
Defines an api.
API middleware options:
Opinionated chain of middlewares for web apis. Takes optional options-map.
An error handler is a function of exception, ex-data and request to response.
When defining these options, it is suggested to use alias for the exceptions namespace,
e.g. [compojure.api.exception :as ex]
.
Default:
{::ex/request-validation ex/request-validation-handler
::ex/request-parsing ex/request-parsing-handler
::ex/response-validation ex/response-validation-handler
::ex/default ex/safe-handler}
Note: Because the handlers are merged into default handlers map, to disable default handler you
need to provide nil
value as handler.
Note: To catch Schema errors use {:schema.core/error ex/schema-error-handler}
.
:exceptions for compojure.api.middleware/wrap-exceptions (nil to unmount it)
:type
key in ExceptionInfo data.:format for ring-middleware-format middlewares (nil to unmount it)
[:json-kw :edn]
{:transit-json {:handlers readers}}
{:transit-json {:handlers writers}}
:ring-swagger options for ring-swagger's swagger-json method.
e.g. {:ignore-missing-mappings? true}
:coercion A function from request->type->coercion-matcher, used
in endpoint coercion for :body, :string and :response.
Defaults to (constantly compojure.api.middleware/default-coercion-matchers)
Setting value to nil disables all coercion
:components Components which should be accessible to handlers using :components restructuring. (If you are using api, you might want to take look at using wrap-components middleware manually.). Defaults to nil (middleware not mounted).
Defines an api. API middleware options: Opinionated chain of middlewares for web apis. Takes optional options-map. ### Exception handlers An error handler is a function of exception, ex-data and request to response. When defining these options, it is suggested to use alias for the exceptions namespace, e.g. `[compojure.api.exception :as ex]`. Default: {::ex/request-validation ex/request-validation-handler ::ex/request-parsing ex/request-parsing-handler ::ex/response-validation ex/response-validation-handler ::ex/default ex/safe-handler} Note: Because the handlers are merged into default handlers map, to disable default handler you need to provide `nil` value as handler. Note: To catch Schema errors use `{:schema.core/error ex/schema-error-handler}`. ### Options - **:exceptions** for *compojure.api.middleware/wrap-exceptions* (nil to unmount it) - **:handlers** Map of error handlers for different exception types, type refers to `:type` key in ExceptionInfo data. - **:format** for ring-middleware-format middlewares (nil to unmount it) - **:formats** sequence of supported formats, e.g. `[:json-kw :edn]` - **:params-opts** for *ring.middleware.format-params/wrap-restful-params*, e.g. `{:transit-json {:handlers readers}}` - **:response-opts** for *ring.middleware.format-params/wrap-restful-response*, e.g. `{:transit-json {:handlers writers}}` - **:ring-swagger** options for ring-swagger's swagger-json method. e.g. `{:ignore-missing-mappings? true}` - **:coercion** A function from request->type->coercion-matcher, used in endpoint coercion for :body, :string and :response. Defaults to `(constantly compojure.api.middleware/default-coercion-matchers)` Setting value to nil disables all coercion - **:components** Components which should be accessible to handlers using :components restructuring. (If you are using api, you might want to take look at using wrap-components middleware manually.). Defaults to nil (middleware not mounted).
(defroutes name & routes)
Define a Ring handler function from a sequence of routes. The name may optionally be followed by a doc-string and metadata map.
Define a Ring handler function from a sequence of routes. The name may optionally be followed by a doc-string and metadata map.
(describe schema desc & kvs)
Attach description and possibly other meta-data to a schema.
Attach description and possibly other meta-data to a schema.
(middleware middleware & body)
Wraps routes with given middleware using thread-first macro.
Note that middlewares will be executed even if routes in body do not match the request uri. Be careful with middleware that has side-effects.
Wraps routes with given middleware using thread-first macro. Note that middlewares will be executed even if routes in body do not match the request uri. Be careful with middleware that has side-effects.
(routes & handlers)
Create a Ring handler by combining several handlers into one.
Create a Ring handler by combining several handlers into one.
(swagger-routes)
(swagger-routes options)
Returns routes for swagger-articats (ui & spec). Accepts an options map, with the following options: :ui Path for the swagger-ui (defaults to "/"). Setting the value to nil will cause the swagger-ui not to be mounted :spec Path for the swagger-spec (defaults to "/swagger.json") Setting the value to nil will cause the swagger-ui not to be mounted :data Swagger data in the Ring-Swagger format. :options :ui Options to configure the ui :spec Options to configure the spec. Nada at the moment. Example options: {:ui "/api-docs" :spec "/swagger.json" :options {:ui {:jsonEditor true} :spec {}} :data {:basePath "/app" :info {:version "1.0.0" :title "Sausages" :description "Sausage description" :termsOfService "http://helloreverb.com/terms/" :contact {:name "My API Team" :email "foo@example.com" :url "http://www.metosin.fi"} :license {:name: "Eclipse Public License" :url: "http://www.eclipse.org/legal/epl-v10.html"}} :tags [{:name "sausages", :description "Sausage api-set"}]}}
Returns routes for swagger-articats (ui & spec). Accepts an options map, with the following options: **:ui** Path for the swagger-ui (defaults to "/"). Setting the value to nil will cause the swagger-ui not to be mounted **:spec** Path for the swagger-spec (defaults to "/swagger.json") Setting the value to nil will cause the swagger-ui not to be mounted **:data** Swagger data in the Ring-Swagger format. **:options** **:ui** Options to configure the ui **:spec** Options to configure the spec. Nada at the moment. Example options: {:ui "/api-docs" :spec "/swagger.json" :options {:ui {:jsonEditor true} :spec {}} :data {:basePath "/app" :info {:version "1.0.0" :title "Sausages" :description "Sausage description" :termsOfService "http://helloreverb.com/terms/" :contact {:name "My API Team" :email "foo@example.com" :url "http://www.metosin.fi"} :license {:name: "Eclipse Public License" :url: "http://www.eclipse.org/legal/epl-v10.html"}} :tags [{:name "sausages", :description "Sausage api-set"}]}}
(transform-enum enum f)
Converts the items in an enumeration using a provided transformation function.
Converts the items in an enumeration using a provided transformation function.
(undocumented & handlers)
Routes without route-documentation. Can be used to wrap routes, not satisfying compojure.api.routes/Routing -protocol.
Routes without route-documentation. Can be used to wrap routes, not satisfying compojure.api.routes/Routing -protocol.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close