-
-
Save lvh/243576d4e825d3792d4cd1bb8d8c39d7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(s/def ::json-type any?) | |
(s/def ::type | |
#{"object" "array" "integer" "number" "boolean" "string" "null"}) | |
(def schema-type nil) | |
(defmulti schema-type :type) | |
(s/def ::shared-schema-props | |
(s/keys :opt-un [::type ::title ::description ::default])) | |
(s/def ::title string?) | |
(s/def ::description string?) | |
(s/def ::format string?) | |
(s/def ::default ::json-type) | |
(s/def ::schema | |
(s/merge (s/multi-spec schema-type :type) | |
::shared-schema-props)) | |
(s/def ::root-schema ::schema) | |
(defmethod schema-type "object" | |
[_] | |
(s/keys :opt-un [::min-properties | |
::max-properties | |
::additional-properties | |
::required | |
::properties])) | |
(s/def ::min-properties (s/int-in 0 16384)) | |
(s/def ::max-properties (s/int-in 0 16384)) | |
(s/def ::additional-properties | |
(s/or | |
::implicit-additional-properties boolean? | |
::explicit-additional-properties ::schema)) | |
(s/def ::required (s/every string? :distinct true)) | |
(s/def ::properties | |
(s/map-of keyword? ::schema)) | |
(defmethod schema-type "array" | |
[_] | |
::shared-schema-props) | |
(defmethod schema-type "integer" | |
[_] | |
::shared-schema-props) | |
(defmethod schema-type "number" | |
[_] | |
::shared-schema-props) | |
(defmethod schema-type "boolean" | |
[_] | |
::shared-schema-props) | |
(defmethod schema-type "string" | |
[_] | |
::shared-schema-props) | |
(defmethod schema-type "null" | |
[_] | |
::shared-schema-props) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment