diff --git a/doc/ring/openapi.md b/doc/ring/openapi.md index 7515b933..b2288575 100644 --- a/doc/ring/openapi.md +++ b/doc/ring/openapi.md @@ -139,6 +139,7 @@ Malli: [:x {:title "X parameter" :description "Description for X parameter" + :json-schema/deprecated true :json-schema/default 42} int?] [:y int?]]}}}] @@ -151,6 +152,7 @@ Schema: {:post {:parameters {:body {:x (schema-tools.core/schema s/Num {:description "Description for X parameter" + :openapi/deprecated true :openapi/example 13 :openapi/default 42}) :y int?}}}}] @@ -165,6 +167,7 @@ Spec: {:body (spec-tools.data-spec/spec ::foo {:x (schema-tools.core/spec {:spec int? :description "Description for X parameter" + :openapi/deprecated true :openapi/example 13 :openapi/default 42}) :y int?}}}}}] diff --git a/examples/openapi/src/example/server.clj b/examples/openapi/src/example/server.clj index 83e3a6b0..6c4ae3e7 100644 --- a/examples/openapi/src/example/server.clj +++ b/examples/openapi/src/example/server.clj @@ -97,6 +97,10 @@ :json-schema/default 30 :json-schema/example 10} int?] + [:charset {:title "Which charset to use?" + :optional true + :json-schema/deprecated true} + string?] [:email {:title "Email address to search for" :json-schema/format "email"} string?]]} diff --git a/modules/reitit-openapi/src/reitit/openapi.clj b/modules/reitit-openapi/src/reitit/openapi.clj index 979620eb..aade0b60 100644 --- a/modules/reitit-openapi/src/reitit/openapi.clj +++ b/modules/reitit-openapi/src/reitit/openapi.clj @@ -110,8 +110,8 @@ (merge {:in (name in) :name k :required (required? k) - :schema schema} - (select-keys schema [:description]))) + :schema (dissoc schema :description :deprecated)} + (select-keys schema [:description :deprecated]))) (into []))}) (when body ;; :body uses a single schema to describe every :requestBody diff --git a/test/cljc/reitit/openapi_test.clj b/test/cljc/reitit/openapi_test.clj index c474fbf3..6ad6c215 100644 --- a/test/cljc/reitit/openapi_test.clj +++ b/test/cljc/reitit/openapi_test.clj @@ -47,7 +47,9 @@ ["/plus/:z" {:get {:summary "plus" :tags [:plus :spec] - :parameters {:query {:x int?, :y int?} + :parameters {:query {:x int?, :y (st/spec {:spec int? + :description "this is deprecated" + :openapi/deprecated true})} :path {:z int?}} :openapi {:operationId "spec-plus" :deprecated true @@ -78,7 +80,8 @@ ["/plus/*z" {:get {:summary "plus" :tags [:plus :malli] - :parameters {:query [:map [:x int?] [:y int?]] + :parameters {:query [:map [:x int?] [:y {:json-schema/deprecated true + :description "this is deprecated"} int?]] :path [:map [:z int?]]} :openapi {:responses {400 {:description "kosh" :content {"application/json" {:schema {:type "string"}}}}}} @@ -107,7 +110,8 @@ ["/plus/*z" {:get {:summary "plus" :tags [:plus :schema] - :parameters {:query {:x s/Int, :y s/Int} + :parameters {:query {:x s/Int, :y (schema-tools.core/schema s/Int {:description "this is deprecated" + :openapi/deprecated true})} :path {:z s/Int}} :openapi {:responses {400 {:content {"application/json" {:schema {:type "string"}}} :description "kosh"}}} @@ -163,6 +167,8 @@ :format "int64"}} {:in "query" :name "y" + :description "this is deprecated" + :deprecated true :required true :schema {:type "integer" :format "int64"}} @@ -212,6 +218,8 @@ {:in "query" :name :y :required true + :description "this is deprecated" + :deprecated true :schema {:type "integer"}} {:in "path" :name :z @@ -256,6 +264,8 @@ {:in "query" :name "y" :required true + :description "this is deprecated" + :deprecated true :schema {:type "integer" :format "int32"}} {:in "path"