[Rust] Implement 'object' type conversion (#6846)

* [Rust] Use serde Value for objects

This hopefully fixes the previous TODO; it at least fixes compilation
errors for the specific swagger model I'm working with.

* [Rust] Update Cargo.toml to specify versions

Letting the version float freely is scary, to say the least.

This gives it a better chance at being future-proof.

When the crate author had a recommended selector I picked that,
otherwise I went semver compatible.

* [Rust] Regenerate the example
This commit is contained in:
Euan Kemp
2017-11-01 07:00:56 -07:00
committed by wing328
parent 7755c7de38
commit c97b63d2bb
18 changed files with 45 additions and 368 deletions

View File

@@ -15,8 +15,6 @@ use futures::{Future, future, Stream, stream};
use petstore_api::{ApiNoContext, ContextWrapperExt,
ApiError,
TestSpecialTagsResponse,
GetXmlFeaturesResponse,
PostXmlFeaturesResponse,
FakeOuterBooleanSerializeResponse,
FakeOuterCompositeSerializeResponse,
FakeOuterNumberSerializeResponse,
@@ -55,7 +53,6 @@ fn main() {
.arg(Arg::with_name("operation")
.help("Sets the operation to run")
.possible_values(&[
"GetXmlFeatures",
"FakeOuterBooleanSerialize",
"FakeOuterCompositeSerialize",
"FakeOuterNumberSerialize",
@@ -105,17 +102,6 @@ fn main() {
// println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
// },
Some("GetXmlFeatures") => {
let result = client.get_xml_features().wait();
println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
},
// Disabled because there's no example.
// Some("PostXmlFeatures") => {
// let result = client.post_xml_features(???).wait();
// println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
// },
Some("FakeOuterBooleanSerialize") => {
let result = client.fake_outer_boolean_serialize(None).wait();
println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));

View File

@@ -11,8 +11,6 @@ use std::io::Error;
use petstore_api::{Api, ApiError, Context,
TestSpecialTagsResponse,
GetXmlFeaturesResponse,
PostXmlFeaturesResponse,
FakeOuterBooleanSerializeResponse,
FakeOuterCompositeSerializeResponse,
FakeOuterNumberSerializeResponse,
@@ -59,20 +57,6 @@ impl Api for Server {
Box::new(futures::failed("Generic failure".into()))
}
/// Get some XML
fn get_xml_features(&self, context: &Context) -> Box<Future<Item=GetXmlFeaturesResponse, Error=ApiError> + Send> {
let context = context.clone();
println!("get_xml_features() - X-Span-ID: {:?}", context.x_span_id.unwrap_or(String::from("<none>")).clone());
Box::new(futures::failed("Generic failure".into()))
}
/// Post some xml
fn post_xml_features(&self, xml_object: models::XmlObject, context: &Context) -> Box<Future<Item=PostXmlFeaturesResponse, Error=ApiError> + Send> {
let context = context.clone();
println!("post_xml_features({:?}) - X-Span-ID: {:?}", xml_object, context.x_span_id.unwrap_or(String::from("<none>")).clone());
Box::new(futures::failed("Generic failure".into()))
}
fn fake_outer_boolean_serialize(&self, body: Option<models::OuterBoolean>, context: &Context) -> Box<Future<Item=FakeOuterBooleanSerializeResponse, Error=ApiError> + Send> {
let context = context.clone();