diff options
author | Colin Okay <okay@toyful.space> | 2022-02-20 15:48:36 -0600 |
---|---|---|
committer | Colin Okay <okay@toyful.space> | 2022-02-20 15:48:36 -0600 |
commit | 70def00400c88f4d872a58b2f76449077ece22ca (patch) | |
tree | b918e7321145b1ced930cc9206c3a395af8dcd08 /example | |
parent | 0437c4a85af5a4fbb68174d7c1266887acc692c1 (diff) | |
parent | c48ecda020797fe3fe65d55d02a8b72f6e7f19cb (diff) |
Merge branch 'master' of github.com:cbeo/lazybones
Diffstat (limited to 'example')
-rw-r--r-- | example/lazybones-example-docs.md | 23 | ||||
-rw-r--r-- | example/lazybones-example.lisp | 32 |
2 files changed, 55 insertions, 0 deletions
diff --git a/example/lazybones-example-docs.md b/example/lazybones-example-docs.md index a7dfca9..522d129 100644 --- a/example/lazybones-example-docs.md +++ b/example/lazybones-example-docs.md @@ -6,6 +6,17 @@ Just an API that defines some endpoints. These ## Endpoints +### GET /animal/:genus:/:species: +*text/plain* + +Route Variables: + +- GENUS +- SPECIES + + +Prints information about [Animal](#animal) specified by GENUS and SPECIES + ### POST /crapshoot *text/plain* @@ -97,3 +108,15 @@ An instance of person. As JSON, it looks like: +<h3 id='#animal'>animal</h3> + +An animal + +**Slots:** +- GENUS: The genus +- SPECIES: The species +- POPULATION: Population on Earth +- HABITAT: Where the animal lives + + + 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))) + |