metosin / metosin/compojure-api
How do I specify an optional field when accepting multipart-params for a request?
Open
Nobody has claimed this yet.
- Dominant language
- Clojure
- Stars
- 1.1k
- Forks
- 146
- PR merge metrics
- No merged PRs in 30d
Description
Library Version(s)
2.0.0-alpha31
Problem
(POST "/test-route" request
:multipart-params [optional_data :- s/Str]
:middleware [admin-rbac upload/wrap-multipart-params]
(res/ok "ok"))
In this example, optional_data is not a mandatory argument. How do I tell the framework to accept requests which do not provide this field. I've tried these and they don't work:
...
:multipart-params [optional_data :- s/Str nil]
...
...
:multipart-params [optional_data :- (s/maybe s/Str)]
...
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the route using :multipart-params and the upload/wrap-multipart-params middleware described in the issue, on version 2.0.0-alpha31. Read the multipart parameter handling and schema validation entry points to determine whether an omitted optional_data field is supported; done means identifying the accepted syntax or documenting the missing behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- clojure
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100