← ClaudeAtlas

add-malli-schemaslisted

Efficiently add Malli schemas to API endpoints in the Metabase codebase with proper patterns, validation timing, and error handling
aiskillstore/marketplace · ★ 329 · API & Backend · score 79
Install: claude install-skill aiskillstore/marketplace
# Add Malli Schemas to API Endpoints This skill helps you efficiently and uniformly add Malli schemas to API endpoints in the Metabase codebase. ## Reference Files (Best Examples) - `src/metabase/warehouses/api.clj` - Most comprehensive schemas, custom error messages - `src/metabase/api_keys/api.clj` - Excellent response schemas - `src/metabase/collections/api.clj` - Great named schema patterns - `src/metabase/timeline/api/timeline.clj` - Clean, simple examples ## Quick Checklist When adding Malli schemas to an endpoint: - [ ] Route params have schemas - [ ] Query params have schemas with `:optional true` and `:default` where appropriate - [ ] Request body has a schema (for POST/PUT) - [ ] Response schema is defined (using `:-` after route string) - [ ] Use existing schema types from `ms` namespace when possible - [ ] Consider creating named schemas for reusable or complex types - [ ] Add contextual error messages for validation failures ## Basic Structure ### Complete Endpoint Example ```clojure (mr/def ::Color [:enum "red" "blue" "green"]) (mr/def ::ResponseSchema [:map [:id pos-int?] [:name string?] [:color ::Color] [:created_at ms/TemporalString]]) (api.macros/defendpoint :post "/:name" :- ::ResponseSchema "Create a resource with a given name." [;; Route Params: {:keys [name]} :- [:map [:name ms/NonBlankString]] ;; Query Params: {:keys [include archived]} :- [:map [:include {:optional true} [:maybe