Skip to content

Commit

Permalink
add screenshot
Browse files Browse the repository at this point in the history
  • Loading branch information
jakecoffman committed Mar 1, 2021
1 parent 48d32bc commit 95af973
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ crud.Spec{
Tags: []string{"Widgets"},
Validate: crud.Validate{
Path: crud.Object(map[string]crud.Field{
"id": crud.Number().Required().Description("ID of the widget")
"id": crud.Number().Required().Description("ID of the widget"),
}),
Body: crud.Object(map[string]crud.Field{
"owner": crud.String().Required().Example("Bob").Description("Widget owner's name"),
Expand All @@ -62,4 +62,8 @@ crud.Spec{

This will add a route `/widgets/:id` that responds to the PATCH method. It generates swagger and serves it at the root of the web application. It validates that the ID in the path is a number, so you don't have to. It also validates that the body is an object and has an "owner" property that is a string, again so you won't have to.

It mounts the swagger-ui at `/` and loads up the generated swagger.json:

![screenshot](/screenshot.png?raw=true "Swagger")

The `PreHandlers` run before validation, and the `Handler` runs after validation is successful.
Binary file added screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 95af973

Please sign in to comment.