metosin / spec-tools

Clojure(Script) tools for clojure.spec

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Inline models with data-spec

rgould1 opened this issue · comments

Working with reitit and being able to inline data-specs for parameters and responses is invaluable, however, I'm now starting to use Swagger to work with other teams in my organisation hitting friction due to the models associated with data-specs being untitled and 'inlined'. Short of pulling out each nested object and registering it, is there a way of getting names into my models?

As an example, here's a typical end point description and it's rendering in Swagger.

  ["api-config-auth-types"
     {:swagger {:tags ["connections"]}
      :get     {:handler    #'connections/auth-types
                :parameters {:path {:account-id ::account-id}}
                :responses  {:200 {:body [{:display-name string?
                                                         :id   int?
                                          :fields       [{:name string?
                                                          :hide boolean?
                                                          :id   string?}]}]}}}}]

image

There is spec-tools.data-spec that can be used to inject spec data like :name that is used to name the models. Data-specs is kinda too simple for this, sorry. In process of creating malli that solves this more elegantly.