@@ -67,25 +67,28 @@ impl<'a> APISpec<'a> {
67
67
}
68
68
69
69
/// Sets the path to specify/check.
70
- pub fn path ( & ' a mut self , path : & ' a str ) -> & mut APISpec {
70
+ pub fn path ( & ' a mut self , path : & ' a str ) -> & ' a mut APISpec < ' a > {
71
71
self . path = Some ( path) ;
72
72
self
73
73
}
74
74
75
75
/// Sets the method to specify/check.
76
- pub fn method ( & ' a mut self , method : & ' a str ) -> & mut APISpec {
76
+ pub fn method ( & ' a mut self , method : & ' a str ) -> & ' a mut APISpec < ' a > {
77
77
self . method = Some ( method) ;
78
78
self
79
79
}
80
80
81
81
/// Sets the content type to specify/check, note that it defaults to "application/json".
82
- pub fn content_type ( & ' a mut self , content_type : & ' a str ) -> & mut APISpec {
82
+ pub fn content_type ( & ' a mut self , content_type : & ' a str ) -> & ' a mut APISpec < ' a > {
83
83
self . content_type = Some ( content_type) ;
84
84
self
85
85
}
86
86
87
87
/// Validates if a request is valid
88
- fn validate_request ( & ' a self , request_body : & impl Serialize ) -> Result < & APISpec , String > {
88
+ fn validate_request (
89
+ & ' a self ,
90
+ request_body : & impl Serialize ,
91
+ ) -> Result < & ' a APISpec < ' a > , String > {
89
92
let path = self . path . unwrap ( ) ;
90
93
let method = self . method . unwrap ( ) . to_lowercase ( ) ;
91
94
let content_type = self . content_type . unwrap ( ) ;
@@ -104,7 +107,7 @@ impl<'a> APISpec<'a> {
104
107
& ' a self ,
105
108
path : & str ,
106
109
operation_object : & Value ,
107
- ) -> Result < & APISpec , String > {
110
+ ) -> Result < & ' a APISpec < ' a > , String > {
108
111
let fake_base_url = "http://0.0.0.1" ;
109
112
let url = Url :: parse ( & format ! ( "{}{}" , fake_base_url, path) ) . unwrap ( ) ;
110
113
@@ -130,7 +133,7 @@ impl<'a> APISpec<'a> {
130
133
& ' a self ,
131
134
response : & Response < Bytes > ,
132
135
expected_status_code : & StatusCode ,
133
- ) -> Result < & APISpec , String > {
136
+ ) -> Result < & ' a APISpec < ' a > , String > {
134
137
if expected_status_code. as_u16 ( ) != response. status ( ) . as_u16 ( ) {
135
138
return Err ( format ! (
136
139
"expected status code {} but was {}" ,
@@ -143,7 +146,7 @@ impl<'a> APISpec<'a> {
143
146
}
144
147
145
148
/// Validates if a response is valid
146
- fn validate_response ( & ' a self , response : & Response < Bytes > ) -> Result < & APISpec , String > {
149
+ fn validate_response ( & ' a self , response : & Response < Bytes > ) -> Result < & ' a APISpec < ' a > , String > {
147
150
let body = response. body ( ) ;
148
151
let status = response. status ( ) ;
149
152
@@ -207,7 +210,11 @@ impl<'a> APISpec<'a> {
207
210
}
208
211
209
212
/// Validates conformity of a value against a schema
210
- fn validate_conformity ( & ' a self , value : & Value , schema : & Value ) -> Result < & APISpec , String > {
213
+ fn validate_conformity (
214
+ & ' a self ,
215
+ value : & Value ,
216
+ schema : & Value ,
217
+ ) -> Result < & ' a APISpec < ' a > , String > {
211
218
match schema {
212
219
Null => match value {
213
220
Null => Ok ( self ) ,
0 commit comments