 (s/defschema Authorization
   {(s/optional-key :authorization) s/Any})
 
+(s/defschema RealmValue
+  (merge AuthSchemes Authorization NamespacedEntries))
+
 (s/defschema Realms
   {(s/optional-key :realms)
-   {Realm (merge AuthSchemes Authorization NamespacedEntries)}})
+   {Realm RealmValue}})
 
 (s/defschema Cors
   {(s/optional-key :allow-origin) (s/conditional fn? (s/=> (s/conditional ifn? #{s/Str} :else s/Str) Context) :else StringSet)

       x))})

(def SingleSchemeMapping
  {(merge AuthSchemes Authorization NamespacedEntries)
   (fn [x]
     (if (:verify x)
       (-> x

   (s/optional-key :allow-methods) (s/conditional fn? ContextFunction :else Keywords)
   (s/optional-key :allow-headers) (s/conditional fn? ContextFunction :else Strings)})

(s/defschema AccessControlValue
  (merge Realms Cors NamespacedEntries))

(s/defschema AccessControl
  {(s/optional-key :access-control) AccessControlValue})

;; Here is some tricky code, caused by the necessity to compose the
;; 'data macros'. The realm short-hand has to rewrite the data, which
;; may include the scheme in short or long form, which makes it
;; difficult to find an approach that preserves schema integrity while
;; decoupling the data macros from each other. The consequence is that
;; these mappings have some intimate knowledge of each other's
;; structure, but the trade-off of more difficult maintenance is
;; deemed worth it for the value to the user of being able to use
;; short-hands. For an explanation of data macros, see
;; https://blog.juxt.pro/posts/data-macros.html

(def SingleRealmMapping
  {AccessControlValue
   (fn [x]
     (if-let [realm (:realm x)]
       (-> x
