Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support schema Any #76

Closed
nha opened this issue Mar 19, 2016 · 2 comments
Closed

support schema Any #76

nha opened this issue Mar 19, 2016 · 2 comments

Comments

@nha
Copy link
Contributor

nha commented Mar 19, 2016

When using prismatic/schema Any yada.coerce throws an error :

For instance :
:parameters {:query { (sch/optional-key sch/Any) sch/Any}} will throw :

java.lang.IllegalArgumentException: No implementation of method: :to-key of protocol: #'yada.coerce/ParameterKey found for class: schema.core.AnythingSchema
@Frozenlock
Copy link
Contributor

Shouldn't it be like this? :

:parameters {:query { (sch/optional-key :my-key) sch/Any}}

I think optional-key expects a keyword.

@nha
Copy link
Contributor Author

nha commented Mar 19, 2016

Oh you are right. Here is a correct example with schema :

(schema/validate {schema/Any schema/Any} {});; => {}
(schema/validate {schema/Any schema/Any} {:a 1 :b 2});; => {:a 1 :b 2}

However in yada, this gives me a 500 error :

(yada (yada/resource {:methods { :get {:parameters {:query {sch/Any sch/Any}}
                                       :response (fn [ctx]
                                                   ...)}}}))
ERROR aleph.http.server - error in HTTP handler
java.lang.IllegalArgumentException: No implementation of method: :to-key of protocol: #'yada.coerce/ParameterKey found for class: schema.core.AnythingSchema

Note : in this particular case removing the validation would have the same effect and this is not urgent for me.

griff added a commit to griff/yada that referenced this issue Apr 6, 2016
This adds support for having a schema as a key in resource query
parameters definition. This means that query parameters now support
defining some required and optional query parameters and then specifing
a schema that all other parameters must match.

I have also added more test cases for parse-parameters.

Fixes: juxt#76
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants