`st/strip-extra-keys-transformer` not handling merged `s/or`
Nobody has claimed this yet.
- Dominant language
- Clojure
- Stars
- 606
- Forks
- 90
- PR merge metrics
- No merged PRs in 30d
Description
Similar to #178 and might be related to #264
When having a spec with merge of an or-spec, `st/strip-extra-keys-transformer` removes too many keys. However it seems to be an issue with parsing of the specs.
```clojure
(ns merged-or.test
(:require [clojure.spec.alpha :as s]
[spec-tools.core :as st]))
(s/def ::a int?)
(s/def ::doors int?)
(s/def ::wheels int?)
(s/def ::car (s/keys :req-un [::doors]))
(s/def ::bike (s/keys :req-un [::wheels]))
(s/def ::vehicle (s/or :car ::car
:bike ::bike))
(s/def ::merged-or (s/merge ::vehicle
(s/keys :opt-un [::a])))
(s/def ::merged-or-reversed (s/merge (s/keys :opt-un [::a])
::vehicle))
(let [chevy {:doors 4 :a 1}]
[(st/coerce ::merged-or chevy st/json-transformer)
(st/coerce ::merged-or chevy st/strip-extra-keys-transformer)
(st/coerce ::merged-or-reversed chevy st/strip-extra-keys-transformer)])
; => [{:doors 4, :a 1}
; {:a 1}
; {:doors 4, :a 1}]
```
I've not been able to create a fix :(
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
Start by running the provided reproduction around st/coerce with st/strip-extra-keys-transformer. Trace how merged s/or specs are parsed and transformed, then verify that both ::merged-or and ::merged-or-reversed preserve :doors and :a for the sample input.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- clojure
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100