File tree Expand file tree Collapse file tree 2 files changed +9
-6
lines changed
Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -26,10 +26,14 @@ struct MockOp {
2626
2727impl Generator {
2828 /// Generate a strongly-typed mocking extension to the `httpmock` crate.
29+ ///
30+ /// The `crate_path` parameter should be a valid Rust path corresponding to
31+ /// the SDK. This can include `::` and instances of `-` in the crate name
32+ /// should be converted to `_`.
2933 pub fn httpmock (
3034 & mut self ,
3135 spec : & OpenAPI ,
32- crate_name : & str ,
36+ crate_path : & str ,
3337 ) -> Result < TokenStream > {
3438 validate_openapi ( spec) ?;
3539
@@ -81,7 +85,9 @@ impl Generator {
8185
8286 let crate_path = syn:: TypePath {
8387 qself : None ,
84- path : syn:: parse_str ( crate_name) . unwrap ( ) ,
88+ path : syn:: parse_str ( crate_path) . unwrap_or_else ( |_| {
89+ panic ! ( "{} is not a valid identifier" , crate_path)
90+ } ) ,
8591 } ;
8692
8793 let code = quote ! {
Original file line number Diff line number Diff line change @@ -1293,10 +1293,7 @@ impl Generator {
12931293 parameters : & [ OperationParameter ] ,
12941294 responses : & [ OperationResponse ] ,
12951295 ) -> Option < DropshotPagination > {
1296- let Some ( value) = operation. extensions . get ( "x-dropshot-pagination" )
1297- else {
1298- return None ;
1299- } ;
1296+ let value = operation. extensions . get ( "x-dropshot-pagination" ) ?;
13001297
13011298 // We expect to see at least "page_token" and "limit" parameters.
13021299 if parameters
You can’t perform that action at this time.
0 commit comments