Last active
August 29, 2015 14:21
-
-
Save dclucas/ed2495c0b222bd762f5a to your computer and use it in GitHub Desktop.
Example for resource builder class, consuming the DSL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CommentResourceBuilder { | |
def buildResource(Resource resource) { | |
resource.definitions = | |
resource.definitions | |
.Comments { | |
properties { | |
body { | |
type 'string' | |
description 'Comments contents' | |
} | |
} | |
required 'body' | |
} | |
resource.paths = | |
resource.paths | |
."/comments" { | |
get { req, res -> | |
"comments.get" | |
} | |
post { req, res -> | |
"comments.post" | |
}.document { docs -> | |
docs.description = "Description for comments.post" | |
docs | |
} | |
.skipAuth | |
.skipValidation | |
"/:id" { | |
get {req, res -> "comments/1.get"} | |
patch {req, res -> "comments/1.patch"} | |
//.document { docs -> docs.operationId = "commentUpdate"; docs } | |
delete {req, res -> "comments/1.delete"} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment