@@ -9,62 +9,62 @@ class HelperTestAPI < Grape::API
9
9
10
10
@api = Object . new
11
11
# after injecting grape-swagger into the Test API we get the helper methods
12
- # back from the first endpoint's class (the API mounted by grape-swagger
12
+ # back from the first endpoint's class (the API mounted by grape-swagger
13
13
# to serve the swagger_doc
14
14
@api . extend HelperTestAPI . endpoints . first . options [ :app ] . helpers
15
15
16
16
end
17
-
17
+
18
18
context "parsing parameters" do
19
19
it "should parse params as query strings for a GET" do
20
20
params = {
21
- name : { type : 'String' , :@api => "A name" , required : true } ,
22
- level : 'max'
21
+ name : { type : 'String' , :desc => "A name" , required : true } ,
22
+ level : 'max'
23
23
}
24
24
path = "/coolness"
25
25
method = "GET"
26
- @api . parse_params ( params , path , method ) . should ==
27
- [
26
+ @api . parse_params ( params , path , method ) . should ==
27
+ [
28
28
{ paramType : "query" , name : :name , description :"A name" , dataType : "String" , required : true } ,
29
29
{ paramType : "query" , name : :level , description :"" , dataType : "String" , required : false }
30
30
]
31
31
end
32
-
32
+
33
33
it "should parse params as body for a POST" do
34
34
params = {
35
- name : { type : 'String' , :@api => "A name" , required : true } ,
36
- level : 'max'
35
+ name : { type : 'String' , :desc => "A name" , required : true } ,
36
+ level : 'max'
37
37
}
38
38
path = "/coolness"
39
39
method = "POST"
40
- @api . parse_params ( params , path , method ) . should ==
41
- [
40
+ @api . parse_params ( params , path , method ) . should ==
41
+ [
42
42
{ paramType : "body" , name : :name , description :"A name" , dataType : "String" , required : true } ,
43
43
{ paramType : "body" , name : :level , description :"" , dataType : "String" , required : false }
44
44
]
45
45
end
46
46
end
47
-
47
+
48
48
context "parsing the path" do
49
49
it "should parse the path" do
50
50
path = ":abc/def(.:format)"
51
51
@api . parse_path ( path , nil ) . should == "{abc}/def.{format}"
52
52
end
53
-
53
+
54
54
it "should parse the path with a specified version" do
55
55
path = ":abc/{version}/def(.:format)"
56
56
@api . parse_path ( path , 'v1' ) . should == "{abc}/v1/def.{format}"
57
57
end
58
58
end
59
-
59
+
60
60
context "parsing header parameters" do
61
61
it "should parse params for the header" do
62
62
params = { "XAuthToken" => { description : "A required header." , required : true } }
63
- @api . parse_header_params ( params ) . should ==
64
- [
63
+ @api . parse_header_params ( params ) . should ==
64
+ [
65
65
{ paramType : "header" , name : "XAuthToken" , description :"A required header." , dataType : "String" , required : true }
66
66
]
67
67
end
68
68
end
69
-
70
- end
69
+
70
+ end
0 commit comments