Skip to content

Instantly share code, notes, and snippets.

@dclucas
Last active August 29, 2015 14:21
Show Gist options
  • Save dclucas/ed2495c0b222bd762f5a to your computer and use it in GitHub Desktop.
Save dclucas/ed2495c0b222bd762f5a to your computer and use it in GitHub Desktop.
Example for resource builder class, consuming the DSL
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