forked from loafle/openapi-generator-original
add uuid test, better hyper test (#12916)
This commit is contained in:
parent
4ee336a9da
commit
b88666b87a
@ -1,7 +1,7 @@
|
|||||||
generatorName: rust
|
generatorName: rust
|
||||||
outputDir: samples/client/petstore/rust/hyper/petstore
|
outputDir: samples/client/petstore/rust/hyper/petstore
|
||||||
library: hyper
|
library: hyper
|
||||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
|
inputSpec: modules/openapi-generator/src/test/resources/3_0/rust/petstore.yaml
|
||||||
templateDir: modules/openapi-generator/src/main/resources/rust
|
templateDir: modules/openapi-generator/src/main/resources/rust
|
||||||
additionalProperties:
|
additionalProperties:
|
||||||
supportAsync: "false"
|
supportAsync: "false"
|
||||||
|
@ -769,3 +769,11 @@ components:
|
|||||||
type: string
|
type: string
|
||||||
message:
|
message:
|
||||||
type: string
|
type: string
|
||||||
|
property_test:
|
||||||
|
title: A model to test various formats, e.g. UUID
|
||||||
|
description: A model to test various formats, e.g. UUID
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
uuid:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
|
@ -4,9 +4,11 @@ Cargo.toml
|
|||||||
README.md
|
README.md
|
||||||
docs/ApiResponse.md
|
docs/ApiResponse.md
|
||||||
docs/Category.md
|
docs/Category.md
|
||||||
|
docs/FakeApi.md
|
||||||
docs/Order.md
|
docs/Order.md
|
||||||
docs/Pet.md
|
docs/Pet.md
|
||||||
docs/PetApi.md
|
docs/PetApi.md
|
||||||
|
docs/PropertyTest.md
|
||||||
docs/StoreApi.md
|
docs/StoreApi.md
|
||||||
docs/Tag.md
|
docs/Tag.md
|
||||||
docs/User.md
|
docs/User.md
|
||||||
@ -14,6 +16,7 @@ docs/UserApi.md
|
|||||||
git_push.sh
|
git_push.sh
|
||||||
src/apis/client.rs
|
src/apis/client.rs
|
||||||
src/apis/configuration.rs
|
src/apis/configuration.rs
|
||||||
|
src/apis/fake_api.rs
|
||||||
src/apis/mod.rs
|
src/apis/mod.rs
|
||||||
src/apis/pet_api.rs
|
src/apis/pet_api.rs
|
||||||
src/apis/request.rs
|
src/apis/request.rs
|
||||||
@ -25,5 +28,6 @@ src/models/category.rs
|
|||||||
src/models/mod.rs
|
src/models/mod.rs
|
||||||
src/models/order.rs
|
src/models/order.rs
|
||||||
src/models/pet.rs
|
src/models/pet.rs
|
||||||
|
src/models/property_test.rs
|
||||||
src/models/tag.rs
|
src/models/tag.rs
|
||||||
src/models/user.rs
|
src/models/user.rs
|
||||||
|
@ -25,6 +25,7 @@ All URIs are relative to *http://petstore.swagger.io/v2*
|
|||||||
|
|
||||||
Class | Method | HTTP request | Description
|
Class | Method | HTTP request | Description
|
||||||
------------ | ------------- | ------------- | -------------
|
------------ | ------------- | ------------- | -------------
|
||||||
|
*FakeApi* | [**test_nullable_required_param**](docs/FakeApi.md#test_nullable_required_param) | **Get** /fake/user/{username} | To test nullable required parameters
|
||||||
*PetApi* | [**add_pet**](docs/PetApi.md#add_pet) | **Post** /pet | Add a new pet to the store
|
*PetApi* | [**add_pet**](docs/PetApi.md#add_pet) | **Post** /pet | Add a new pet to the store
|
||||||
*PetApi* | [**delete_pet**](docs/PetApi.md#delete_pet) | **Delete** /pet/{petId} | Deletes a pet
|
*PetApi* | [**delete_pet**](docs/PetApi.md#delete_pet) | **Delete** /pet/{petId} | Deletes a pet
|
||||||
*PetApi* | [**find_pets_by_status**](docs/PetApi.md#find_pets_by_status) | **Get** /pet/findByStatus | Finds Pets by status
|
*PetApi* | [**find_pets_by_status**](docs/PetApi.md#find_pets_by_status) | **Get** /pet/findByStatus | Finds Pets by status
|
||||||
@ -53,6 +54,7 @@ Class | Method | HTTP request | Description
|
|||||||
- [Category](docs/Category.md)
|
- [Category](docs/Category.md)
|
||||||
- [Order](docs/Order.md)
|
- [Order](docs/Order.md)
|
||||||
- [Pet](docs/Pet.md)
|
- [Pet](docs/Pet.md)
|
||||||
|
- [PropertyTest](docs/PropertyTest.md)
|
||||||
- [Tag](docs/Tag.md)
|
- [Tag](docs/Tag.md)
|
||||||
- [User](docs/User.md)
|
- [User](docs/User.md)
|
||||||
|
|
||||||
|
41
samples/client/petstore/rust/hyper/petstore/docs/FakeApi.md
Normal file
41
samples/client/petstore/rust/hyper/petstore/docs/FakeApi.md
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
# \FakeApi
|
||||||
|
|
||||||
|
All URIs are relative to *http://petstore.swagger.io/v2*
|
||||||
|
|
||||||
|
Method | HTTP request | Description
|
||||||
|
------------- | ------------- | -------------
|
||||||
|
[**test_nullable_required_param**](FakeApi.md#test_nullable_required_param) | **Get** /fake/user/{username} | To test nullable required parameters
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## test_nullable_required_param
|
||||||
|
|
||||||
|
> test_nullable_required_param(username, dummy_required_nullable_param, uppercase)
|
||||||
|
To test nullable required parameters
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
|
||||||
|
Name | Type | Description | Required | Notes
|
||||||
|
------------- | ------------- | ------------- | ------------- | -------------
|
||||||
|
**username** | **String** | The name that needs to be fetched. Use user1 for testing. | [required] |
|
||||||
|
**dummy_required_nullable_param** | Option<**String**> | To test nullable required parameters | [required] |
|
||||||
|
**uppercase** | Option<**String**> | To test parameter names in upper case | |
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
(empty response body)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
No authorization required
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: Not defined
|
||||||
|
- **Accept**: Not defined
|
||||||
|
|
||||||
|
[[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)
|
||||||
|
|
@ -0,0 +1,11 @@
|
|||||||
|
# PropertyTest
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
**uuid** | Option<[**uuid::Uuid**](uuid::Uuid.md)> | | [optional]
|
||||||
|
|
||||||
|
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||||
|
|
||||||
|
|
46
samples/client/petstore/rust/hyper/petstore/pom.xml
Normal file
46
samples/client/petstore/rust/hyper/petstore/pom.xml
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
<project>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>org.openapitools</groupId>
|
||||||
|
<artifactId>RustHyperClientTests</artifactId>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<name>Rust Hyper Petstore Client</name>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-dependency-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>copy-dependencies</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<outputDirectory>${project.build.directory}</outputDirectory>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>exec-maven-plugin</artifactId>
|
||||||
|
<version>1.2.1</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>bundle-test</id>
|
||||||
|
<phase>integration-test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>exec</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<executable>cargo</executable>
|
||||||
|
<arguments>
|
||||||
|
<argument>test</argument>
|
||||||
|
</arguments>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
@ -4,6 +4,7 @@ use hyper;
|
|||||||
use super::configuration::Configuration;
|
use super::configuration::Configuration;
|
||||||
|
|
||||||
pub struct APIClient {
|
pub struct APIClient {
|
||||||
|
fake_api: Box<dyn crate::apis::FakeApi>,
|
||||||
pet_api: Box<dyn crate::apis::PetApi>,
|
pet_api: Box<dyn crate::apis::PetApi>,
|
||||||
store_api: Box<dyn crate::apis::StoreApi>,
|
store_api: Box<dyn crate::apis::StoreApi>,
|
||||||
user_api: Box<dyn crate::apis::UserApi>,
|
user_api: Box<dyn crate::apis::UserApi>,
|
||||||
@ -15,12 +16,17 @@ impl APIClient {
|
|||||||
let rc = Rc::new(configuration);
|
let rc = Rc::new(configuration);
|
||||||
|
|
||||||
APIClient {
|
APIClient {
|
||||||
|
fake_api: Box::new(crate::apis::FakeApiClient::new(rc.clone())),
|
||||||
pet_api: Box::new(crate::apis::PetApiClient::new(rc.clone())),
|
pet_api: Box::new(crate::apis::PetApiClient::new(rc.clone())),
|
||||||
store_api: Box::new(crate::apis::StoreApiClient::new(rc.clone())),
|
store_api: Box::new(crate::apis::StoreApiClient::new(rc.clone())),
|
||||||
user_api: Box::new(crate::apis::UserApiClient::new(rc.clone())),
|
user_api: Box::new(crate::apis::UserApiClient::new(rc.clone())),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn fake_api(&self) -> &dyn crate::apis::FakeApi{
|
||||||
|
self.fake_api.as_ref()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn pet_api(&self) -> &dyn crate::apis::PetApi{
|
pub fn pet_api(&self) -> &dyn crate::apis::PetApi{
|
||||||
self.pet_api.as_ref()
|
self.pet_api.as_ref()
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* OpenAPI Petstore
|
||||||
|
*
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* The version of the OpenAPI document: 1.0.0
|
||||||
|
*
|
||||||
|
* Generated by: https://openapi-generator.tech
|
||||||
|
*/
|
||||||
|
|
||||||
|
use std::rc::Rc;
|
||||||
|
use std::borrow::Borrow;
|
||||||
|
use std::pin::Pin;
|
||||||
|
#[allow(unused_imports)]
|
||||||
|
use std::option::Option;
|
||||||
|
|
||||||
|
use hyper;
|
||||||
|
use futures::Future;
|
||||||
|
|
||||||
|
use super::{Error, configuration};
|
||||||
|
use super::request as __internal_request;
|
||||||
|
|
||||||
|
pub struct FakeApiClient<C: hyper::client::connect::Connect>
|
||||||
|
where C: Clone + std::marker::Send + Sync + 'static {
|
||||||
|
configuration: Rc<configuration::Configuration<C>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<C: hyper::client::connect::Connect> FakeApiClient<C>
|
||||||
|
where C: Clone + std::marker::Send + Sync {
|
||||||
|
pub fn new(configuration: Rc<configuration::Configuration<C>>) -> FakeApiClient<C> {
|
||||||
|
FakeApiClient {
|
||||||
|
configuration,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait FakeApi {
|
||||||
|
fn test_nullable_required_param(&self, username: &str, dummy_required_nullable_param: Option<&str>, uppercase: Option<&str>) -> Pin<Box<dyn Future<Output = Result<(), Error>>>>;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<C: hyper::client::connect::Connect>FakeApi for FakeApiClient<C>
|
||||||
|
where C: Clone + std::marker::Send + Sync {
|
||||||
|
#[allow(unused_mut)]
|
||||||
|
fn test_nullable_required_param(&self, username: &str, dummy_required_nullable_param: Option<&str>, uppercase: Option<&str>) -> Pin<Box<dyn Future<Output = Result<(), Error>>>> {
|
||||||
|
let mut req = __internal_request::Request::new(hyper::Method::GET, "/fake/user/{username}".to_string())
|
||||||
|
;
|
||||||
|
req = req.with_path_param("username".to_string(), username.to_string());
|
||||||
|
match dummy_required_nullable_param {
|
||||||
|
Some(param_value) => { req = req.with_header_param("dummy_required_nullable_param".to_string(), param_value.to_string()); },
|
||||||
|
None => { req = req.with_header_param("dummy_required_nullable_param".to_string(), "".to_string()); },
|
||||||
|
}
|
||||||
|
if let Some(param_value) = uppercase {
|
||||||
|
req = req.with_header_param("UPPERCASE".to_string(), param_value.to_string());
|
||||||
|
}
|
||||||
|
req = req.returns_nothing();
|
||||||
|
|
||||||
|
req.execute(self.configuration.borrow())
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -47,6 +47,8 @@ impl From<serde_json::Error> for Error {
|
|||||||
|
|
||||||
mod request;
|
mod request;
|
||||||
|
|
||||||
|
mod fake_api;
|
||||||
|
pub use self::fake_api::{ FakeApi, FakeApiClient };
|
||||||
mod pet_api;
|
mod pet_api;
|
||||||
pub use self::pet_api::{ PetApi, PetApiClient };
|
pub use self::pet_api::{ PetApi, PetApiClient };
|
||||||
mod store_api;
|
mod store_api;
|
||||||
|
@ -6,6 +6,8 @@ pub mod order;
|
|||||||
pub use self::order::Order;
|
pub use self::order::Order;
|
||||||
pub mod pet;
|
pub mod pet;
|
||||||
pub use self::pet::Pet;
|
pub use self::pet::Pet;
|
||||||
|
pub mod property_test;
|
||||||
|
pub use self::property_test::PropertyTest;
|
||||||
pub mod tag;
|
pub mod tag;
|
||||||
pub use self::tag::Tag;
|
pub use self::tag::Tag;
|
||||||
pub mod user;
|
pub mod user;
|
||||||
|
@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* OpenAPI Petstore
|
||||||
|
*
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* The version of the OpenAPI document: 1.0.0
|
||||||
|
*
|
||||||
|
* Generated by: https://openapi-generator.tech
|
||||||
|
*/
|
||||||
|
|
||||||
|
/// PropertyTest : A model to test various formats, e.g. UUID
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
|
||||||
|
pub struct PropertyTest {
|
||||||
|
#[serde(rename = "uuid", skip_serializing_if = "Option::is_none")]
|
||||||
|
pub uuid: Option<uuid::Uuid>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PropertyTest {
|
||||||
|
/// A model to test various formats, e.g. UUID
|
||||||
|
pub fn new() -> PropertyTest {
|
||||||
|
PropertyTest {
|
||||||
|
uuid: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -8,6 +8,7 @@ docs/FakeApi.md
|
|||||||
docs/Order.md
|
docs/Order.md
|
||||||
docs/Pet.md
|
docs/Pet.md
|
||||||
docs/PetApi.md
|
docs/PetApi.md
|
||||||
|
docs/PropertyTest.md
|
||||||
docs/StoreApi.md
|
docs/StoreApi.md
|
||||||
docs/Tag.md
|
docs/Tag.md
|
||||||
docs/User.md
|
docs/User.md
|
||||||
@ -25,5 +26,6 @@ src/models/category.rs
|
|||||||
src/models/mod.rs
|
src/models/mod.rs
|
||||||
src/models/order.rs
|
src/models/order.rs
|
||||||
src/models/pet.rs
|
src/models/pet.rs
|
||||||
|
src/models/property_test.rs
|
||||||
src/models/tag.rs
|
src/models/tag.rs
|
||||||
src/models/user.rs
|
src/models/user.rs
|
||||||
|
@ -54,6 +54,7 @@ Class | Method | HTTP request | Description
|
|||||||
- [Category](docs/Category.md)
|
- [Category](docs/Category.md)
|
||||||
- [Order](docs/Order.md)
|
- [Order](docs/Order.md)
|
||||||
- [Pet](docs/Pet.md)
|
- [Pet](docs/Pet.md)
|
||||||
|
- [PropertyTest](docs/PropertyTest.md)
|
||||||
- [Tag](docs/Tag.md)
|
- [Tag](docs/Tag.md)
|
||||||
- [User](docs/User.md)
|
- [User](docs/User.md)
|
||||||
|
|
||||||
|
@ -0,0 +1,11 @@
|
|||||||
|
# PropertyTest
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
**uuid** | Option<[**uuid::Uuid**](uuid::Uuid.md)> | | [optional]
|
||||||
|
|
||||||
|
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||||
|
|
||||||
|
|
@ -6,6 +6,8 @@ pub mod order;
|
|||||||
pub use self::order::Order;
|
pub use self::order::Order;
|
||||||
pub mod pet;
|
pub mod pet;
|
||||||
pub use self::pet::Pet;
|
pub use self::pet::Pet;
|
||||||
|
pub mod property_test;
|
||||||
|
pub use self::property_test::PropertyTest;
|
||||||
pub mod tag;
|
pub mod tag;
|
||||||
pub use self::tag::Tag;
|
pub use self::tag::Tag;
|
||||||
pub mod user;
|
pub mod user;
|
||||||
|
@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* OpenAPI Petstore
|
||||||
|
*
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* The version of the OpenAPI document: 1.0.0
|
||||||
|
*
|
||||||
|
* Generated by: https://openapi-generator.tech
|
||||||
|
*/
|
||||||
|
|
||||||
|
/// PropertyTest : A model to test various formats, e.g. UUID
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
|
||||||
|
pub struct PropertyTest {
|
||||||
|
#[serde(rename = "uuid", skip_serializing_if = "Option::is_none")]
|
||||||
|
pub uuid: Option<uuid::Uuid>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PropertyTest {
|
||||||
|
/// A model to test various formats, e.g. UUID
|
||||||
|
pub fn new() -> PropertyTest {
|
||||||
|
PropertyTest {
|
||||||
|
uuid: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user