metosin / metosin/spec-tools

missing swagger support for `spec/coll-of`

Open
#175 1 comment 0 reactions 0 assignees View on GitHub
help wanted
Dominant language
Clojure
Stars
606
Forks
90
PR merge metrics
No merged PRs in 30d

Description

`spec-tools.visitor` has
`(defmethod visit-spec 'clojure.spec.alpha/coll-of ...)` which ends up dispatching on
```
(case type
:map-of ::map-of
:set ::set-of
:vector ::vector-of)
```
while there is no implementation of `accept-spec` for any of `#{::visitor/map-of, ::visitor/set-of, ::visitor/vector-of}`

I've tried to add a
```
(defmethod swagger/accept-spec ::vector-of [_ _ children _]
(println "CHILDREN-VECTOR-OF" (util/pp children))
{:enum children :type "string"})
```
this prints `CHILDREN-VECTOR-OF [{}]`

This leads me to suspect that the implementation of `visit-spec` for `clojure.spec.alpha/coll-of` is flawed.

Contributor guide

Open the contributing guide

Research direction

Start in spec-tools.visitor at the visit-spec implementation for clojure.spec.alpha/coll-of, then trace the swagger/accept-spec dispatch for ::visitor/map-of, ::visitor/set-of, and ::visitor/vector-of. Reproduce the reported children value and determine what support is needed for each collection type; done means coll-of specs produce correct Swagger output without the missing dispatch or malformed children.

Written by the indexing model from the issue text.

Assessment

Tech stack
clojure
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.