Fork me on GitHub

hey everyone, I am receiving an IllegalrgumentException exception when using a schema.core/constrained schema on compojure-api. The trace is here: I’ve taken a look at the ring-swagger code and it seems like the schema is being wrongly identified as a collection. At first glance, it looks like a bug but I was hoping to get more insight here before posting an issue.


As a side note, the trace is indicating that every-pred cannot be converted into a schema, but I am only using every-pred to compose a few more granular predicates. I am using a schema like this:

(def MySchema (s/constrained AnotherSchema (every-pred predicate-1? predicate-2?)))


That sounds like a bug.


hmm.. but it seems it’s extracting the schema from the first element, which is AnotherSchema. What does that look like?


yeah, that’s also where I got confused, but AnotherSchema is working just fine. I even use just AnotherSchema to replace MySchema and it works ok (they are compatible since MySchema is just a constrained version.


MySchema is just map schema like this:

(s/defschema MySchema
    {:ids [s/Int]
     (s/optional-key :unique) Boolean
     (s/optional-key :start_time) s/Inst
     (s/optional-key :end_time) s/Inst
     (s/optional-key :billing) (s/enum :paid :free :all)})


it has a few other fields but I am confident that does not affect the issue. I can create a minimal example in a gist if you like


I will actually


makes everything easier


thanks. Please write an issue to ring-swagger. Also, if you know how to fix it, PR is most welcome :)


sure, no problem. If I need some guidance, I might just bother again here 😛


will open the issue as soon as I get the chance


I wanted to ask something else. When using compojure-api, I would like to make the schema validation errors more human-friendly before I return them to the client. Is there a recommended way to do so?


thanks in advance


@quimrstorres: haven’t seen a one good way for humane errors with Schema. Some think they are already human-readable 😉 I Believe Michael Drogalis (Onyx) & Bruce Hauman (Figwheel) have done their own parsers on top of schema errors. We have just used error key-paths, e.g. fixed texts for each field - in the UI.


well, that’s true, they are human-readable. maybe just not appropriate for public API interfaces I would say. but thanks, I just wanted to make sure I was going on the right direction 🙂