From 442d5e0616b8158eae5428b022254bdcb0cdaa62 Mon Sep 17 00:00:00 2001
From: colin <colin@cicadas.surf>
Date: Sun, 12 May 2024 12:30:41 -0700
Subject: Add: defendpoint parameters signal slot-required when necessary

---
 src/defendpoint.lisp | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/src/defendpoint.lisp b/src/defendpoint.lisp
index 0ac9ec9..dd39368 100644
--- a/src/defendpoint.lisp
+++ b/src/defendpoint.lisp
@@ -42,11 +42,12 @@ PART is either
        (symbolp (first spec))
        (symbolp (second spec))))
 
-(defun params-to-slotdefs (specs)
+(defun params-to-slotdefs (endpoint specs)
   (loop :for (name type . doc) :in specs
         :collect `(,name
                    :accessor ,name
                    :initarg ,(a:make-keyword name)
+                   :initform (slot-required ',endpoint ',name)
                    :type ,type
                    :documentation ,(or (first doc) ""))))
 
@@ -75,7 +76,7 @@ PART is either
   (setf var (or var (gensym "REQ-")))
   (setf metaclass (or metaclass 'endpoint))
   (let* ((slot-defs
-           (nconc (params-to-slotdefs parameters)
+           (nconc (params-to-slotdefs name parameters)
                   (props-to-slotdefs properties)))
          (all-slots
            (nconc (mapcar #'first slot-defs)
@@ -130,9 +131,6 @@ PART is either
                 (:@ supers (:? <supers>))
                 (:@ method <method>)
                 (:@ pathspec <pathspec>)
- ;               (:@ return (:? <return>))
-;                (:@ params (:? <parameters>))
-;                (:@ props (:? <properties>))
                 (:@ options (:* <option>))
                 (:@ handle <handle>)
                 (:eof))
@@ -141,10 +139,7 @@ PART is either
                 method
                 pathspec
                 handle
-;                return
                 :supers supers
-;                :parameters params
-;                :properties props
                 (a:alist-plist options)))
   (<supers>
    :match (:seq (:or= :using :extends) (:+ <classname>))
@@ -163,14 +158,16 @@ PART is either
    :note "REGEX or (KWD REGEX &optional PARSER)")
   (<parameters>
    :match (:seq (:= :parameters) (:+ <param>))
-   :then (cons :parameters (second <parameters>)))
+   :then (cons :parameters (second <parameters>))
+   :note "Request parameters - will signal an error if missing from the user request")
   (<param>
    :match (:item)
    :if parameter-spec-p
    :note "(NAME TYPE &optional DOCSTRING)")
   (<properties>
    :match (:seq (:= :properties) (:+ <prop>))
-   :then (cons :properties (second <properties>)))
+   :then (cons :properties (second <properties>))
+   :note "Values that should be filled-in during authentication or authorization")
   (<prop>
    :match (:item)
    :if property-spec-p
-- 
cgit v1.2.3