-
-
Notifications
You must be signed in to change notification settings - Fork 13
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
clojure.lang.ExceptionInfo: Input to annotate does not match schema #24
Comments
Hi, Are you sure you want |
I'm quite sure that the examples say to use |
Ah yes, you are right - ring calls it |
This is unrelated to using #!/bin/sh
#_(
DEPS='
{:deps {pedestal-api {:mvn/version "0.3.4"}
io.pedestal/pedestal.jetty {:mvn/version "0.5.5"}
io.pedestal/pedestal.service {:mvn/version "0.5.5"}}}
'
OPTS='
-J-Xms256m -J-Xmx256m -J-client
'
exec clojure $OPTS -Sdeps "$DEPS" "$0" "$@"
)
(require '[pedestal-api.core :as api])
(require '[schema.core :as s])
(require '[io.pedestal.interceptor :refer [interceptor]])
(import 'java.util.UUID)
(s/defschema Pet
{:name s/Str
:type s/Str
:age s/Int})
(def create-pet
(s/with-fn-validation
(api/annotate
{:summary "Create a pet"
:parameters {:body-params Pet}
:responses {201 {:body {:id s/Uuid}}}
:operationId :create-pet}
(interceptor
{:name ::create-pet
:enter (fn [ctx]
(let [id (UUID/randomUUID)]
(assoc ctx :response
{:status 201
:body {:id id}})))})))) Executing causes:
|
The issue is that the Operation schema in ring-swagger does not accept keys I worked around this by simply using the annotate function with the schema removed: (defn annotate
"Attaches swagger documentation to an object."
[doc obj]
(vary-meta obj assoc ::doc doc)) The schema is not particularly useful here since it only checks for key existence. But you could certainly add in a correct schema if you choose. |
I'm trying to use schema.core/with-fn-validation on my tests but I'm getting the error above. I think this schema is too strict for the use on this library but changing it would need changes on https://github.com/metosin/ring-swagger
Do you have a suggestion on how to fix this? Thanks!
The text was updated successfully, but these errors were encountered: