Skip to content

Commit

Permalink
release 0.11.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Deraen committed Aug 10, 2014
1 parent c20e4cb commit 8409fe4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## 0.11.0 (x.x.2014)
## 0.11.0 (10.8.2014)

- Removed `ring.swagger.schema/defmodel`, please use `schema.core/defschema`.
- Split JSON Schema generation to a `json-schema` module.
- Refactored Json schema transformations
- New `describe` helper:
- Instead of `(field Long {:description "The description"})` you can use
Expand Down
25 changes: 16 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
## Latest version

```clojure
[metosin/ring-swagger "0.10.6"]
[metosin/ring-swagger "0.11.0"]
```

## Web libs using Ring-Swagger
Expand Down Expand Up @@ -158,20 +158,27 @@ Customer

JSON Schema generation is implemented using multimethods. You can register your own schema types by installing new methods to the multimethods.

### Class-based dispatch

```clojure
(require '[ring.swagger.core :as swagger])
(require '[ring.swagger.json-schema :as jsons])
(require '[schema.core :as s])
(defmethod swagger/json-type-class s/Maybe [e] (swagger/->json (:schema e)))
(defmethod jsons/json-type s/Maybe [e] (swagger/->json (:schema e)))
(defmethod jsons/json-type s/Any [_] {:type "string"})
```

### Identity-based dispatch
## Describing schemas

You can add e.g. description to you schemas using `ring.swagger.schema/field` and `ring.swagger.schema/describe` functions.
These work by adding meta-data to schema under `:json-schema`-key. Objects which don't support meta-data, like Java classes, are
wrapped into `s/both`.

```clojure
(require '[ring.swagger.core :as swagger])
(require '[schema.core :as s])
(defmethod swagger/json-type s/Any [_] {:type "string"})
(s/defschema Customer {:id Long
:name (describe String "the name")
(s/optional-key :address) (describe {:street String
:country Country}
"The Address")})

(= (jsons/json-schema-meta (describe Customer "The Customer")) {:description "The Customer"})
```

## TODO
Expand Down

0 comments on commit 8409fe4

Please sign in to comment.