LCOV - code coverage report
Current view: top level - schemas/api - account.clj Coverage Total Hit
Test: lcov.info Lines: 100.0 % 43 43
Test Date: 2026-11-23 18:11:10 Functions: - 0 0

            Line data    Source code
       1            4 : (ns schemas.api.account
       2              :   (:require
       3              :    [schemas.domain.user :as domain-user-schemas]))
       4              : 
       5              : 
       6           47 : (defn- stringify-keys [m] (if (map? m) (update-keys m #(if (keyword? %) (name %) %)) m))
       7              : 
       8              : 
       9              : ;; JSON bodies arrive keywordized ({:uk ...}); language keys are strings. "" removes a name.
      10            4 : (def NameLocalizedRequestSchema
      11           20 :   [:map-of {:decode/snake-to-kebab stringify-keys}
      12           20 :    (into [:enum] domain-user-schemas/localized-languages)
      13           60 :    [:or [:= ""] [:and [:string {:max 120}] [:re domain-user-schemas/LocalizedNameRegex]]]])
      14              : 
      15              : 
      16            4 : (def AccountRequestSchema
      17           28 :   [:map {:swagger/title       "AccountRequestSchema"
      18              :          :swagger/description "User account creation or update data"}
      19            8 :    [:name
      20           44 :     [:string {:min         1
      21              :               :max         120
      22              :               :description "User's display name"
      23              :               :example     "John Doe"}]]
      24           20 :    [:username {:optional true}
      25            8 :     [:maybe
      26           44 :      [:string {:min         4
      27              :                :max         100
      28              :                :description "Unique username"
      29              :                :example     "johndoe"}]]]
      30           20 :    [:photo-url {:description "URL to user's profile photo"}
      31           12 :     [:maybe :string]]
      32           28 :    [:country-code {:optional    true
      33              :                    :description "ISO 3166-1 alpha-2 country code; null clears it"}
      34           12 :     [:maybe domain-user-schemas/CountryCodeSchema]]
      35           20 :    [:settings {:optional true}
      36            4 :     domain-user-schemas/UserSettingsSchema]
      37           20 :    [:name-localized {:optional true}
      38            4 :     NameLocalizedRequestSchema]
      39           24 :    [:confirm-name {:optional true}
      40              :     :boolean]])
      41              : 
      42              : 
      43              : ;; Account response body schemas
      44            4 : (def AccountResponseSuccess200Body
      45           28 :   [:map {:swagger/title       "AccountResponseSuccess200Body"
      46              :          :swagger/description "Successful account response with data"}
      47           28 :    [:message [:string {:example "User found successfully"}]]
      48           20 :    [:data [:ref :domain/AccountRecord]]])
      49              : 
      50              : 
      51            4 : (def AccountResponseSuccess201Body
      52           28 :   [:map {:swagger/title       "AccountResponseSuccess201Body"
      53              :          :swagger/description "Account created successfully"}
      54           28 :    [:message [:string {:example "User created successfully"}]]
      55           20 :    [:data [:ref :domain/AccountRecord]]])
      56              : 
      57              : 
      58            4 : (def AccountResponseError400Body
      59           28 :   [:map {:swagger/title       "AccountResponseError400Body"
      60              :          :swagger/description "Bad request error response"}
      61           28 :    [:message [:string {:example "Invalid request data"}]]
      62           12 :    [:data nil?]])
      63              : 
      64              : 
      65            4 : (def AccountResponseError404Body
      66           28 :   [:map {:swagger/title       "AccountResponseError404Body"
      67              :          :swagger/description "Account not found error"}
      68           28 :    [:message [:string {:example "User not found"}]]])
      69              : 
      70              : 
      71              : ;; Account response schemas for different HTTP status codes
      72            4 : (def AccountResponseSchema
      73              :   "Union of all possible account response schemas"
      74            8 :   [:or
      75           40 :    [:map [:status [:= 200]] [:body AccountResponseSuccess200Body]]
      76           40 :    [:map [:status [:= 201]] [:body AccountResponseSuccess201Body]]
      77           40 :    [:map [:status [:= 400]] [:body AccountResponseError400Body]]
      78           40 :    [:map [:status [:= 404]] [:body AccountResponseError404Body]]])
        

Generated by: LCOV version 2.0-1