Skip to content

Instantly share code, notes, and snippets.

@jakecoffman
Last active December 3, 2021 14:43
Show Gist options
  • Save jakecoffman/df3cf0607284a2e21974cca8ec12b793 to your computer and use it in GitHub Desktop.
Save jakecoffman/df3cf0607284a2e21974cca8ec12b793 to your computer and use it in GitHub Desktop.
Example author REST endpoint spec
crud.Spec{
Method: "PATCH",
Path: "/authors/{id}",
Summary: "Patch an author",
Tags: tags,
Handler: PatchAuthor,
Validate: crud.Validate{
Path: crud.Object(map[string]crud.Field{
"id": crud.Integer().Required(),
}),
Body: crud.Object(map[string]crud.Field{
"name": crud.String().Description("Name of the author"),
"born": crud.Date().Description("Author's date of birth"),
"books": crud.Array().Items(crud.Object(map[string]crud.Field{
"title": crud.String().Description("Title of book"),
"genre": crud.String().Enum("", "fantasy", "non-fiction", "political").Description("Book genre"),
})),
}),
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment