|
1 |
| -(ns compojure.api.sweet |
2 |
| - (:require compojure.api.core |
3 |
| - compojure.api.api |
4 |
| - compojure.api.routes |
5 |
| - compojure.api.resource |
6 |
| - compojure.api.swagger |
7 |
| - ring.swagger.json-schema |
8 |
| - [potemkin :refer [import-vars]])) |
9 |
| - |
10 |
| -(import-vars |
11 |
| - |
12 |
| - [compojure.api.core routes defroutes let-routes undocumented |
13 |
| - context GET ANY HEAD PATCH DELETE OPTIONS POST PUT] |
14 |
| - |
15 |
| - [compojure.api.api api] |
16 |
| - |
17 |
| - [compojure.api.resource resource] |
18 |
| -[compojure.api.routes path-for] |
19 |
| - |
20 |
| - [compojure.api.swagger swagger-routes] |
21 |
| -[ring.swagger.json-schema describe]) |
| 1 | +;; NOTE: This namespace is generated by compojure.api.dev.gen |
| 2 | +(ns compojure.api.sweet (:require compojure.api.core compojure.api.api compojure.api.routes compojure.api.resource compojure.api.swagger ring.swagger.json-schema)) |
| 3 | +(def ^{:arglists (quote ([& handlers])), :doc "Create a Ring handler by combining several handlers into one."} routes compojure.api.core/routes) |
| 4 | +(defmacro defroutes {:doc "Define a Ring handler function from a sequence of routes.\n The name may optionally be followed by a doc-string and metadata map."} [name & routes] (list* (quote compojure.api.core/defroutes) name routes)) |
| 5 | +(defmacro let-routes {:doc "Takes a vector of bindings and a body of routes.\n\n Equivalent to: `(let [...] (routes ...))`"} [bindings & body] (list* (quote compojure.api.core/let-routes) bindings body)) |
| 6 | +(def ^{:arglists (quote ([& handlers])), :doc "Routes without route-documentation. Can be used to wrap routes,\n not satisfying compojure.api.routes/Routing -protocol."} undocumented compojure.api.core/undocumented) |
| 7 | +(defmacro context [& args] (list* (quote compojure.api.core/context) args)) |
| 8 | +(defmacro GET [& args] (list* (quote compojure.api.core/GET) args)) |
| 9 | +(defmacro ANY [& args] (list* (quote compojure.api.core/ANY) args)) |
| 10 | +(defmacro HEAD [& args] (list* (quote compojure.api.core/HEAD) args)) |
| 11 | +(defmacro PATCH [& args] (list* (quote compojure.api.core/PATCH) args)) |
| 12 | +(defmacro DELETE [& args] (list* (quote compojure.api.core/DELETE) args)) |
| 13 | +(defmacro OPTIONS [& args] (list* (quote compojure.api.core/OPTIONS) args)) |
| 14 | +(defmacro POST [& args] (list* (quote compojure.api.core/POST) args)) |
| 15 | +(defmacro PUT [& args] (list* (quote compojure.api.core/PUT) args)) |
| 16 | +(def ^{:arglists (quote ([& body])), :doc "Returns a ring handler wrapped in compojure.api.middleware/api-middlware.\n Creates the route-table at api creation time and injects that into the request via\n middlewares. Api and the mounted api-middleware can be configured by optional\n options map as the first parameter:\n\n (api\n {:exceptions {:handlers {:compojure.api.exception/default my-logging-handler}}\n :api {:invalid-routes-fn (constantly nil)}\n :swagger {:spec \"/swagger.json\"\n :ui \"/api-docs\"\n :data {:info {:version \"1.0.0\"\n :title \"My API\"\n :description \"the description\"}}}}\n (context \"/api\" []\n ...))\n\n ### direct api options:\n\n - **:api** All api options are under `:api`.\n - **:invalid-routes-fn** A 2-arity function taking handler and a sequence of\n invalid routes (not satisfying compojure.api.route.Routing)\n setting value to nil ignores invalid routes completely.\n defaults to `compojure.api.routes/log-invalid-child-routes`\n - **:disable-api-middleware?** boolean to disable the `api-middleware` from api.\n - **:swagger** Options to configure the Swagger-routes. Defaults to nil.\n See `compojure.api.swagger/swagger-routes` for details.\n\n ### api-middleware options\n\n See `compojure.api.middleware/api-middleware` for more available options.\n\n Opinionated chain of middlewares for web apis. Takes optional options-map.\n\n ### Exception handlers\n\n An error handler is a function of exception, ex-data and request to response.\n\n When defining these options, it is suggested to use alias for the exceptions namespace,\n e.g. `[compojure.api.exception :as ex]`.\n\n Default:\n\n {::ex/request-validation ex/request-validation-handler\n ::ex/request-parsing ex/request-parsing-handler\n ::ex/response-validation ex/response-validation-handler\n ::ex/default ex/safe-handler}\n\n Note: Because the handlers are merged into default handlers map, to disable default handler you\n need to provide `nil` value as handler.\n\n Note: To catch Schema errors use `{:schema.core/error ex/schema-error-handler}`.\n\n ### Options\n\n - **:exceptions** for *compojure.api.middleware/wrap-exceptions* (nil to unmount it)\n - **:handlers** Map of error handlers for different exception types, type refers to `:type` key in ExceptionInfo data.\n\n - **:formats** for Muuntaja middleware. Value can be a valid muuntaja options-map,\n a Muuntaja instance or nil (to unmount it). See\n https://github.com/metosin/muuntaja/blob/master/doc/Configuration.md for details.\n\n - **:middleware** vector of extra middleware to be applied last (just before the handler).\n\n - **:ring-swagger** options for ring-swagger's swagger-json method.\n e.g. `{:ignore-missing-mappings? true}`\n\n - **:coercion** A function from request->type->coercion-matcher, used\n in endpoint coercion for types :body, :string and :response.\n Defaults to `compojure.api.middleware/default-coercion`\n Setting value to nil disables all coercion.\n\n - **:components** Components which should be accessible to handlers using\n :components restructuring. (If you are using api,\n you might want to take look at using wrap-components\n middleware manually.). Defaults to nil (middleware not mounted)."} api compojure.api.api/api) |
| 17 | +(defmacro defapi {:deprecated "2.0.0", :doc "Deprecated: please use (def name (api ...body..))\n \n Defines an api.\n\n API middleware options:\n\n Opinionated chain of middlewares for web apis. Takes optional options-map.\n\n ### Exception handlers\n\n An error handler is a function of exception, ex-data and request to response.\n\n When defining these options, it is suggested to use alias for the exceptions namespace,\n e.g. `[compojure.api.exception :as ex]`.\n\n Default:\n\n {::ex/request-validation ex/request-validation-handler\n ::ex/request-parsing ex/request-parsing-handler\n ::ex/response-validation ex/response-validation-handler\n ::ex/default ex/safe-handler}\n\n Note: Because the handlers are merged into default handlers map, to disable default handler you\n need to provide `nil` value as handler.\n\n Note: To catch Schema errors use `{:schema.core/error ex/schema-error-handler}`.\n\n ### Options\n\n - **:exceptions** for *compojure.api.middleware/wrap-exceptions* (nil to unmount it)\n - **:handlers** Map of error handlers for different exception types, type refers to `:type` key in ExceptionInfo data.\n\n - **:formats** for Muuntaja middleware. Value can be a valid muuntaja options-map,\n a Muuntaja instance or nil (to unmount it). See\n https://github.com/metosin/muuntaja/blob/master/doc/Configuration.md for details.\n\n - **:middleware** vector of extra middleware to be applied last (just before the handler).\n\n - **:ring-swagger** options for ring-swagger's swagger-json method.\n e.g. `{:ignore-missing-mappings? true}`\n\n - **:coercion** A function from request->type->coercion-matcher, used\n in endpoint coercion for types :body, :string and :response.\n Defaults to `compojure.api.middleware/default-coercion`\n Setting value to nil disables all coercion.\n\n - **:components** Components which should be accessible to handlers using\n :components restructuring. (If you are using api,\n you might want to take look at using wrap-components\n middleware manually.). Defaults to nil (middleware not mounted)."} [name & body] (list* (quote compojure.api.api/defapi) name body)) |
| 18 | +(def ^{:arglists (quote ([data])), :doc "Creates a nested compojure-api Route from enchanced ring-swagger operations map.\n By default, applies both request- and response-coercion based on those definitions.\n\n Extra keys:\n\n - **:middleware** Middleware in duct-format either at top-level or under methods.\n Top-level mw are applied first if route matches, method-level\n mw are applied next if method matches\n\n - **:coercion** A function from request->type->coercion-matcher, used\n in resource coercion for :body, :string and :response.\n Setting value to `(constantly nil)` disables both request- &\n response coercion. See tests and wiki for details.\n\n Enchancements to ring-swagger operations map:\n\n 1) :parameters use ring request keys (query-params, path-params, ...) instead of\n swagger-params (query, path, ...). This keeps things simple as ring keys are used in\n the handler when destructuring the request.\n\n 2) at resource root, one can add any ring-swagger operation definitions, which will be\n available for all operations, using the following rules:\n\n 2.1) :parameters are deep-merged into operation :parameters\n 2.2) :responses are merged into operation :responses (operation can fully override them)\n 2.3) all others (:produces, :consumes, :summary,...) are deep-merged by compojure-api\n\n 3) special keys `:handler` and/or `:async-handler` either under operations or at top-level.\n They should be 1-ary and 3-ary Ring handler functions, respectively, that are responsible\n for the actual request processing. Handler lookup order is the following:\n\n 3.1) If called asynchronously, operations-level :async-handler\n 3.2) Operations-level :handler\n 3.3) If called asynchronously, top-level :async-handler\n 3.4) Top-level :handler\n\n 4) request-coercion is applied once, using deep-merged parameters for a given\n operation or resource-level if only resource-level handler is defined.\n\n 5) response-coercion is applied once, using merged responses for a given\n operation or resource-level if only resource-level handler is defined.\n\n Note: Swagger operations are generated only from declared operations (:get, :post, ..),\n despite the top-level handler could process more operations.\n\n Example:\n\n (resource\n {:parameters {:query-params {:x Long}}\n :responses {500 {:schema {:reason s/Str}}}\n :get {:parameters {:query-params {:y Long}}\n :responses {200 {:schema {:total Long}}}\n :handler (fn [request]\n (ok {:total (+ (-> request :query-params :x)\n (-> request :query-params :y))}))}\n :post {}\n :handler (constantly\n (internal-server-error {:reason \"not implemented\"}))})"} resource compojure.api.resource/resource) |
| 19 | +(defmacro path-for {:doc "Extracts the lookup-table from request and finds a route by name."} [route-name & arg2] (list* (quote compojure.api.routes/path-for) route-name arg2)) |
| 20 | +(def ^{:arglists (quote ([] [options])), :doc "Returns routes for swagger-articats (ui & spec). Accepts an options map, with the\n following options:\n\n **:ui** Path for the swagger-ui (defaults to \"/\").\n Setting the value to nil will cause the swagger-ui not to be mounted\n\n **:spec** Path for the swagger-spec (defaults to \"/swagger.json\")\n Setting the value to nil will cause the swagger-ui not to be mounted\n\n **:data** Swagger data in the Ring-Swagger format.\n\n **:options**\n **:ui** Options to configure the ui\n **:spec** Options to configure the spec. Nada at the moment.\n\n Example options:\n\n {:ui \"/api-docs\"\n :spec \"/swagger.json\"\n :options {:ui {:jsonEditor true}\n :spec {}}\n :data {:basePath \"/app\"\n :info {:version \"1.0.0\"\n :title \"Sausages\"\n :description \"Sausage description\"\n :termsOfService \"http://helloreverb.com/terms/\"\n :contact {:name \"My API Team\"\n :email \" [email protected]\"\n :url \"http://www.metosin.fi\"}\n :license {:name: \"Eclipse Public License\"\n :url: \"http://www.eclipse.org/legal/epl-v10.html\"}}\n :tags [{:name \"sausages\", :description \"Sausage api-set\"}]}}"} swagger-routes compojure.api.swagger/swagger-routes) |
| 21 | +(def ^{:arglists (quote ([schema desc & kvs])), :doc "Attach description and possibly other meta-data to a schema."} describe ring.swagger.json-schema/describe) |
0 commit comments