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.
fix(rust): untagged enum of type-aliases without discriminator
Partially solves OpenAPITools#17869 There is a downside - variants names doesn't reflect model name of reference It also doesn't solve issue of import, will be solved separately
- Loading branch information
Showing
19 changed files
with
418 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
generatorName: rust | ||
outputDir: samples/client/others/rust/reqwest/oneOf-aliases | ||
library: reqwest | ||
inputSpec: modules/openapi-generator/src/test/resources/3_0/rust/issue_17869_oneOf_aliases.yaml | ||
templateDir: modules/openapi-generator/src/main/resources/rust | ||
additionalProperties: | ||
supportAsync: false | ||
packageName: oneof-reqwest-oneOf-aliases |
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
42 changes: 42 additions & 0 deletions
42
modules/openapi-generator/src/test/resources/3_0/rust/issue_17869_oneOf_aliases.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,42 @@ | ||
{ | ||
"openapi": "3.0.3", | ||
"info": { | ||
"title": "Omitted", | ||
"description": "Omitted", | ||
"license": { | ||
"name": "" | ||
}, | ||
"version": "0.1.0" | ||
}, | ||
"servers": [ | ||
{ | ||
"url": "http://localhost:8080", | ||
"description": "Omitted" | ||
} | ||
], | ||
"paths": {}, | ||
"components": { | ||
"schemas": { | ||
"AccountName": { | ||
"type": "string", | ||
"description": "An account name." | ||
}, | ||
"AccountOrEmail": { | ||
"oneOf": [ | ||
{ | ||
"$ref": "#/components/schemas/Email" | ||
}, | ||
{ | ||
"$ref": "#/components/schemas/AccountName" | ||
} | ||
], | ||
"description": "Either an account name or an email." | ||
}, | ||
"Email": { | ||
"type": "string", | ||
"description": "An email address." | ||
} | ||
}, | ||
"responses": {} | ||
} | ||
} |
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 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,3 @@ | ||
/target/ | ||
**/*.rs.bk | ||
Cargo.lock |
23 changes: 23 additions & 0 deletions
23
samples/client/others/rust/reqwest/oneOf-aliases/.openapi-generator-ignore
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 @@ | ||
# 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 |
11 changes: 11 additions & 0 deletions
11
samples/client/others/rust/reqwest/oneOf-aliases/.openapi-generator/FILES
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,11 @@ | ||
.gitignore | ||
.travis.yml | ||
Cargo.toml | ||
README.md | ||
docs/AccountOrEmail.md | ||
git_push.sh | ||
src/apis/configuration.rs | ||
src/apis/mod.rs | ||
src/lib.rs | ||
src/models/account_or_email.rs | ||
src/models/mod.rs |
1 change: 1 addition & 0 deletions
1
samples/client/others/rust/reqwest/oneOf-aliases/.openapi-generator/VERSION
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 @@ | ||
7.4.0-SNAPSHOT |
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 @@ | ||
language: rust |
17 changes: 17 additions & 0 deletions
17
samples/client/others/rust/reqwest/oneOf-aliases/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 = "oneof-reqwest-oneOf-aliases" | ||
version = "0.1.0" | ||
authors = ["OpenAPI Generator team and contributors"] | ||
description = "Omitted" | ||
license = "" | ||
edition = "2018" | ||
|
||
[dependencies] | ||
serde = "^1.0" | ||
serde_derive = "^1.0" | ||
serde_json = "^1.0" | ||
url = "^2.2" | ||
uuid = { version = "^1.0", features = ["serde", "v4"] } | ||
[dependencies.reqwest] | ||
version = "^0.11" | ||
features = ["json", "blocking", "multipart"] |
43 changes: 43 additions & 0 deletions
43
samples/client/others/rust/reqwest/oneOf-aliases/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 oneof-reqwest-oneOf-aliases | ||
|
||
Omitted | ||
|
||
|
||
## 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: 0.1.0 | ||
- Package version: 0.1.0 | ||
- Build package: `org.openapitools.codegen.languages.RustClientCodegen` | ||
|
||
## Installation | ||
|
||
Put the package under your project folder in a directory named `oneof-reqwest-oneOf-aliases` and add the following to `Cargo.toml` under `[dependencies]`: | ||
|
||
``` | ||
oneof-reqwest-oneOf-aliases = { path = "./oneof-reqwest-oneOf-aliases" } | ||
``` | ||
|
||
## Documentation for API Endpoints | ||
|
||
All URIs are relative to *http://localhost:8080* | ||
|
||
Class | Method | HTTP request | Description | ||
------------ | ------------- | ------------- | ------------- | ||
|
||
|
||
## Documentation For Models | ||
|
||
- [AccountOrEmail](docs/AccountOrEmail.md) | ||
|
||
|
||
To get access to the crate's generated documentation, use: | ||
|
||
``` | ||
cargo doc --open | ||
``` | ||
|
||
## Author | ||
|
||
|
11 changes: 11 additions & 0 deletions
11
samples/client/others/rust/reqwest/oneOf-aliases/docs/AccountOrEmail.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,11 @@ | ||
# AccountOrEmail | ||
|
||
## Enum Variants | ||
|
||
| Name | Description | | ||
|---- | -----| | ||
| String | Either an account name or an email. | | ||
|
||
[[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
57
samples/client/others/rust/reqwest/oneOf-aliases/git_push.sh
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,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' |
53 changes: 53 additions & 0 deletions
53
samples/client/others/rust/reqwest/oneOf-aliases/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,53 @@ | ||
/* | ||
* Omitted | ||
* | ||
* Omitted | ||
* | ||
* The version of the OpenAPI document: 0.1.0 | ||
* | ||
* Generated by: https://openapi-generator.tech | ||
*/ | ||
|
||
|
||
|
||
#[derive(Debug, Clone)] | ||
pub struct Configuration { | ||
pub base_path: String, | ||
pub user_agent: Option<String>, | ||
pub client: reqwest::blocking::Client, | ||
pub basic_auth: Option<BasicAuth>, | ||
pub oauth_access_token: Option<String>, | ||
pub bearer_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>); | ||
|
||
#[derive(Debug, Clone)] | ||
pub struct ApiKey { | ||
pub prefix: Option<String>, | ||
pub key: String, | ||
} | ||
|
||
|
||
impl Configuration { | ||
pub fn new() -> Configuration { | ||
Configuration::default() | ||
} | ||
} | ||
|
||
impl Default for Configuration { | ||
fn default() -> Self { | ||
Configuration { | ||
base_path: "http://localhost:8080".to_owned(), | ||
user_agent: Some("OpenAPI-Generator/0.1.0/rust".to_owned()), | ||
client: reqwest::blocking::Client::new(), | ||
basic_auth: None, | ||
oauth_access_token: None, | ||
bearer_access_token: None, | ||
api_key: None, | ||
|
||
} | ||
} | ||
} |
Oops, something went wrong.