Skip to content

Commit 511a1e9

Browse files
committed
Namespace http method to avoid conflict with the capabilities API
1 parent 27864ad commit 511a1e9

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

api_generator/src/generator/code_gen/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ pub fn use_declarations() -> Tokens {
3737
params::*,
3838
error::Error,
3939
http::{
40+
self,
4041
headers::{HeaderName, HeaderMap, HeaderValue, CONTENT_TYPE, ACCEPT},
41-
Method,
4242
request::{Body, NdBody, JsonBody, PARTS_ENCODED},
4343
response::Response,
44-
transport::Transport,
44+
transport::Transport
4545
},
4646
};
4747
use std::{

api_generator/src/generator/code_gen/request/request_builder.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,14 @@ impl<'a> RequestBuilder<'a> {
103103
_ => match methods.as_slice() {
104104
[HttpMethod::Post, HttpMethod::Put] => {
105105
if builder_name.contains("Put") {
106-
parse_expr(quote!(Method::Put))
106+
parse_expr(quote!(http::Method::Put))
107107
} else {
108-
parse_expr(quote!(Method::Post))
108+
parse_expr(quote!(http::Method::Post))
109109
}
110110
}
111111
[HttpMethod::Get, HttpMethod::Post] => parse_expr(quote!(match self.body {
112-
Some(_) => Method::Post,
113-
None => Method::Get,
112+
Some(_) => http::Method::Post,
113+
None => http::Method::Get,
114114
})),
115115
_ => panic!("Combination of methods unexpected"),
116116
},

api_generator/src/generator/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ use void::Void;
4242
pub mod code_gen;
4343
pub mod output;
4444

45-
use itertools::Itertools;
4645
use output::{merge_file, write_file};
4746
use std::cmp::Ordering;
4847

@@ -111,6 +110,8 @@ pub enum HttpMethod {
111110
/// a `Method` in the elasticsearch client
112111
impl quote::ToTokens for HttpMethod {
113112
fn to_tokens(&self, tokens: &mut quote::Tokens) {
113+
tokens.append("http");
114+
tokens.append("::");
114115
tokens.append("Method");
115116
tokens.append("::");
116117
match *self {
@@ -702,7 +703,7 @@ where
702703
.paths
703704
.iter()
704705
.map(|p| &p.deprecated)
705-
.fold1(|d1, d2| Deprecated::combine(d1, d2))
706+
.reduce(|d1, d2| Deprecated::combine(d1, d2))
706707
.unwrap_or(&None);
707708

708709
if let Some(deprecated) = deprecation {

0 commit comments

Comments
 (0)