Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ public RustClientCodegen() {
typeMapping.put("file", "File");
typeMapping.put("binary", "Vec<u8>");
typeMapping.put("ByteArray", "String");
// TODO what should 'object' mapped to
typeMapping.put("object", "Object");
typeMapping.put("object", "Value");

// no need for rust
//importMapping = new HashMap<String, String>();
Expand Down
16 changes: 8 additions & 8 deletions modules/swagger-codegen/src/main/resources/rust/Cargo.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ version = "{{{packageVersion}}}"
authors = ["Swagger Codegen team and contributors"]

[dependencies]
serde = "*"
serde_derive = "*"
serde_yaml = "*"
serde_json = "*"
base64 = "*"
futures = "*"
hyper = "*"
url = "*"
serde = "1.0"
serde_derive = "1.0"
serde_yaml = "0.7"
serde_json = "1.0"
base64 = "~0.7.0"
futures = "0.1.16"
hyper = "0.11.6"
url = "1.5"

[dev-dependencies]
tokio-core = "*"
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
/// {{{classname}}} : {{{description}}}
{{/description}}

#[allow(unused_imports)]
use serde_json::Value;

#[derive(Debug, Serialize, Deserialize)]
pub struct {{classname}} {
{{#vars}}
Expand Down
16 changes: 8 additions & 8 deletions samples/client/petstore/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ version = "1.0.0"
authors = ["Swagger Codegen team and contributors"]

[dependencies]
serde = "*"
serde_derive = "*"
serde_yaml = "*"
serde_json = "*"
base64 = "*"
futures = "*"
hyper = "*"
url = "*"
serde = "1.0"
serde_derive = "1.0"
serde_yaml = "0.7"
serde_json = "1.0"
base64 = "~0.7.0"
futures = "0.1.16"
hyper = "0.11.6"
url = "1.5"

[dev-dependencies]
tokio-core = "*"
3 changes: 3 additions & 0 deletions samples/client/petstore/rust/src/models/api_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@

/// ApiResponse : Describes the result of uploading an image resource

#[allow(unused_imports)]
use serde_json::Value;

#[derive(Debug, Serialize, Deserialize)]
pub struct ApiResponse {
#[serde(rename = "code")]
Expand Down
3 changes: 3 additions & 0 deletions samples/client/petstore/rust/src/models/category.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@

/// Category : A category for a pet

#[allow(unused_imports)]
use serde_json::Value;

#[derive(Debug, Serialize, Deserialize)]
pub struct Category {
#[serde(rename = "id")]
Expand Down
3 changes: 3 additions & 0 deletions samples/client/petstore/rust/src/models/order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@

/// Order : An order for a pets from the pet store

#[allow(unused_imports)]
use serde_json::Value;

#[derive(Debug, Serialize, Deserialize)]
pub struct Order {
#[serde(rename = "id")]
Expand Down
3 changes: 3 additions & 0 deletions samples/client/petstore/rust/src/models/pet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@

/// Pet : A pet for sale in the pet store

#[allow(unused_imports)]
use serde_json::Value;

#[derive(Debug, Serialize, Deserialize)]
pub struct Pet {
#[serde(rename = "id")]
Expand Down
3 changes: 3 additions & 0 deletions samples/client/petstore/rust/src/models/tag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@

/// Tag : A tag for a pet

#[allow(unused_imports)]
use serde_json::Value;

#[derive(Debug, Serialize, Deserialize)]
pub struct Tag {
#[serde(rename = "id")]
Expand Down
3 changes: 3 additions & 0 deletions samples/client/petstore/rust/src/models/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@

/// User : A User who is purchasing from the pet store

#[allow(unused_imports)]
use serde_json::Value;

#[derive(Debug, Serialize, Deserialize)]
pub struct User {
#[serde(rename = "id")]
Expand Down
4 changes: 1 addition & 3 deletions samples/server/petstore/rust-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ To see how to make this your own, look here:
[README](https://github.com/swagger-api/swagger-codegen/blob/master/README.md)

- API version: 1.0.0
- Build date: 2017-10-19T17:45:37.995+08:00
- Build date: 2017-10-30T02:13:46.477Z

## Examples

Expand Down Expand Up @@ -41,8 +41,6 @@ To run a client, follow one of the following simple steps:

```
cargo run --example client TestSpecialTags
cargo run --example client GetXmlFeatures
cargo run --example client PostXmlFeatures
cargo run --example client FakeOuterBooleanSerialize
cargo run --example client FakeOuterCompositeSerialize
cargo run --example client FakeOuterNumberSerialize
Expand Down
66 changes: 6 additions & 60 deletions samples/server/petstore/rust-server/api/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,11 @@ paths:
type: "array"
items:
type: "string"
default: "available"
enum:
- "available"
- "pending"
- "sold"
default: "available"
collectionFormat: "csv"
formatString: "{:?}"
example: "&Vec::new()"
Expand Down Expand Up @@ -893,10 +893,10 @@ paths:
type: "array"
items:
type: "string"
default: "$"
enum:
- ">"
- "$"
default: "$"
formatString: "{:?}"
example: "Some(&Vec::new())"
- name: "enum_form_string"
Expand All @@ -918,10 +918,10 @@ paths:
type: "array"
items:
type: "string"
default: "$"
enum:
- ">"
- "$"
default: "$"
formatString: "{:?}"
example: "Some(&Vec::new())"
- name: "enum_header_string"
Expand All @@ -943,10 +943,10 @@ paths:
type: "array"
items:
type: "string"
default: "$"
enum:
- ">"
- "$"
default: "$"
formatString: "{:?}"
example: "Some(&Vec::new())"
- name: "enum_query_string"
Expand Down Expand Up @@ -1347,60 +1347,6 @@ paths:
path: "/fake/jsonFormData"
HttpMethod: "Get"
httpmethod: "get"
/fake/xmlFeatures:
get:
summary: "Get some XML"
operationId: "getXmlFeatures"
consumes:
- "application/xml"
produces:
- "application/xml"
parameters: []
responses:
200:
description: "Success"
schema:
$ref: "#/definitions/xmlObject"
uppercase_operation_id: "GET_XML_FEATURES"
uppercase_message: "SUCCESS"
uppercase_data_type: "XMLOBJECT"
producesXml: true
operation_id: "get_xml_features"
uppercase_operation_id: "GET_XML_FEATURES"
path: "/fake/xmlFeatures"
HttpMethod: "Get"
httpmethod: "get"
post:
summary: "Post some xml"
operationId: "postXmlFeatures"
consumes:
- "application/xml"
produces:
- "application/xml"
parameters:
- in: "body"
name: "xmlObject"
required: true
schema:
$ref: "#/definitions/xmlObject"
uppercase_data_type: "XMLOBJECT"
refName: "xmlObject"
formatString: "{:?}"
example: "???"
model_key: "OuterBoolean"
uppercase_operation_id: "POST_XML_FEATURES"
consumesXml: true
responses:
200:
description: "Success"
uppercase_operation_id: "POST_XML_FEATURES"
uppercase_message: "SUCCESS"
operation_id: "post_xml_features"
uppercase_operation_id: "POST_XML_FEATURES"
path: "/fake/xmlFeatures"
HttpMethod: "Post"
httpmethod: "post"
noClientExample: true
/fake/inline-additionalProperties:
post:
tags:
Expand Down Expand Up @@ -1512,7 +1458,7 @@ definitions:
type: "string"
description: "Order Status"
enum:
- "placedtest"
- "placed"
- "approved"
- "delivered"
complete:
Expand All @@ -1524,7 +1470,7 @@ definitions:
id: 0
shipDate: "2000-01-23T04:56:07.000+00:00"
complete: false
status: "placedtest"
status: "placed"
xml:
name: "Order"
upperCaseName: "ORDER"
Expand Down
14 changes: 0 additions & 14 deletions samples/server/petstore/rust-server/examples/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ use futures::{Future, future, Stream, stream};
use petstore_api::{ApiNoContext, ContextWrapperExt,
ApiError,
TestSpecialTagsResponse,
GetXmlFeaturesResponse,
PostXmlFeaturesResponse,
FakeOuterBooleanSerializeResponse,
FakeOuterCompositeSerializeResponse,
FakeOuterNumberSerializeResponse,
Expand Down Expand Up @@ -55,7 +53,6 @@ fn main() {
.arg(Arg::with_name("operation")
.help("Sets the operation to run")
.possible_values(&[
"GetXmlFeatures",
"FakeOuterBooleanSerialize",
"FakeOuterCompositeSerialize",
"FakeOuterNumberSerialize",
Expand Down Expand Up @@ -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>")));
Expand Down
16 changes: 0 additions & 16 deletions samples/server/petstore/rust-server/examples/server_lib/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ use std::io::Error;

use petstore_api::{Api, ApiError, Context,
TestSpecialTagsResponse,
GetXmlFeaturesResponse,
PostXmlFeaturesResponse,
FakeOuterBooleanSerializeResponse,
FakeOuterCompositeSerializeResponse,
FakeOuterNumberSerializeResponse,
Expand Down Expand Up @@ -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();
Expand Down
Loading