forked from OpenAPITools/openapi-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[rust] Make it easier to test rust client generator (OpenAPITools#3543)
As we discovered in OpenAPITools#3463, there are various bits of the rust client generator that are currently untested. This PR adds tests for various generator-specific types, and also files. Follows the example of the rust-server generator for making it easy to add new test specs. This should make it easier for future contributors to make sure that their contributions are tested
- Loading branch information
Showing
134 changed files
with
2,064 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
31 changes: 31 additions & 0 deletions
31
modules/openapi-generator/src/test/resources/3_0/rust/rust-test.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
samples/client/petstore/rust-reqwest/.openapi-generator/VERSION.orig
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
34 changes: 0 additions & 34 deletions
34
samples/client/petstore/rust-reqwest/src/apis/client.rs.orig
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
/target/ | ||
**/*.rs.bk | ||
target | ||
Cargo.lock |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/*"] |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
17 changes: 17 additions & 0 deletions
17
samples/client/petstore/rust/hyper/fileResponseTest/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
43
samples/client/petstore/rust/hyper/fileResponseTest/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
|
||
|
34 changes: 34 additions & 0 deletions
34
samples/client/petstore/rust/hyper/fileResponseTest/docs/DefaultApi.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|
File renamed without changes.
23 changes: 23 additions & 0 deletions
23
samples/client/petstore/rust/hyper/fileResponseTest/src/apis/client.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} | ||
|
||
} |
41 changes: 41 additions & 0 deletions
41
samples/client/petstore/rust/hyper/fileResponseTest/src/apis/configuration.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
} | ||
} | ||
} |
Oops, something went wrong.