Skip to content
Draft
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
8 changes: 8 additions & 0 deletions bin/configs/rust-hyper-anyof.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
generatorName: rust
outputDir: samples/client/others/rust/hyper/anyof
library: hyper
inputSpec: modules/openapi-generator/src/test/resources/3_0/rust/rust-anyof-test.yaml
templateDir: modules/openapi-generator/src/main/resources/rust
additionalProperties:
supportAsync: false
packageName: anyof-hyper
3 changes: 3 additions & 0 deletions samples/client/others/rust/hyper/anyof/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/target/
**/*.rs.bk
Cargo.lock
23 changes: 23 additions & 0 deletions samples/client/others/rust/hyper/anyof/.openapi-generator-ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# OpenAPI Generator Ignore
# Generated by openapi-generator https://github.com/openapitools/openapi-generator

# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.

# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
#ApiClient.cs

# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux

# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux

# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md
19 changes: 19 additions & 0 deletions samples/client/others/rust/hyper/anyof/.openapi-generator/FILES
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.gitignore
.travis.yml
Cargo.toml
README.md
docs/AnotherAnyOfTest.md
docs/DefaultApi.md
docs/ModelIdentifier.md
docs/TestResponse.md
git_push.sh
src/apis/client.rs
src/apis/configuration.rs
src/apis/default_api.rs
src/apis/mod.rs
src/apis/request.rs
src/lib.rs
src/models/another_any_of_test.rs
src/models/mod.rs
src/models/model_identifier.rs
src/models/test_response.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7.16.0-SNAPSHOT
1 change: 1 addition & 0 deletions samples/client/others/rust/hyper/anyof/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
language: rust
20 changes: 20 additions & 0 deletions samples/client/others/rust/hyper/anyof/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[package]
name = "anyof-hyper"
version = "1.0.0"
authors = ["OpenAPI Generator team and contributors"]
description = "No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)"
# Override this license by providing a License Object in the OpenAPI.
license = "Unlicense"
edition = "2021"

[dependencies]
serde = { version = "^1.0", features = ["derive"] }
serde_json = "^1.0"
serde_repr = "^0.1"
url = "^2.5"
hyper = { version = "^1.3.1", features = ["full"] }
hyper-util = { version = "0.1.5", features = ["client", "client-legacy", "http1", "http2"] }
http-body-util = { version = "0.1.2" }
http = "~0.2"
base64 = "~0.7.0"
futures = "^0.3"
48 changes: 48 additions & 0 deletions samples/client/others/rust/hyper/anyof/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Rust API client for anyof-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
- Generator version: 7.16.0-SNAPSHOT
- Build package: `org.openapitools.codegen.languages.RustClientCodegen`

## Installation

Put the package under your project folder in a directory named `anyof-hyper` and add the following to `Cargo.toml` under `[dependencies]`:

```
anyof-hyper = { path = "./anyof-hyper" }
```

## Documentation for API Endpoints

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

Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*DefaultApi* | [**model_get**](docs/DefaultApi.md#model_get) | **Get** /model |


## Documentation For Models

- [AnotherAnyOfTest](docs/AnotherAnyOfTest.md)
- [ModelIdentifier](docs/ModelIdentifier.md)
- [TestResponse](docs/TestResponse.md)


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

```
cargo doc --open
```

## Author



10 changes: 10 additions & 0 deletions samples/client/others/rust/hyper/anyof/docs/AnotherAnyOfTest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# AnotherAnyOfTest

## Properties

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------

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


34 changes: 34 additions & 0 deletions samples/client/others/rust/hyper/anyof/docs/DefaultApi.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# \DefaultApi

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

Method | HTTP request | Description
------------- | ------------- | -------------
[**model_get**](DefaultApi.md#model_get) | **Get** /model |



## model_get

> models::TestResponse model_get()


### Parameters

This endpoint does not need any parameter.

### Return type

[**models::TestResponse**](TestResponse.md)

### Authorization

No authorization required

### HTTP request headers

- **Content-Type**: Not defined
- **Accept**: application/json

[[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)

10 changes: 10 additions & 0 deletions samples/client/others/rust/hyper/anyof/docs/ModelIdentifier.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# ModelIdentifier

## Properties

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------

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


12 changes: 12 additions & 0 deletions samples/client/others/rust/hyper/anyof/docs/TestResponse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# TestResponse

## Properties

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**model** | Option<[**models::ModelIdentifier**](ModelIdentifier.md)> | | [optional]
**status** | Option<**String**> | | [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)


57 changes: 57 additions & 0 deletions samples/client/others/rust/hyper/anyof/git_push.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/sh
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
#
# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com"

git_user_id=$1
git_repo_id=$2
release_note=$3
git_host=$4

if [ "$git_host" = "" ]; then
git_host="github.com"
echo "[INFO] No command line input provided. Set \$git_host to $git_host"
fi

if [ "$git_user_id" = "" ]; then
git_user_id="GIT_USER_ID"
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
fi

if [ "$git_repo_id" = "" ]; then
git_repo_id="GIT_REPO_ID"
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
fi

if [ "$release_note" = "" ]; then
release_note="Minor update"
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
fi

# Initialize the local directory as a Git repository
git init

# Adds the files in the local repository and stages them for commit.
git add .

# Commits the tracked changes and prepares them to be pushed to a remote repository.
git commit -m "$release_note"

# Sets the new remote
git_remote=$(git remote)
if [ "$git_remote" = "" ]; then # git remote not defined

if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
else
git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
fi

fi

git pull origin master

# Pushes (Forces) the changes in the local repository up to the remote repository
echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
git push origin master 2>&1 | grep -v 'To https'
25 changes: 25 additions & 0 deletions samples/client/others/rust/hyper/anyof/src/apis/client.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
use std::sync::Arc;

use hyper;
use hyper_util::client::legacy::connect::Connect;
use super::configuration::Configuration;

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

impl APIClient {
pub fn new<C: Connect>(configuration: Configuration<C>) -> APIClient
where C: Clone + std::marker::Send + Sync + 'static {
let rc = Arc::new(configuration);

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

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

}
92 changes: 92 additions & 0 deletions samples/client/others/rust/hyper/anyof/src/apis/configuration.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/*
* Rust anyOf 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;
use hyper_util::client::legacy::Client;
use hyper_util::client::legacy::connect::Connect;
use hyper_util::client::legacy::connect::HttpConnector;
use hyper_util::rt::TokioExecutor;

pub struct Configuration<C: Connect = HttpConnector>
where C: Clone + std::marker::Send + Sync + 'static {
pub base_path: String,
pub user_agent: Option<String>,
pub client: Client<C, String>,
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 Configuration<HttpConnector> {
/// Construct a default [`Configuration`](Self) with a hyper client using a default
/// [`HttpConnector`](hyper_util::client::legacy::connect::HttpConnector).
///
/// Use [`with_client`](Configuration<T>::with_client) to construct a Configuration with a
/// custom hyper client.
///
/// # Example
///
/// ```
/// # use anyof_hyper::apis::configuration::Configuration;
/// let api_config = Configuration {
/// basic_auth: Some(("user".into(), None)),
/// ..Configuration::new()
/// };
/// ```
pub fn new() -> Configuration<HttpConnector> {
Configuration::default()
}
}

impl<C: Connect> Configuration<C>
where C: Clone + std::marker::Send + Sync {

/// Construct a new Configuration with a custom hyper client.
///
/// # Example
///
/// ```
/// # use core::time::Duration;
/// # use anyof_hyper::apis::configuration::Configuration;
/// use hyper_util::client::legacy::Client;
/// use hyper_util::rt::TokioExecutor;
///
/// let client = Client::builder(TokioExecutor::new())
/// .pool_idle_timeout(Duration::from_secs(30))
/// .build_http();
///
/// let api_config = Configuration::with_client(client);
/// ```
pub fn with_client(client: Client<C, String>) -> Configuration<C> {
Configuration {
base_path: "http://localhost".to_owned(),
user_agent: Some("OpenAPI-Generator/1.0.0/rust".to_owned()),
client,
basic_auth: None,
oauth_access_token: None,
api_key: None,
}
}
}

impl Default for Configuration<HttpConnector> {
fn default() -> Self {
let client = Client::builder(TokioExecutor::new()).build_http();
Configuration::with_client(client)
}
}
Loading
Loading