Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rust] Make it easier to test rust client generator #3543

Merged
merged 8 commits into from
Sep 27, 2019
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
19 changes: 17 additions & 2 deletions bin/rust-petstore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,21 @@ fi

# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/rust -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g rust -o samples/client/petstore/rust --additional-properties packageName=petstore_client --library=hyper $@"

java ${JAVA_OPTS} -jar ${executable} ${ags}
for spec_path in \
modules/openapi-generator/src/test/resources/2_0/petstore.yaml \
modules/openapi-generator/src/test/resources/3_0/rust/rust-test.yaml \
modules/openapi-generator/src/test/resources/2_0/fileResponseTest.json\
; do
spec=$(basename "$spec_path" | sed 's/.yaml//' | sed 's/.json//' )

for library in hyper reqwest; do
args="generate --template-dir modules/openapi-generator/src/main/resources/rust
--input-spec $spec_path
--generator-name rust
--output samples/client/petstore/rust/$library/$spec
--additional-properties packageName=${spec}-${library}
--library=$library $@"
java ${JAVA_OPTS} -jar ${executable} ${args} || exit 1
done
done
32 changes: 0 additions & 32 deletions bin/rust-reqwest-petstore.sh

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
openapi: 3.0.1
info:
title: Rust client test spec
description: Special testing for the Rust client generator
version: 1.0.7
paths:
/dummy:
get:
summary: A dummy endpoint to make the spec valid.
responses:
'200':
description: Success
components:
schemas:
TypeTesting:
description: Test handling of differing types (see \#3463)
type: object
properties:
integer:
type: integer
long:
type: long
number:
type: number
float:
type: float
double:
type: double
uuid:
type: string
format: uuid
1 change: 0 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1039,7 +1039,6 @@
<!-- <module>samples/client/petstore/cpp-qt5</module> -->
<module>samples/client/petstore/elm-0.18</module>
<module>samples/client/petstore/rust</module>
<module>samples/client/petstore/rust-reqwest</module>
<!--<module>samples/client/petstore/perl</module>-->
<module>samples/client/petstore/php/OpenAPIClient-php</module>
<module>samples/openapi3/client/petstore/php/OpenAPIClient-php</module>
Expand Down

This file was deleted.

46 changes: 0 additions & 46 deletions samples/client/petstore/rust-reqwest/pom.xml

This file was deleted.

34 changes: 0 additions & 34 deletions samples/client/petstore/rust-reqwest/src/apis/client.rs.orig

This file was deleted.

3 changes: 1 addition & 2 deletions samples/client/petstore/rust/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
/target/
**/*.rs.bk
target
Cargo.lock

This file was deleted.

19 changes: 2 additions & 17 deletions samples/client/petstore/rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,2 @@
[package]
name = "petstore_client"
version = "1.0.0"
authors = ["OpenAPI Generator team and contributors"]

[dependencies]
serde = "^1.0"
serde_derive = "^1.0"
serde_json = "^1.0"
url = "1.5"
hyper = "~0.11"
serde_yaml = "0.7"
base64 = "~0.7.0"
futures = "0.1.23"

[dev-dependencies]
tokio-core = "*"
[workspace]
members = ["hyper/*", "reqwest/*"]
17 changes: 17 additions & 0 deletions samples/client/petstore/rust/hyper/fileResponseTest/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[package]
name = "fileResponseTest-hyper"
version = "1.0.0"
authors = ["OpenAPI Generator team and contributors"]

[dependencies]
serde = "^1.0"
serde_derive = "^1.0"
serde_json = "^1.0"
url = "1.5"
hyper = "~0.11"
serde_yaml = "0.7"
base64 = "~0.7.0"
futures = "0.1.23"

[dev-dependencies]
tokio-core = "*"
43 changes: 43 additions & 0 deletions samples/client/petstore/rust/hyper/fileResponseTest/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Rust API client for fileResponseTest-hyper

No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

## Overview

This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [openapi-spec](https://openapis.org) from a remote server, you can easily generate an API client.

- API version: 1.0.0
- Package version: 1.0.0
- Build package: org.openapitools.codegen.languages.RustClientCodegen

## Installation

Put the package under your project folder and add the following to `Cargo.toml` under `[dependencies]`:

```
openapi = { path = "./generated" }
```

## Documentation for API Endpoints

All URIs are relative to *http://localhost/v2*

Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*DefaultApi* | [**fileresponsetest**](docs/DefaultApi.md#fileresponsetest) | **Get** /tests/fileResponse |


## Documentation For Models



To get access to the crate's generated documentation, use:

```
cargo doc --open
```

## Author



Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# \DefaultApi

All URIs are relative to *http://localhost/v2*

Method | HTTP request | Description
------------- | ------------- | -------------
[**fileresponsetest**](DefaultApi.md#fileresponsetest) | **Get** /tests/fileResponse |



## fileresponsetest

> std::path::PathBuf fileresponsetest()


### Parameters

This endpoint does not need any parameter.

### Return type

[**std::path::PathBuf**](std::path::PathBuf.md)

### Authorization

No authorization required

### HTTP request headers

- **Content-Type**: Not defined
- **Accept**: application/octet-stream

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
use std::rc::Rc;

use hyper;
use super::configuration::Configuration;

pub struct APIClient {
default_api: Box<crate::apis::DefaultApi>,
}

impl APIClient {
pub fn new<C: hyper::client::Connect>(configuration: Configuration<C>) -> APIClient {
let rc = Rc::new(configuration);

APIClient {
default_api: Box::new(crate::apis::DefaultApiClient::new(rc.clone())),
}
}

pub fn default_api(&self) -> &crate::apis::DefaultApi{
self.default_api.as_ref()
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* File Response Test
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1.0.0
*
* Generated by: https://openapi-generator.tech
*/

use hyper;

pub struct Configuration<C: hyper::client::Connect> {
pub base_path: String,
pub user_agent: Option<String>,
pub client: hyper::client::Client<C>,
pub basic_auth: Option<BasicAuth>,
pub oauth_access_token: Option<String>,
pub api_key: Option<ApiKey>,
// TODO: take an oauth2 token source, similar to the go one
}

pub type BasicAuth = (String, Option<String>);

pub struct ApiKey {
pub prefix: Option<String>,
pub key: String,
}

impl<C: hyper::client::Connect> Configuration<C> {
pub fn new(client: hyper::client::Client<C>) -> Configuration<C> {
Configuration {
base_path: "http://localhost/v2".to_owned(),
user_agent: Some("OpenAPI-Generator/1.0.0/rust".to_owned()),
client: client,
basic_auth: None,
oauth_access_token: None,
api_key: None,
}
}
}
Loading