Skip to content

Commit

Permalink
[New Generator] Rust API client/server generator (#6613)
Browse files Browse the repository at this point in the history
* Rust API client/server generator

* `Future::boxed()` has been deprecated - replace with `Box::new(...)`

* rebasing to rust

* MMMLS211 use empty vec over none

* MMMLS211 rebuild after merge from rust

* MMMLS211 YAML array examples not wrapped in Some()

* MMMLS211 Array parameters bad mustache fix

* MMMLS211 don't parse map containers

* MMMLS211 Tidy container types

* MMMLS-211 rebuild example

* MMMLS211 mvn rebuild

* Percent-decode parameters contained in the path

* Produce warnings when unknown fields are present

We still accept unknown fields and discard them. However, to improve
diagnosability, we now write a warning log and return a `Warning`
header.

Note that this is server-only

* Markup

* MMMLS211: Make optional arrays Options again

* 211 markups

* Temporary attempt at tweaking Cow ownership tweak while merging changes from rust branch

* Remove to_string call while parsing path parameters, which requires definining a temporary var in a block because rust can't tell where a Cow reference gets dropped

* Fix rustfmt to the correct version

* Fix rustfmt to the correct version

* Add more response information to ApiError in client

* Re-add missing brace

* Code review markups

* Allow converting out of wrapper types

* Store arrays in new-types too

* Use a new hyper_client every request

* Add vec-like traits to array types

* Xml support - new branch

* Moved conversion from serde_xml_rs::Error to ApiError from swagger-rs to client code until upstream PR is accepted

* MMSUB-172 Don't set Content-Type when there's no body.

If we don't have a body we've serialized, then don't declare
any content type for the nonexistent body.

This is really important for 204 No Content responses, but it's
also morally important for all other non-bodied responses.

* MMSUB-172 Move to swagger 0.6.

* Manually implement debug for the client

* Allow `Context` to be bound to `Api`, and not passed on every function call

* Support "." in parameter names

* Support generate's "--reserved-words-mappings" option

* Support "." in parameter names

* Support generate's "--reserved-words-mappings" option
  • Loading branch information
BenjaminGill-Metaswitch authored and wing328 committed Oct 19, 2017
1 parent d378941 commit 1d89ab6
Show file tree
Hide file tree
Showing 41 changed files with 11,651 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,7 @@ Here is a list of template creators:
* PowerShell: @beatcracker
* R: @ramnov
* Rust: @farcaller
* Rust (rust-server): @metaswitch
* Scala (scalaz & http4s): @tbrown1979
* Swift: @tkqubo
* Swift 3: @hexelon
Expand Down Expand Up @@ -1018,6 +1019,7 @@ Here is a list of template creators:
* PHP Symfony: @ksm2
* PHP Zend Expressive (with Path Handler): @Articus
* Ruby on Rails 5: @zlx
* Rust (rust-server): @metaswitch
* Scala Finch: @jimschubert
* Documentation
* HTML Doc 2: @jhitchcock
Expand Down
31 changes: 31 additions & 0 deletions bin/rust2-petstore.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/sh

SCRIPT="$0"

while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done

if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi

executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"

if [ ! -f "$executable" ]
then
mvn 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/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"

java $JAVA_OPTS -jar $executable $ags
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import io.swagger.models.ExternalDocs;


public class CodegenModel {
public String parent, parentSchema;
public List<String> interfaces;
Expand Down
Loading

0 comments on commit 1d89ab6

Please sign in to comment.