You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.markdown
+35-4Lines changed: 35 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,7 +33,7 @@ module API
33
33
end
34
34
```
35
35
36
-
To explore your API, either download [Swagger UI](https://github.com/wordnik/swagger-ui) and set it up yourself or go to the [online swagger demo](http://petstore.swagger.wordnik.com/) and enter your localhost url documentation root in the url field (probably something in the line of http://localhost:3000/swagger_doc.json).
36
+
To explore your API, either download [Swagger UI](https://github.com/wordnik/swagger-ui) and set it up yourself or go to the [online swagger demo](http://petstore.swagger.wordnik.com/) and enter your localhost url documentation root in the url field (probably something in the line of http://localhost:3000/swagger_doc.json).
37
37
If you use the online demo, make sure your API supports foreign requests by enabling CORS in grape, otherwise you'll see the API description, but requests on the API won't return. You can do this by putting below code in your Grape API definition:
38
38
39
39
````ruby
@@ -53,23 +53,54 @@ You can pass a hash with some configuration possibilities to ```add_swagger_docu
53
53
54
54
## Swagger Header Parameters
55
55
56
-
Swagger also supports the documentation of parameters passed in the header. Since grape's ```params[]``` doesn't return header parameters we can
56
+
Swagger also supports the documentation of parameters passed in the header. Since grape's ```params[]``` doesn't return header parameters we can
57
57
to specify header parameters seperately in a block after the description.
58
58
59
59
```ruby
60
60
desc "Return super-secret information", {
61
61
headers: {
62
62
"XAuthToken" => {
63
63
description:"Valdates your identity",
64
-
required:true
64
+
required:true
65
65
},
66
66
"XOptionalHeader" => {
67
67
description:"Not reallly needed",
68
-
required:false
68
+
required:false
69
69
}
70
70
}
71
71
}
72
72
```
73
+
### Grape Entities
74
+
75
+
Add the [grape-entity](https://github.com/agileanimal/grape-entity) gem to our Gemfile.
76
+
Please refer to the [grape-entity documentation](https://github.com/gileanimal/grape-entity/blob/master/README.markdown)
77
+
for more details.
78
+
79
+
The following example exposes statuses. And exposes statuses documentation adding :type and :desc.
present statuses, with:API::Entities::Status, :type => type
100
+
end
101
+
end
102
+
end
103
+
```
73
104
74
105
## Swagger additions
75
106
grape-swagger allows you to add an explanation in markdown in the notes field. Which would result in proper formatted markdown in Swagger UI. The default Swagger UI doesn't allow HTML in the notes field, so you need to use an adapted version of Swagger UI (you can find one at https://github.com/tim-vandecasteele/swagger-ui/tree/vasco).
0 commit comments