Closed eunmin closed 8 years ago
Hi! I am having trouble when I use s/defrecord (issue #103):
(s/defrecord User [id :- s/Str name :- s/Str]) {:responses {200 {:schema User :description "Found it!"} 404 {:description "Ohnoes."}}}
but ring-swagger throws:
500 : {"type":"unknown-exception","class":"java.lang.IllegalArgumentException"} http://localhost:3000/swagger.json
JsonSchema
s/defrecord
convert-class
schema.core.Record
schema.utils/class-schema
(require '[schema.utils :as su]) {:responses {200 {:schema (:schema (su/class-schmea User)) :description "Found it!"} 404 {:description "Ohnoes."}}}
But plain map doesn't have name. So I Add schema name using schema.core/schema-with-name.
schema.core/schema-with-name
Usage with compojure-api:
(ns luminus-swagger.routes.services (:require [ring.util.http-response :refer :all] [compojure.api.sweet :refer :all] [ring.swagger.schema :as rss] [schema.core :as s])) (s/defrecord User [id :- s/Str name :- s/Str]) (defapi service-routes {:swagger {:ui "/swagger-ui" :spec "/swagger.json" :data {:info {:version "1.0.0" :title "Sample API" :description "Sample Services"}}}} (context "/users" [] :tags ["user"] (POST "/" [] :return (rss/class-schema User) :body [user (rss/class-schema User)] :summary "create user" (ok))))
This will be solved by supporting schema.core/defrecord directly, #103.
schema.core/defrecord
Hi! I am having trouble when I use s/defrecord (issue #103):
but ring-swagger throws:
JsonSchema
Protocol:s/defrecord
type is Class.convert-class
is not supportedschema.core.Record
.schema.core.Record
usingschema.utils/class-schema
.But plain map doesn't have name. So I Add schema name using
schema.core/schema-with-name
.Usage with compojure-api: