-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
fix(rust): wrong path to model used as parameter of api #17968
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,9 @@ | ||
generatorName: rust | ||
outputDir: samples/client/others/rust/hyper/api-with-ref-param | ||
library: hyper | ||
inputSpec: modules/openapi-generator/src/test/resources/3_0/rust/api-with-ref-param.yaml | ||
templateDir: modules/openapi-generator/src/main/resources/rust | ||
additionalProperties: | ||
supportAsync: true | ||
packageName: api-ref-param-hyper | ||
|
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,9 @@ | ||
generatorName: rust | ||
outputDir: samples/client/others/rust/reqwest/api-with-ref-param | ||
library: reqwest | ||
inputSpec: modules/openapi-generator/src/test/resources/3_0/rust/api-with-ref-param.yaml | ||
templateDir: modules/openapi-generator/src/main/resources/rust | ||
additionalProperties: | ||
supportAsync: true | ||
packageName: api-ref-param-reqwest | ||
|
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
24 changes: 24 additions & 0 deletions
24
modules/openapi-generator/src/test/resources/3_0/rust/api-with-ref-param.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,24 @@ | ||
openapi: 3.0.3 | ||
info: | ||
title: Demo | ||
version: 0.0.0 | ||
paths: | ||
/demo/{color}: | ||
get: | ||
parameters: | ||
- name: color | ||
required: true | ||
in: path | ||
schema: | ||
$ref: "#/components/schemas/Color" | ||
responses: | ||
200: | ||
description: OK | ||
components: | ||
schemas: | ||
Color: | ||
type: string | ||
enum: | ||
- RED | ||
- GREEN | ||
- BLUE |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
samples/client/others/rust/hyper/api-with-ref-param/.gitignore
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/hyper/api-with-ref-param/.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 |
15 changes: 15 additions & 0 deletions
15
samples/client/others/rust/hyper/api-with-ref-param/.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,15 @@ | ||
.gitignore | ||
.travis.yml | ||
Cargo.toml | ||
README.md | ||
docs/Color.md | ||
docs/DefaultApi.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/color.rs | ||
src/models/mod.rs |
1 change: 1 addition & 0 deletions
1
samples/client/others/rust/hyper/api-with-ref-param/.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 |
1 change: 1 addition & 0 deletions
1
samples/client/others/rust/hyper/api-with-ref-param/.travis.yml
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 |
20 changes: 20 additions & 0 deletions
20
samples/client/others/rust/hyper/api-with-ref-param/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,20 @@ | ||
[package] | ||
name = "api-ref-param-hyper" | ||
version = "0.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 = "2018" | ||
|
||
[dependencies] | ||
serde = "^1.0" | ||
serde_derive = "^1.0" | ||
serde_json = "^1.0" | ||
url = "^2.2" | ||
uuid = { version = "^1.0", features = ["serde", "v4"] } | ||
hyper = { version = "~0.14", features = ["full"] } | ||
hyper-tls = "~0.5" | ||
http = "~0.2" | ||
base64 = "~0.7.0" | ||
futures = "^0.3" |
45 changes: 45 additions & 0 deletions
45
samples/client/others/rust/hyper/api-with-ref-param/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,45 @@ | ||
# Rust API client for api-ref-param-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: 0.0.0 | ||
- Package version: 0.0.0 | ||
- Build package: `org.openapitools.codegen.languages.RustClientCodegen` | ||
|
||
## Installation | ||
|
||
Put the package under your project folder in a directory named `api-ref-param-hyper` and add the following to `Cargo.toml` under `[dependencies]`: | ||
|
||
``` | ||
api-ref-param-hyper = { path = "./api-ref-param-hyper" } | ||
``` | ||
|
||
## Documentation for API Endpoints | ||
|
||
All URIs are relative to *http://localhost* | ||
|
||
Class | Method | HTTP request | Description | ||
------------ | ------------- | ------------- | ------------- | ||
*DefaultApi* | [**demo_color_get**](docs/DefaultApi.md#demo_color_get) | **Get** /demo/{color} | | ||
|
||
|
||
## Documentation For Models | ||
|
||
- [Color](docs/Color.md) | ||
|
||
|
||
To get access to the crate's generated documentation, use: | ||
|
||
``` | ||
cargo doc --open | ||
``` | ||
|
||
## Author | ||
|
||
|
||
|
14 changes: 14 additions & 0 deletions
14
samples/client/others/rust/hyper/api-with-ref-param/docs/Color.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,14 @@ | ||
# Color | ||
|
||
## Enum Variants | ||
|
||
| Name | Value | | ||
|---- | -----| | ||
| Red | RED | | ||
| Green | GREEN | | ||
| Blue | BLUE | | ||
|
||
|
||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) | ||
|
||
|
37 changes: 37 additions & 0 deletions
37
samples/client/others/rust/hyper/api-with-ref-param/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,37 @@ | ||
# \DefaultApi | ||
|
||
All URIs are relative to *http://localhost* | ||
|
||
Method | HTTP request | Description | ||
------------- | ------------- | ------------- | ||
[**demo_color_get**](DefaultApi.md#demo_color_get) | **Get** /demo/{color} | | ||
|
||
|
||
|
||
## demo_color_get | ||
|
||
> demo_color_get(color) | ||
|
||
|
||
### Parameters | ||
|
||
|
||
Name | Type | Description | Required | Notes | ||
------------- | ------------- | ------------- | ------------- | ------------- | ||
**color** | [**Color**](.md) | | [required] | | ||
|
||
### 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) | ||
|
57 changes: 57 additions & 0 deletions
57
samples/client/others/rust/hyper/api-with-ref-param/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' |
24 changes: 24 additions & 0 deletions
24
samples/client/others/rust/hyper/api-with-ref-param/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,24 @@ | ||
use std::rc::Rc; | ||
|
||
use hyper; | ||
use super::configuration::Configuration; | ||
|
||
pub struct APIClient { | ||
default_api: Box<dyn crate::apis::DefaultApi>, | ||
} | ||
|
||
impl APIClient { | ||
pub fn new<C: hyper::client::connect::Connect>(configuration: Configuration<C>) -> APIClient | ||
where C: Clone + std::marker::Send + Sync + 'static { | ||
let rc = Rc::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() | ||
} | ||
|
||
} |
43 changes: 43 additions & 0 deletions
43
samples/client/others/rust/hyper/api-with-ref-param/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,43 @@ | ||
/* | ||
* Demo | ||
* | ||
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) | ||
* | ||
* The version of the OpenAPI document: 0.0.0 | ||
* | ||
* Generated by: https://openapi-generator.tech | ||
*/ | ||
|
||
use hyper; | ||
|
||
pub struct Configuration<C: hyper::client::connect::Connect> | ||
where C: Clone + std::marker::Send + Sync + 'static { | ||
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::Connect> Configuration<C> | ||
where C: Clone + std::marker::Send + Sync { | ||
pub fn new(client: hyper::client::Client<C>) -> Configuration<C> { | ||
Configuration { | ||
base_path: "http://localhost".to_owned(), | ||
user_agent: Some("OpenAPI-Generator/0.0.0/rust".to_owned()), | ||
client, | ||
basic_auth: None, | ||
oauth_access_token: None, | ||
api_key: None, | ||
} | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, we can see that
hyper
implementation doesn't use this condition and seems to work correctly.But I covered both clients with tests