Skip to content

Support for ring.swagger.json-schema/describe #95

@christophe-riolo

Description

@christophe-riolo

Hello,

In my project I have used ring.swagger.json-schema/describe to annotate some types

(require '[ring.swagger.json-schema :refer [describe]] '[schema.core :as s])
(s/defschema Foo (describe s/Str "Not very bar"))

However the schema-tools.swagger.core/transform failed on this

(require '[schema-tools.swagger.core])
(schema-tools.swagger.core/transform Foo nil)
;; Execution error (ExceptionInfo) at schema-tools.swagger.core/not-supported! (core.cljc:56).
;; don't know how to convert ring.swagger.json_schema.FieldSchema@8d6443 into a Swagger Schema. 

I have had to do the following

(import ring.swagger.json_schema.FieldSchema)
(extend-protocol schema-tools.swagger.core/SwaggerSchema
  FieldSchema
  (-transform [this opts]
    (schema-tools.swagger.core/transform (.schema this) opts)))

to get it working.

I am not sure if there should be support for this module in schema-tools, but at least it gave me some headache while trying to move from compojure-api to Reitit, so maybe it should be supported somewhere in the toolchain if I am not alone using that function !

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Not right now

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions