Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
dzhus committed Nov 26, 2024
2 parents 6a1f515 + dcfc4ba commit 3c9ab67
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Malli is in well matured [alpha](README.md#alpha).

## 0.17.0 (UNRELEASED)

* Don't output `:definitions nil` in swagger. [#1134](https://github.com/metosin/malli/issues/1134)
* **BREAKING**: `:gen/fmap` property requires its schema to create a generator.
* previous behavior defaulted to a `nil`-returning generator, even if the schema doesn't accept `nil`
* use `:gen/return nil` property to restore this behavior
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3429,19 +3429,19 @@ The transformation engine is smart enough to just transform parts of the schema

## Built-in schemas

#### `malli.core/predicate-schemas`
### `malli.core/predicate-schemas`

Contains both function values and unqualified symbol representations for all relevant core predicates. Having both representations enables reading forms from both code (function values) and EDN-files (symbols): `any?`, `some?`, `number?`, `integer?`, `int?`, `pos-int?`, `neg-int?`, `nat-int?`, `pos?`, `neg?`, `float?`, `double?`, `boolean?`, `string?`, `ident?`, `simple-ident?`, `qualified-ident?`, `keyword?`, `simple-keyword?`, `qualified-keyword?`, `symbol?`, `simple-symbol?`, `qualified-symbol?`, `uuid?`, `uri?`, `decimal?`, `inst?`, `seqable?`, `indexed?`, `map?`, `vector?`, `list?`, `seq?`, `char?`, `set?`, `nil?`, `false?`, `true?`, `zero?`, `rational?`, `coll?`, `empty?`, `associative?`, `sequential?`, `ratio?`, `bytes?`, `ifn?` and `fn?`.

#### `malli.core/class-schemas`
### `malli.core/class-schemas`

Class-based schemas, contains `java.util.regex.Pattern` & `js/RegExp`.

#### `malli.core/comparator-schemas`
### `malli.core/comparator-schemas`

Comparator functions as keywords: `:>`, `:>=`, `:<`, `:<=`, `:=` and `:not=`.

#### `malli.core/type-schemas`
### `malli.core/type-schemas`

Type-like schemas: `:any`, `:some`, `:nil`, `:string`, `:int`, `:double`, `:boolean`, `:keyword`, `:qualified-keyword`, `:symbol`, `:qualified-symbol`, and `:uuid`.

Expand Down
3 changes: 2 additions & 1 deletion src/malli/swagger.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,12 @@
parameters (:parameters expanded)
responses (:responses expanded)
definitions (apply merge
(:definitions acc)
(concat
(->> responses vals (map (comp :definitions :schema)))
(->> parameters (map (comp :definitions :schema)))))]
(-> acc (dissoc k) (merge expanded)
(update :definitions merge definitions)
(merge (when-not (empty? definitions) [:definitions definitions]))
dissoc-non-root-definitions))
acc))
x x)
Expand Down
9 changes: 3 additions & 6 deletions test/malli/swagger_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,7 @@

(deftest swagger-spec-test
(testing "generates swagger for ::parameters and ::responses w/ basic schema"
(is (= {:definitions nil
:parameters [{:description ""
(is (= {:parameters [{:description ""
:in "body"
:name "body"
:required true
Expand Down Expand Up @@ -439,8 +438,7 @@
{:registry registry})}}})))))

(testing "no schema in responses ignored"
(is (= {:definitions nil
:responses {200 {:description "" :schema {:type "string"}}
(is (= {:responses {200 {:description "" :schema {:type "string"}}
500 {:description "fail"}}}
(swagger/swagger-spec {::swagger/responses
{500 {:description "fail"}
Expand Down Expand Up @@ -518,8 +516,7 @@
::swagger/responses {200 {:schema #'Success}}}))))
(testing "::parameters :query w/ var schema"
;; NB! all refs get inlined!
(is (= {:definitions nil
:parameters [{:description ""
(is (= {:parameters [{:description ""
:in "query"
:name :a
:required true
Expand Down

0 comments on commit 3c9ab67

Please sign in to comment.