diff --git a/bin/rust-server-petstore.sh b/bin/rust-server-petstore.sh index 06a8c4d020..5d76464ace 100755 --- a/bin/rust-server-petstore.sh +++ b/bin/rust-server-petstore.sh @@ -25,8 +25,10 @@ then mvn -B clean package fi -# if you've executed sbt assembly previously it will use that instead. -export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" -ags="generate -t modules/openapi-generator/src/main/resources/rust-server -i modules/openapi-generator/src/test/resources/2_0/rust-server/petstore-with-fake-endpoints-models-for-testing.yaml -g rust-server -o samples/server/petstore/rust-server -DpackageName=petstore_api --additional-properties hideGenerationTimestamp=true $@" +for spec_path in modules/openapi-generator/src/test/resources/2_0/rust-server/* ; do + export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" + spec=$(basename "$spec_path" | sed 's/.yaml//') + ags="generate -t modules/openapi-generator/src/main/resources/rust-server -i $spec_path -g rust-server -o samples/server/petstore/rust-server/output/$spec -DpackageName=$spec --additional-properties hideGenerationTimestamp=true $@" -java $JAVA_OPTS -jar $executable $ags + java $JAVA_OPTS -jar $executable $ags +done diff --git a/samples/server/petstore/rust-server/Cargo.toml b/samples/server/petstore/rust-server/Cargo.toml index 2cbbb4cc2e..68d06c5410 100644 --- a/samples/server/petstore/rust-server/Cargo.toml +++ b/samples/server/petstore/rust-server/Cargo.toml @@ -1,48 +1,2 @@ -[package] -name = "petstore_api" -version = "1.0.0" -authors = [] -description = "This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\" -license = "Unlicense" - -[features] -default = ["client", "server"] -client = ["serde_json", "serde_urlencoded", "serde-xml-rs", "serde_ignored", "hyper", "hyper-tls", "native-tls", "openssl", "tokio-core", "url", "uuid"] -server = ["serde_json", "serde-xml-rs", "serde_ignored", "hyper", "hyper-tls", "native-tls", "openssl", "tokio-core", "tokio-proto", "tokio-tls", "regex", "percent-encoding", "url", "uuid"] - -[dependencies] -# Required by example server. -# -chrono = { version = "0.4", features = ["serde"] } -futures = "0.1" -hyper = {version = "0.11", optional = true} -hyper-tls = {version = "0.1.2", optional = true} -swagger = "1.0.1" - -# Not required by example server. -# -lazy_static = "0.2" -log = "0.3.0" -mime = "0.3.3" -multipart = {version = "0.13.3", optional = true} -native-tls = {version = "0.1.4", optional = true} -openssl = {version = "0.9.14", optional = true} -percent-encoding = {version = "1.0.0", optional = true} -regex = {version = "0.2", optional = true} -serde = "1.0" -serde_derive = "1.0" -serde_ignored = {version = "0.0.4", optional = true} -serde_json = {version = "1.0", optional = true} -serde_urlencoded = {version = "0.5.1", optional = true} -tokio-core = {version = "0.1.6", optional = true} -tokio-proto = {version = "0.1.1", optional = true} -tokio-tls = {version = "0.1.3", optional = true, features = ["tokio-proto"]} -url = {version = "1.5", optional = true} -uuid = {version = "0.5", optional = true, features = ["serde", "v4"]} -# ToDo: this should be updated to point at the official crate once -# https://github.com/RReverser/serde-xml-rs/pull/45 is accepted upstream -serde-xml-rs = {git = "git://github.com/Metaswitch/serde-xml-rs.git" , branch = "master", optional = true} - -[dev-dependencies] -clap = "2.25" -error-chain = "0.12" +[workspace] +members = ["output/*"] diff --git a/samples/server/petstore/rust-server/.cargo/config b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/.cargo/config similarity index 100% rename from samples/server/petstore/rust-server/.cargo/config rename to samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/.cargo/config diff --git a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/.gitignore b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/.gitignore new file mode 100644 index 0000000000..a9d37c560c --- /dev/null +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/.gitignore @@ -0,0 +1,2 @@ +target +Cargo.lock diff --git a/samples/server/petstore/rust-server/.openapi-generator-ignore b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/.openapi-generator-ignore similarity index 100% rename from samples/server/petstore/rust-server/.openapi-generator-ignore rename to samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/.openapi-generator-ignore diff --git a/samples/server/petstore/rust-server/.openapi-generator/VERSION b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/.openapi-generator/VERSION similarity index 100% rename from samples/server/petstore/rust-server/.openapi-generator/VERSION rename to samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/.openapi-generator/VERSION diff --git a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/Cargo.toml b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/Cargo.toml new file mode 100644 index 0000000000..e5dc334269 --- /dev/null +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/Cargo.toml @@ -0,0 +1,48 @@ +[package] +name = "petstore-with-fake-endpoints-models-for-testing" +version = "1.0.0" +authors = [] +description = "This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\" +license = "Unlicense" + +[features] +default = ["client", "server"] +client = ["serde_json", "serde_urlencoded", "serde-xml-rs", "serde_ignored", "hyper", "hyper-tls", "native-tls", "openssl", "tokio-core", "url", "uuid"] +server = ["serde_json", "serde-xml-rs", "serde_ignored", "hyper", "hyper-tls", "native-tls", "openssl", "tokio-core", "tokio-proto", "tokio-tls", "regex", "percent-encoding", "url", "uuid"] + +[dependencies] +# Required by example server. +# +chrono = { version = "0.4", features = ["serde"] } +futures = "0.1" +hyper = {version = "0.11", optional = true} +hyper-tls = {version = "0.1.2", optional = true} +swagger = "1.0.1" + +# Not required by example server. +# +lazy_static = "0.2" +log = "0.3.0" +mime = "0.3.3" +multipart = {version = "0.13.3", optional = true} +native-tls = {version = "0.1.4", optional = true} +openssl = {version = "0.9.14", optional = true} +percent-encoding = {version = "1.0.0", optional = true} +regex = {version = "0.2", optional = true} +serde = "1.0" +serde_derive = "1.0" +serde_ignored = {version = "0.0.4", optional = true} +serde_json = {version = "1.0", optional = true} +serde_urlencoded = {version = "0.5.1", optional = true} +tokio-core = {version = "0.1.6", optional = true} +tokio-proto = {version = "0.1.1", optional = true} +tokio-tls = {version = "0.1.3", optional = true, features = ["tokio-proto"]} +url = {version = "1.5", optional = true} +uuid = {version = "0.5", optional = true, features = ["serde", "v4"]} +# ToDo: this should be updated to point at the official crate once +# https://github.com/RReverser/serde-xml-rs/pull/45 is accepted upstream +serde-xml-rs = {git = "git://github.com/Metaswitch/serde-xml-rs.git" , branch = "master", optional = true} + +[dev-dependencies] +clap = "2.25" +error-chain = "0.12" diff --git a/samples/server/petstore/rust-server/README.md b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/README.md similarity index 79% rename from samples/server/petstore/rust-server/README.md rename to samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/README.md index 9d56541b6a..f8b30f1711 100644 --- a/samples/server/petstore/rust-server/README.md +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/README.md @@ -1,4 +1,4 @@ -# Rust API for petstore_api +# Rust API for petstore-with-fake-endpoints-models-for-testing This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ @@ -14,17 +14,17 @@ To see how to make this your own, look here: - API version: 1.0.0 -This autogenerated project defines an API crate `petstore_api` which contains: +This autogenerated project defines an API crate `petstore-with-fake-endpoints-models-for-testing` which contains: * An `Api` trait defining the API in Rust. * Data types representing the underlying data model. * A `Client` type which implements `Api` and issues HTTP requests for each operation. * A router which accepts HTTP requests and invokes the appropriate `Api` method for each operation. -It also contains an example server and client which make use of `petstore_api`: -* The example server starts up a web server using the `petstore_api` router, +It also contains an example server and client which make use of `petstore-with-fake-endpoints-models-for-testing`: +* The example server starts up a web server using the `petstore-with-fake-endpoints-models-for-testing` router, and supplies a trivial implementation of `Api` which returns failure for every operation. * The example client provides a CLI which lets you invoke any single operation on the - `petstore_api` client by passing appropriate arguments on the command line. + `petstore-with-fake-endpoints-models-for-testing` client by passing appropriate arguments on the command line. You can use the example server and client as a basis for your own code. See below for [more detail on implementing a server](#writing-a-server). @@ -105,17 +105,17 @@ This will use the keys/certificates from the examples directory. Note that the s The server example is designed to form the basis for implementing your own server. Simply follow these steps. * Set up a new Rust project, e.g., with `cargo init --bin`. -* Insert `petstore_api` into the `members` array under [workspace] in the root `Cargo.toml`, e.g., `members = [ "petstore_api" ]`. -* Add `petstore_api = {version = "1.0.0", path = "petstore_api"}` under `[dependencies]` in the root `Cargo.toml`. -* Copy the `[dependencies]` and `[dev-dependencies]` from `petstore_api/Cargo.toml` into the root `Cargo.toml`'s `[dependencies]` section. +* Insert `petstore-with-fake-endpoints-models-for-testing` into the `members` array under [workspace] in the root `Cargo.toml`, e.g., `members = [ "petstore-with-fake-endpoints-models-for-testing" ]`. +* Add `petstore-with-fake-endpoints-models-for-testing = {version = "1.0.0", path = "petstore-with-fake-endpoints-models-for-testing"}` under `[dependencies]` in the root `Cargo.toml`. +* Copy the `[dependencies]` and `[dev-dependencies]` from `petstore-with-fake-endpoints-models-for-testing/Cargo.toml` into the root `Cargo.toml`'s `[dependencies]` section. * Copy all of the `[dev-dependencies]`, but only the `[dependencies]` that are required by the example server. These should be clearly indicated by comments. * Remove `"optional = true"` from each of these lines if present. Each autogenerated API will contain an implementation stub and main entry point, which should be copied into your project the first time: ``` -cp petstore_api/examples/server.rs src/main.rs -cp petstore_api/examples/server_lib/mod.rs src/lib.rs -cp petstore_api/examples/server_lib/server.rs src/server.rs +cp petstore-with-fake-endpoints-models-for-testing/examples/server.rs src/main.rs +cp petstore-with-fake-endpoints-models-for-testing/examples/server_lib/mod.rs src/lib.rs +cp petstore-with-fake-endpoints-models-for-testing/examples/server_lib/server.rs src/server.rs ``` Now diff --git a/samples/server/petstore/rust-server/api/openapi.yaml b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/api/openapi.yaml similarity index 100% rename from samples/server/petstore/rust-server/api/openapi.yaml rename to samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/api/openapi.yaml diff --git a/samples/server/petstore/rust-server/examples/ca.pem b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/examples/ca.pem similarity index 100% rename from samples/server/petstore/rust-server/examples/ca.pem rename to samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/examples/ca.pem diff --git a/samples/server/petstore/rust-server/examples/client.rs b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/examples/client.rs similarity index 97% rename from samples/server/petstore/rust-server/examples/client.rs rename to samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/examples/client.rs index d87dd25b87..be8c084e7b 100644 --- a/samples/server/petstore/rust-server/examples/client.rs +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/examples/client.rs @@ -1,6 +1,6 @@ #![allow(missing_docs, unused_variables, trivial_casts)] -extern crate petstore_api; +extern crate petstore_with_fake_endpoints_models_for_testing; #[allow(unused_extern_crates)] extern crate futures; #[allow(unused_extern_crates)] @@ -17,7 +17,7 @@ use swagger::{ContextBuilder, EmptyContext, XSpanIdString, Has, Push, AuthData}; use futures::{Future, future, Stream, stream}; use tokio_core::reactor; #[allow(unused_imports)] -use petstore_api::{ApiNoContext, ContextWrapperExt, +use petstore_with_fake_endpoints_models_for_testing::{ApiNoContext, ContextWrapperExt, ApiError, TestSpecialTagsResponse, FakeOuterBooleanSerializeResponse, @@ -107,11 +107,11 @@ fn main() { matches.value_of("port").unwrap()); let client = if matches.is_present("https") { // Using Simple HTTPS - petstore_api::Client::try_new_https(core.handle(), &base_url, "examples/ca.pem") + petstore_with_fake_endpoints_models_for_testing::Client::try_new_https(core.handle(), &base_url, "examples/ca.pem") .expect("Failed to create HTTPS client") } else { // Using HTTP - petstore_api::Client::try_new_http(core.handle(), &base_url) + petstore_with_fake_endpoints_models_for_testing::Client::try_new_http(core.handle(), &base_url) .expect("Failed to create HTTP client") }; diff --git a/samples/server/petstore/rust-server/examples/server-chain.pem b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/examples/server-chain.pem similarity index 100% rename from samples/server/petstore/rust-server/examples/server-chain.pem rename to samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/examples/server-chain.pem diff --git a/samples/server/petstore/rust-server/examples/server-key.pem b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/examples/server-key.pem similarity index 100% rename from samples/server/petstore/rust-server/examples/server-key.pem rename to samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/examples/server-key.pem diff --git a/samples/server/petstore/rust-server/examples/server.rs b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/examples/server.rs similarity index 86% rename from samples/server/petstore/rust-server/examples/server.rs rename to samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/examples/server.rs index 270b1e5cdb..0f2aba9655 100644 --- a/samples/server/petstore/rust-server/examples/server.rs +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/examples/server.rs @@ -1,10 +1,10 @@ -//! Main binary entry point for petstore_api implementation. +//! Main binary entry point for petstore_with_fake_endpoints_models_for_testing implementation. #![allow(missing_docs)] // Imports required by this file. // extern crate ; -extern crate petstore_api; +extern crate petstore_with_fake_endpoints_models_for_testing; extern crate swagger; extern crate hyper; extern crate openssl; @@ -14,7 +14,7 @@ extern crate tokio_tls; extern crate clap; // Imports required by server library. -// extern crate petstore_api; +// extern crate petstore_with_fake_endpoints_models_for_testing; // extern crate swagger; extern crate futures; extern crate chrono; @@ -55,7 +55,7 @@ fn main() { .get_matches(); let service_fn = - petstore_api::server::context::NewAddContext::<_, EmptyContext>::new( + petstore_with_fake_endpoints_models_for_testing::server::context::NewAddContext::<_, EmptyContext>::new( AllowAllAuthenticator::new( server_lib::NewService::new(), "cosmo" diff --git a/samples/server/petstore/rust-server/examples/server_lib/mod.rs b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/examples/server_lib/mod.rs similarity index 66% rename from samples/server/petstore/rust-server/examples/server_lib/mod.rs rename to samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/examples/server_lib/mod.rs index c4f682d653..9c406c28aa 100644 --- a/samples/server/petstore/rust-server/examples/server_lib/mod.rs +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/examples/server_lib/mod.rs @@ -1,4 +1,4 @@ -//! Main library entry point for petstore_api implementation. +//! Main library entry point for petstore_with_fake_endpoints_models_for_testing implementation. mod server; @@ -11,7 +11,7 @@ use std::io; use std::clone::Clone; use std::marker::PhantomData; use hyper; -use petstore_api; +use petstore_with_fake_endpoints_models_for_testing; use swagger::{Has, XSpanIdString}; use swagger::auth::Authorization; @@ -29,10 +29,10 @@ impl hyper::server::NewService for NewService where C: Has type Request = (hyper::Request, C); type Response = hyper::Response; type Error = hyper::Error; - type Instance = petstore_api::server::Service, C>; + type Instance = petstore_with_fake_endpoints_models_for_testing::server::Service, C>; /// Instantiate a new server. fn new_service(&self) -> io::Result { - Ok(petstore_api::server::Service::new(server::Server::new())) + Ok(petstore_with_fake_endpoints_models_for_testing::server::Service::new(server::Server::new())) } } diff --git a/samples/server/petstore/rust-server/examples/server_lib/server.rs b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/examples/server_lib/server.rs similarity index 98% rename from samples/server/petstore/rust-server/examples/server_lib/server.rs rename to samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/examples/server_lib/server.rs index c470b7be10..1f1d1e00a2 100644 --- a/samples/server/petstore/rust-server/examples/server_lib/server.rs +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/examples/server_lib/server.rs @@ -1,4 +1,4 @@ -//! Server implementation of petstore_api. +//! Server implementation of petstore_with_fake_endpoints_models_for_testing. #![allow(unused_imports)] @@ -10,7 +10,7 @@ use std::marker::PhantomData; use swagger; use swagger::{Has, XSpanIdString}; -use petstore_api::{Api, ApiError, +use petstore_with_fake_endpoints_models_for_testing::{Api, ApiError, TestSpecialTagsResponse, FakeOuterBooleanSerializeResponse, FakeOuterCompositeSerializeResponse, @@ -44,7 +44,7 @@ use petstore_api::{Api, ApiError, LogoutUserResponse, UpdateUserResponse }; -use petstore_api::models; +use petstore_with_fake_endpoints_models_for_testing::models; #[derive(Copy, Clone)] pub struct Server { diff --git a/samples/server/petstore/rust-server/src/client/mod.rs b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/client/mod.rs similarity index 100% rename from samples/server/petstore/rust-server/src/client/mod.rs rename to samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/client/mod.rs diff --git a/samples/server/petstore/rust-server/src/lib.rs b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/lib.rs similarity index 100% rename from samples/server/petstore/rust-server/src/lib.rs rename to samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/lib.rs diff --git a/samples/server/petstore/rust-server/src/mimetypes.rs b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/mimetypes.rs similarity index 100% rename from samples/server/petstore/rust-server/src/mimetypes.rs rename to samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/mimetypes.rs diff --git a/samples/server/petstore/rust-server/src/models.rs b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/models.rs similarity index 100% rename from samples/server/petstore/rust-server/src/models.rs rename to samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/models.rs diff --git a/samples/server/petstore/rust-server/src/server/context.rs b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/server/context.rs similarity index 100% rename from samples/server/petstore/rust-server/src/server/context.rs rename to samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/server/context.rs diff --git a/samples/server/petstore/rust-server/src/server/mod.rs b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs similarity index 100% rename from samples/server/petstore/rust-server/src/server/mod.rs rename to samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs