Skip to content

Commit

Permalink
form-params
Browse files Browse the repository at this point in the history
  • Loading branch information
frenchy64 committed Apr 24, 2024
1 parent 5439ca6 commit ad6dd6e
Show file tree
Hide file tree
Showing 3 changed files with 162 additions and 129 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ See also: [compojure-api 1.1.x changelog](./CHANGELOG-1.1.x.md)
## NEXT
* Throw an error on malformed `:{body,query,headers}`, in particular is anything other than 2 elements was provided
* Disable check with `-Dcompojure.api.meta.allow-bad-{body,query,headers}=true`
* 50% reduction in the number of times `:{return,body,query,responses,headers,body-params}` schemas are evaluated
* 50% reduction in the number of times `:{return,body,query,responses,headers,body-params,form-params}` schemas are evaluated
* saves 1 evaluation per schema for static contexts
* saves 1 evaluation per schema, per request, for dynamic contexts
* Merge `:form-params` `:info :public :parameters :formData` field at runtime

## 2.0.0-alpha32 (2024-03-20)

Expand Down
8 changes: 5 additions & 3 deletions src/compojure/api/meta.clj
Original file line number Diff line number Diff line change
Expand Up @@ -438,10 +438,12 @@
" (ok {:total (+ x y)}))")))

(defmethod restructure-param :form-params [_ form-params acc]
(let [schema (strict (fnk-schema form-params))]
(let [schema (strict (fnk-schema form-params))
g (gensym 'form-params-schema)]
(-> acc
(update-in [:letks] into [form-params (src-coerce! schema :form-params :string)])
(update-in [:info :public :parameters :formData] st/merge schema)
(update :outer-lets into [g schema])
(update-in [:letks] into [form-params (src-coerce! g :form-params :string)])
(update-in [:info :public :parameters :formData] #(if % (list `st/merge % g) g))
(assoc-in [:info :public :consumes] ["application/x-www-form-urlencoded"]))))

;;
Expand Down
Loading

0 comments on commit ad6dd6e

Please sign in to comment.