Skip to content

Commit

Permalink
[Rust] rename rust2 to rust-server (#6747)
Browse files Browse the repository at this point in the history
* rename rust2 to rust-server

* update rust-server batch file to use petstore test spec
  • Loading branch information
wing328 authored Oct 19, 2017
1 parent 3472c68 commit f0b7dae
Show file tree
Hide file tree
Showing 39 changed files with 237 additions and 172 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
This is the swagger codegen project, which allows generation of API client libraries (SDK generation), server stubs and documentation automatically given an [OpenAPI Spec](https://github.com/OAI/OpenAPI-Specification). Currently, the following languages/frameworks are supported:

- **API clients**: **ActionScript**, **Ada**, **Apex**, **Bash**, **C#** (.net 2.0, 4.0 or later), **C++** (cpprest, Qt5, Tizen), **Clojure**, **Dart**, **Elixir**, **Eiffel**, **Go**, **Groovy**, **Haskell** (http-client, Servant), **Java** (Jersey1.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign, RestTemplate, RESTEasy, Vertx), **Kotlin**, **Lua**, **Node.js** (ES5, ES6, AngularJS with Google Closure Compiler annotations) **Objective-C**, **Perl**, **PHP**, **PowerShell**, **Python**, **R**, **Ruby**, **Rust**, **Scala** (akka, http4s, swagger-async-httpclient), **Swift** (2.x, 3.x, 4.x), **Typescript** (Angular1.x, Angular2.x, Fetch, jQuery, Node)
- **Server stubs**: **C#** (ASP.NET Core, NancyFx), **C++** (Pistache, Restbed), **Erlang**, **Go**, **Haskell** (Servant), **Java** (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, RestEasy, Play Framework), **PHP** (Lumen, Slim, Silex, [Symfony](https://symfony.com/), [Zend Expressive](https://github.com/zendframework/zend-expressive)), **Python** (Flask), **NodeJS**, **Ruby** (Sinatra, Rails5), **Scala** ([Finch](https://github.com/finagle/finch), Scalatra)
- **Server stubs**: **C#** (ASP.NET Core, NancyFx), **C++** (Pistache, Restbed), **Erlang**, **Go**, **Haskell** (Servant), **Java** (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, RestEasy, Play Framework), **PHP** (Lumen, Slim, Silex, [Symfony](https://symfony.com/), [Zend Expressive](https://github.com/zendframework/zend-expressive)), **Python** (Flask), **NodeJS**, **Ruby** (Sinatra, Rails5), **Rust**, **Scala** ([Finch](https://github.com/finagle/finch), Scalatra)
- **API documentation generators**: **HTML**, **Confluence Wiki**
- **Configuration files**: [**Apache2**](https://httpd.apache.org/)
- **Others**: **JMeter**
Expand Down
2 changes: 1 addition & 1 deletion bin/rust2-petstore.sh → bin/rust-server-petstore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ 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/swagger-codegen/src/main/resources/rust2 -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l rust2 -o samples/client/petstore/rust2 -DpackageName=petstore_api"
ags="$@ generate -t modules/swagger-codegen/src/main/resources/rust-server -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l rust-server -o samples/server/petstore/rust-server -DpackageName=petstore_api"

java $JAVA_OPTS -jar $executable $ags
10 changes: 10 additions & 0 deletions bin/windows/rust-server-petstore.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
set executable=.\modules\swagger-codegen-cli\target\swagger-codegen-cli.jar

If Not Exist %executable% (
mvn clean package
)

REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -DloggerPath=conf/log4j.properties
set ags=generate -i modules\swagger-codegen\src\test\resources\2_0\petstore-with-fake-endpoints-models-for-testing.yaml -l rust-server -o samples\server\petstore\rust-server

java %JAVA_OPTS% -jar %executable% %ags%
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,25 @@
import java.util.Map.Entry;
import org.apache.commons.lang3.StringUtils;

public class Rust2Codegen extends DefaultCodegen implements CodegenConfig {
public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {

private static final Logger LOGGER = LoggerFactory.getLogger(Rust2Codegen.class);
private static final Logger LOGGER = LoggerFactory.getLogger(RustServerCodegen.class);

private HashMap<String, String> modelXmlNames = new HashMap<String, String>();

protected String apiVersion = "1.0.0";
protected int serverPort = 8080;
protected String projectName = "swagger-server";
protected String apiPath = "rust2";
protected String apiPath = "rust-server";
protected String packageName;
protected String packageVersion;
protected String externCrateName;

public Rust2Codegen() {
public RustServerCodegen() {
super();

// set the output folder here
outputFolder = "generated-code/rust2";
outputFolder = "generated-code/rust-server";

/*
* Models. You can write model files using the modelTemplateFiles map.
Expand All @@ -66,7 +66,7 @@ public Rust2Codegen() {
* Template Location. This is the location which templates will be read from. The generator
* will use the resource stream to attempt to read the templates.
*/
embeddedTemplateDir = templateDir = "rust2";
embeddedTemplateDir = templateDir = "rust-server";

/*
* Reserved words. Override this with reserved words specific to your language
Expand Down Expand Up @@ -232,7 +232,7 @@ public CodegenType getTag() {
*/
@Override
public String getName() {
return "rust2";
return "rust-server";
}

/**
Expand All @@ -243,7 +243,7 @@ public String getName() {
*/
@Override
public String getHelp() {
return "Generates a Rust client/server library using the swagger-codegen project.";
return "Generates a Rust client/server library (beta) using the swagger-codegen project.";
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ io.swagger.codegen.languages.RClientCodegen
io.swagger.codegen.languages.Rails5ServerCodegen
io.swagger.codegen.languages.RestbedCodegen
io.swagger.codegen.languages.RubyClientCodegen
io.swagger.codegen.languages.Rust2Codegen
io.swagger.codegen.languages.RustClientCodegen
io.swagger.codegen.languages.RustServerCodegen
io.swagger.codegen.languages.ScalaClientCodegen
io.swagger.codegen.languages.ScalatraServerCodegen
io.swagger.codegen.languages.ScalazClientCodegen
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
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-09-26T16:36:55.563+01:00
- Build date: 2017-10-19T17:45:37.995+08:00

## Examples

Expand Down Expand Up @@ -50,6 +50,7 @@ cargo run --example client FakeOuterStringSerialize
cargo run --example client TestClientModel
cargo run --example client TestEndpointParameters
cargo run --example client TestEnumParameters
cargo run --example client TestInlineAdditionalProperties
cargo run --example client TestJsonFormData
cargo run --example client TestClassname
cargo run --example client AddPet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ info:
contact:
email: "apiteam@swagger.io"
license:
name: "Apache 2.0"
name: "Apache-2.0"
url: "http://www.apache.org/licenses/LICENSE-2.0.html"
host: "petstore.swagger.io:80"
basePath: "/v2"
Expand Down Expand Up @@ -54,7 +54,7 @@ paths:
refName: "Pet"
formatString: "{:?}"
example: "???"
model_key: "itemList"
model_key: "OuterBoolean"
uppercase_operation_id: "ADD_PET"
consumesXml: true
responses:
Expand Down Expand Up @@ -95,7 +95,7 @@ paths:
refName: "Pet"
formatString: "{:?}"
example: "???"
model_key: "itemList"
model_key: "OuterBoolean"
uppercase_operation_id: "UPDATE_PET"
consumesXml: true
responses:
Expand Down Expand Up @@ -450,7 +450,7 @@ paths:
refName: "Order"
formatString: "{:?}"
example: "???"
model_key: "itemList"
model_key: "OuterBoolean"
uppercase_operation_id: "PLACE_ORDER"
responses:
200:
Expand Down Expand Up @@ -568,7 +568,7 @@ paths:
refName: "User"
formatString: "{:?}"
example: "???"
model_key: "itemList"
model_key: "OuterBoolean"
uppercase_operation_id: "CREATE_USER"
responses:
default:
Expand Down Expand Up @@ -602,7 +602,7 @@ paths:
$ref: "#/definitions/User"
formatString: "{:?}"
example: "&Vec::new()"
model_key: "itemList"
model_key: "OuterBoolean"
uppercase_operation_id: "CREATE_USERS_WITH_ARRAY_INPUT"
responses:
default:
Expand Down Expand Up @@ -635,7 +635,7 @@ paths:
$ref: "#/definitions/User"
formatString: "{:?}"
example: "&Vec::new()"
model_key: "itemList"
model_key: "OuterBoolean"
uppercase_operation_id: "CREATE_USERS_WITH_LIST_INPUT"
responses:
default:
Expand Down Expand Up @@ -787,7 +787,7 @@ paths:
refName: "User"
formatString: "{:?}"
example: "???"
model_key: "itemList"
model_key: "OuterBoolean"
uppercase_operation_id: "UPDATE_USER"
responses:
400:
Expand Down Expand Up @@ -856,7 +856,7 @@ paths:
refName: "Client"
formatString: "{:?}"
example: "???"
model_key: "itemList"
model_key: "OuterBoolean"
uppercase_operation_id: "TEST_CLASSNAME"
responses:
200:
Expand Down Expand Up @@ -1169,7 +1169,7 @@ paths:
refName: "Client"
formatString: "{:?}"
example: "???"
model_key: "itemList"
model_key: "OuterBoolean"
uppercase_operation_id: "TEST_CLIENT_MODEL"
responses:
200:
Expand Down Expand Up @@ -1202,7 +1202,7 @@ paths:
refName: "OuterNumber"
formatString: "{:?}"
example: "None"
model_key: "itemList"
model_key: "OuterBoolean"
uppercase_operation_id: "FAKE_OUTER_NUMBER_SERIALIZE"
responses:
200:
Expand Down Expand Up @@ -1234,7 +1234,7 @@ paths:
refName: "OuterString"
formatString: "{:?}"
example: "None"
model_key: "itemList"
model_key: "OuterBoolean"
uppercase_operation_id: "FAKE_OUTER_STRING_SERIALIZE"
responses:
200:
Expand Down Expand Up @@ -1266,7 +1266,7 @@ paths:
refName: "OuterBoolean"
formatString: "{:?}"
example: "None"
model_key: "itemList"
model_key: "OuterBoolean"
uppercase_operation_id: "FAKE_OUTER_BOOLEAN_SERIALIZE"
responses:
200:
Expand Down Expand Up @@ -1298,7 +1298,7 @@ paths:
refName: "OuterComposite"
formatString: "{:?}"
example: "None"
model_key: "itemList"
model_key: "OuterBoolean"
uppercase_operation_id: "FAKE_OUTER_COMPOSITE_SERIALIZE"
responses:
200:
Expand Down Expand Up @@ -1365,7 +1365,6 @@ paths:
uppercase_message: "SUCCESS"
uppercase_data_type: "XMLOBJECT"
producesXml: true
has_namespace: "true"
operation_id: "get_xml_features"
uppercase_operation_id: "GET_XML_FEATURES"
path: "/fake/xmlFeatures"
Expand All @@ -1388,8 +1387,7 @@ paths:
refName: "xmlObject"
formatString: "{:?}"
example: "???"
has_namespace: "true"
model_key: "itemList"
model_key: "OuterBoolean"
uppercase_operation_id: "POST_XML_FEATURES"
consumesXml: true
responses:
Expand All @@ -1403,6 +1401,41 @@ paths:
HttpMethod: "Post"
httpmethod: "post"
noClientExample: true
/fake/inline-additionalProperties:
post:
tags:
- "fake"
summary: "test inline additionalProperties"
description: ""
operationId: "testInlineAdditionalProperties"
consumes:
- "application/json"
parameters:
- in: "body"
name: "param"
description: "request body"
required: true
schema:
type: "object"
additionalProperties:
type: "string"
upperCaseName: "PARAM"
refName: null
formatString: "{:?}"
example: "???"
model_key: "OuterBoolean"
uppercase_operation_id: "TEST_INLINE_ADDITIONAL_PROPERTIES"
responses:
200:
description: "successful operation"
uppercase_operation_id: "TEST_INLINE_ADDITIONAL_PROPERTIES"
uppercase_message: "SUCCESSFUL_OPERATION"
operation_id: "test_inline_additional_properties"
uppercase_operation_id: "TEST_INLINE_ADDITIONAL_PROPERTIES"
path: "/fake/inline-additionalProperties"
HttpMethod: "Post"
httpmethod: "post"
noClientExample: true
/another-fake/dummy:
patch:
tags:
Expand All @@ -1425,7 +1458,7 @@ paths:
refName: "Client"
formatString: "{:?}"
example: "???"
model_key: "itemList"
model_key: "OuterBoolean"
uppercase_operation_id: "TEST_SPECIAL_TAGS"
responses:
200:
Expand Down Expand Up @@ -1968,15 +2001,6 @@ definitions:
- "approved"
- "delivered"
upperCaseName: "OUTERENUM"
OuterNumber:
type: "number"
upperCaseName: "OUTERNUMBER"
OuterString:
type: "string"
upperCaseName: "OUTERSTRING"
OuterBoolean:
type: "boolean"
upperCaseName: "OUTERBOOLEAN"
OuterComposite:
type: "object"
properties:
Expand All @@ -1991,30 +2015,15 @@ definitions:
my_number: {}
my_boolean: {}
upperCaseName: "OUTERCOMPOSITE"
xmlObject:
required:
- "itemList"
- "name"
properties:
name:
type: "string"
example: "myXmlObject"
itemList:
$ref: "#/definitions/itemList"
itemXmlName: "item"
xml:
name: "group"
namespace: "http://example.com/schema.xsd"
upperCaseName: "XMLOBJECT"
itemList:
type: "array"
items:
type: "string"
example: "my item"
xml:
name: "item"
upperCaseName: "ITEMLIST"
itemXmlName: "item"
OuterNumber:
type: "number"
upperCaseName: "OUTERNUMBER"
OuterString:
type: "string"
upperCaseName: "OUTERSTRING"
OuterBoolean:
type: "boolean"
upperCaseName: "OUTERBOOLEAN"
externalDocs:
description: "Find out more about Swagger"
url: "http://swagger.io"
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use petstore_api::{ApiNoContext, ContextWrapperExt,
TestClientModelResponse,
TestEndpointParametersResponse,
TestEnumParametersResponse,
TestInlineAdditionalPropertiesResponse,
TestJsonFormDataResponse,
TestClassnameResponse,
AddPetResponse,
Expand Down Expand Up @@ -151,6 +152,12 @@ fn main() {
println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
},

// Disabled because there's no example.
// Some("TestInlineAdditionalProperties") => {
// let result = client.test_inline_additional_properties(???).wait();
// println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
// },

Some("TestJsonFormData") => {
let result = client.test_json_form_data("param_example".to_string(), "param2_example".to_string()).wait();
println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
Expand Down
Loading

0 comments on commit f0b7dae

Please sign in to comment.