Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # working name
- use Safety::API::Dance;
- resource "/v1/users"
- => abstract { 'Optional OpenAPI documentation' }
- => GET { operation 'list_users' }
- => PUT { operation 'create_user' }
- => POST { operations 'query_users' }
- ;
- resource "/v1/users/:user_id"
- => GET { operation 'fetch_user' }
- => POST { operation 'update_user' }
- => DELETE { operation 'delete_user' }
- ;
- resource parameter user_id
- => constraint => PositiveInt
- ;
- operation delete_user
- => abstract { 'OpenAPI documentation' }
- => returns { constraint }
- => throws { HTTP::Status::NOT_FOUND => via 'My::API::X::User::Not::Found' }
- => throws { HTTP::Status::BAD_CONTENT => via 'My::API::X::User::Validation' }
- # either direct callback
- => as => sub { }
- # or delegate to the instance
- => class => 'My::API::Users'
- => method => 'delete'
- ;
- # evolution of an idea (in fact this become before first step itself)
- # one declaration for uri with or without item identifier parameter
- resource "/v1/users/:user_id"
- => abstract { 'Optional OpenAPI documentation' }
- => list_items { operation 'list_users' }
- => create_item { operation 'create_user' }
- => query_items { operations 'query_users' }
- => fetch_item { operation 'fetch_user' }
- => update_item { operation 'update_user' }
- => delete_item { operation 'delete_user' }
- ;
Add Comment
Please, Sign In to add comment