diff --git a/definition/request.go b/definition/request.go index 0d2dc1e..2a9abe9 100644 --- a/definition/request.go +++ b/definition/request.go @@ -7,3 +7,16 @@ type Request struct { Body []Body Headers []Header } + +// IsEmpty verifies is the request is empty +func (r Request) IsEmpty() bool { + if r.Title != "" || r.Description != "" { + return false + } + + if len(r.Body) > 0 || len(r.Headers) > 0 { + return false + } + + return true +} \ No newline at end of file diff --git a/examples/spec/blueprint/realworld.apib b/examples/spec/blueprint/realworld.apib index 3228249..284b245 100644 --- a/examples/spec/blueprint/realworld.apib +++ b/examples/spec/blueprint/realworld.apib @@ -74,7 +74,7 @@ Returns a specific Post. + Response 200 (application/json) - This is a mighty example + Single post Resource + Body @@ -121,7 +121,20 @@ Returns a specific Post. "you_starred": false }, "meta": { - "code": 200, + "code": 200 + } + } + ++ Response 404 (application/json) + + Resource Not found + + + Body + + { + "data": {}, + "meta": { + "code": 200 } } diff --git a/try-it-out/css/try-it-out.css b/try-it-out/css/try-it-out.css index 75e4806..c686de5 100644 --- a/try-it-out/css/try-it-out.css +++ b/try-it-out/css/try-it-out.css @@ -12,3 +12,10 @@ h1 { text-align: center; color: #FF0000; } + +pre {outline: 1px solid #ccc; padding: 5px; margin: 5px; } +.string { color: green; } +.number { color: darkorange; } +.boolean { color: blue; } +.null { color: magenta; } +.key { color: red; } \ No newline at end of file diff --git a/try-it-out/index.html b/try-it-out/index.html index 28e62d2..94f4022 100644 --- a/try-it-out/index.html +++ b/try-it-out/index.html @@ -3,372 +3,713 @@
-get ...
-patch ....
-get items ...
-patch items....
+Single post Resource
+ ++ application/json +
+ + ++ Example-1 +
+{ + "data": { + "id": "1", // note this is a string + "user": { + ... + }, + "created_at": "2012-07-16T17:25:47Z", + "text": "@berg FIRST post on this new site #newsocialnetwork", + "html": "<span itemprop=\"mention\" data-mention-name=\"berg\" data-mention-id=\"2\">@berg</span> FIRST post on <a href=\"https://join.app.net\" rel=\"nofollow\">this new site</a> <span itemprop=\"hashtag\" data-hashtag-name=\"newsocialnetwork\">#newsocialnetwork</span>.", + "source": { + "client_id": "udxGzAVBdXwGtkHmvswR5MbMEeVnq6n4", + "name": "Clientastic for iOS", + "link": "http://app.net" + }, + "machine_only": false, + "reply_to": null, + "thread_id": "1", + "num_replies": 3, + "num_reposts": 0, + "num_stars": 0, + "entities": { + "mentions": [{ + "name": "berg", + "id": "2", + "pos": 0, + "len": 5 + }], + "hashtags": [{ + "name": "newsocialnetwork", + "pos": 34, + "len": 17 + }], + "links": [{ + "text": "this new site", + "url": "https://join.app.net" + "pos": 20, + "len": 13 + }] + }, + "you_reposted": false, + "you_starred": false + }, + "meta": { + "code": 200 + } +} ++
get images...
-patch images ....
+Resource Not found
+ ++ application/json +
+ + ++ Example-1 +
+{ + "data": {}, + "meta": { + "code": 200 + } +} ++
Allows you to modify the properties of an account.
-A 34 character string that uniquely identifies this account.
-A 34 character string that uniquely identifies this account.
++ application/json +
+ + ++ Example-1 +
+{ + "data": { + "id": "1", // note this is a string + "user": { + ... + }, + "created_at": "2012-07-16T17:25:47Z", + "text": "@berg FIRST post on this new site #newsocialnetwork", + "html": "<span itemprop=\"mention\" data-mention-name=\"berg\" data-mention-id=\"2\">@berg</span> FIRST post on <a href=\"https://join.app.net\" rel=\"nofollow\">this new site</a> <span itemprop=\"hashtag\" data-hashtag-name=\"newsocialnetwork\">#newsocialnetwork</span>.", + "source": { + "client_id": "udxGzAVBdXwGtkHmvswR5MbMEeVnq6n4", + "name": "Clientastic for iOS", + "link": "http://app.net" + }, + "machine_only": false, + "reply_to": null, + "thread_id": "1", + "num_replies": 3, + "num_reposts": 0, + "num_stars": 0, + "entities": { + "mentions": [{ + "name": "berg", + "id": "2", + "pos": 0, + "len": 5 + }], + "hashtags": [{ + "name": "newsocialnetwork", + "pos": 34, + "len": 17 + }], + "links": [{ + "text": "this new site", + "url": "https://join.app.net" + "pos": 20, + "len": 13 + }] + }, + "you_reposted": false, + "you_starred": false + }, + "meta": { + "code": 200, + } +} ++
Oauth
+ +finance_read
+Authorization description.
-+ application/json +
+ + +application/x-www-form-urlencoded
+ -A 34 character string that uniquely identifies this account.
-+ Example-1 +
+{ + "data": [ + { + "id": "1", // note this is a string + ... + }, + { + "id": "2", + ... + }, + { + "id": "3", + ... + }, + ], + "meta": { + "code": 200, + } +} ++
The request was successful, we updated the resource and the response - body contains the representation.
- -- application/json - application/xml -
- -+ application/json +
+ + ++ Example-1 +
+{ + "data": { + "id": "1", // note this is a string + "user": { + ... + }, + "created_at": "2012-07-16T17:25:47Z", + "text": "@berg FIRST post on this new site #newsocialnetwork", + "html": "<span itemprop=\"mention\" data-mention-name=\"berg\" data-mention-id=\"2\">@berg</span> FIRST post on <a href=\"https://join.app.net\" rel=\"nofollow\">this new site</a> <span itemprop=\"hashtag\" data-hashtag-name=\"newsocialnetwork\">#newsocialnetwork</span>.", + "source": { + "client_id": "udxGzAVBdXwGtkHmvswR5MbMEeVnq6n4", + "name": "Clientastic for iOS", + "link": "http://app.net" + }, + "machine_only": false, + "reply_to": null, + "thread_id": "1", + "num_replies": 3, + "num_reposts": 0, + "num_stars": 0, + "entities": { + "mentions": [{ + "name": "berg", + "id": "2", + "pos": 0, + "len": 5 + }], + "hashtags": [{ + "name": "newsocialnetwork", + "pos": 34, + "len": 17 + }], + "links": [{ + "text": "this new site", + "url": "https://join.app.net" + "pos": 20, + "len": 13 + }] + }, + "you_reposted": false, + "you_starred": false + }, + "meta": { + "code": 200, + } +} ++
+ application/json +
+ + ++ Example-1 +
+{ + "data": { + "id": "1", // note this is a string + "user": { + ... + }, + "created_at": "2012-07-16T17:25:47Z", + "text": "@berg FIRST post on this new site #newsocialnetwork", + "html": "<span itemprop=\"mention\" data-mention-name=\"berg\" data-mention-id=\"2\">@berg</span> FIRST post on <a href=\"https://join.app.net\" rel=\"nofollow\">this new site</a> <span itemprop=\"hashtag\" data-hashtag-name=\"newsocialnetwork\">#newsocialnetwork</span>.", + "source": { + "client_id": "udxGzAVBdXwGtkHmvswR5MbMEeVnq6n4", + "name": "Clientastic for iOS", + "link": "http://app.net" + }, + "machine_only": false, + "reply_to": null, + "thread_id": "1", + "num_replies": 3, + "num_reposts": 0, + "num_stars": 0, + "entities": { + "mentions": [{ + "name": "berg", + "id": "2", + "pos": 0, + "len": 5 + }], + "hashtags": [{ + "name": "newsocialnetwork", + "pos": 34, + "len": 17 + }], + "links": [{ + "text": "this new site", + "url": "https://join.app.net" + "pos": 20, + "len": 13 + }] + }, + "you_reposted": false, + "you_starred": false + }, + "meta": { + "code": 200, + } +} ++