aboutsummaryrefslogtreecommitdiff
path: root/example/lazybones-example.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'example/lazybones-example.lisp')
-rw-r--r--example/lazybones-example.lisp32
1 files changed, 32 insertions, 0 deletions
diff --git a/example/lazybones-example.lisp b/example/lazybones-example.lisp
index 5eb00d9..018b4ae 100644
--- a/example/lazybones-example.lisp
+++ b/example/lazybones-example.lisp
@@ -135,3 +135,35 @@
}
")
+
+(defclass animal ()
+ ((genus :initarg :genus :documentation "The genus")
+ (species :initarg :species :documentation "The species")
+ (population :initarg :population :documentation "Population on Earth")
+ (habitat :initarg :habitat :documentation "Where the animal lives"))
+ (:documentation "An animal"))
+
+;; add a documentation definition for animal class, the provided slots
+;; will show up in the api docs
+(lzb:add-class-to-definitions (lzb:app)
+ 'animal
+ 'genus 'species 'population 'habitat)
+
+(defvar +dummy-animal+
+ (make-instance 'animal
+ :genus "Pseudocheirus"
+ :species "Peregrinis"
+ :population "Unknown"
+ :habitat "Australia"))
+
+;; you can refer to definitions in docstrings
+(defendpoint* :get "/animal/:genus:/:species:" () ()
+ "Prints information about [Animal](#animal) specified by GENUS and SPECIES"
+ (if (and (string-equal genus "Pseudocheirus")
+ (string-equal species "Peregrinis"))
+ (with-output-to-string (out)
+ (with-slots (genus species population habitat) +dummy-animal+
+ (format out "The ~a ~a lives in ~a. Population: ~a~%"
+ genus species population habitat)))
+ (http-err 404)))
+