forked from loafle/openapi-generator-original
[Rust] Support for withAWSV4Signature option (#11690)
* [rust] add support for withAWSV4Signature option in reqwest (#11193) Signed-off-by: Jérôme Jutteau <jerome.jutteau@outscale.com> * [rust] add petstore sample for withAWSV4Signature option for reqwest (#11193) Signed-off-by: Jérôme Jutteau <jerome.jutteau@outscale.com> * [rust] update all samples (#11193) Signed-off-by: Jérôme Jutteau <jerome.jutteau@outscale.com>
This commit is contained in:
parent
1b6ab63953
commit
21f649e087
9
bin/configs/rust-reqwest-petstore-awsv4signature.yaml
Normal file
9
bin/configs/rust-reqwest-petstore-awsv4signature.yaml
Normal file
@ -0,0 +1,9 @@
|
||||
generatorName: rust
|
||||
outputDir: samples/client/petstore/rust/reqwest/petstore-awsv4signature
|
||||
library: reqwest
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/rust
|
||||
additionalProperties:
|
||||
supportAsync: false
|
||||
packageName: petstore-reqwest-awsv4signature
|
||||
withAWSV4Signature: true
|
@ -26,6 +26,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|supportAsync|If set, generate async function call instead. This option is for 'reqwest' library only| |true|
|
||||
|supportMultipleResponses|If set, return type wraps an enum of all possible 2xx schemas. This option is for 'reqwest' library only| |false|
|
||||
|useSingleRequestParameter|Setting this property to true will generate functions with a single argument containing all API endpoint parameters instead of one argument per parameter.| |false|
|
||||
|withAWSV4Signature|whether to include AWS v4 signature support| |false|
|
||||
|
||||
## IMPORT MAPPING
|
||||
|
||||
|
@ -40,6 +40,7 @@ public class RustClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
private boolean useSingleRequestParameter = false;
|
||||
private boolean supportAsync = true;
|
||||
private boolean supportMultipleResponses = false;
|
||||
private boolean withAWSV4Signature = false;
|
||||
|
||||
public static final String PACKAGE_NAME = "packageName";
|
||||
public static final String PACKAGE_VERSION = "packageVersion";
|
||||
@ -181,6 +182,8 @@ public class RustClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
cliOptions.add(new CliOption(SUPPORT_MULTIPLE_RESPONSES, "If set, return type wraps an enum of all possible 2xx schemas. This option is for 'reqwest' library only", SchemaTypeUtil.BOOLEAN_TYPE)
|
||||
.defaultValue(Boolean.FALSE.toString()));
|
||||
cliOptions.add(new CliOption(CodegenConstants.ENUM_NAME_SUFFIX, CodegenConstants.ENUM_NAME_SUFFIX_DESC).defaultValue(this.enumSuffix));
|
||||
cliOptions.add(new CliOption(CodegenConstants.WITH_AWSV4_SIGNATURE_COMMENT, CodegenConstants.WITH_AWSV4_SIGNATURE_COMMENT_DESC, SchemaTypeUtil.BOOLEAN_TYPE)
|
||||
.defaultValue(Boolean.FALSE.toString()));
|
||||
|
||||
supportedLibraries.put(HYPER_LIBRARY, "HTTP client: Hyper.");
|
||||
supportedLibraries.put(REQWEST_LIBRARY, "HTTP client: Reqwest.");
|
||||
@ -249,6 +252,10 @@ public class RustClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.WITH_AWSV4_SIGNATURE_COMMENT)) {
|
||||
withAWSV4Signature = Boolean.parseBoolean(additionalProperties.get(CodegenConstants.WITH_AWSV4_SIGNATURE_COMMENT).toString());
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.ENUM_NAME_SUFFIX)) {
|
||||
enumSuffix = additionalProperties.get(CodegenConstants.ENUM_NAME_SUFFIX).toString();
|
||||
}
|
||||
|
@ -27,6 +27,11 @@ version = "^0.11"
|
||||
features = ["json", "multipart"]
|
||||
{{/supportAsync}}
|
||||
{{/reqwest}}
|
||||
{{#withAWSV4Signature}}
|
||||
aws-sigv4 = "0.3.0"
|
||||
http = "0.2.5"
|
||||
secrecy = "0.8.0"
|
||||
{{/withAWSV4Signature}}
|
||||
|
||||
[dev-dependencies]
|
||||
{{#hyper}}
|
||||
|
@ -141,6 +141,30 @@ pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}(configuration:
|
||||
{{/isApiKey}}
|
||||
{{/authMethods}}
|
||||
{{/hasAuthMethods}}
|
||||
{{#hasAuthMethods}}
|
||||
{{#withAWSV4Signature}}
|
||||
if let Some(ref local_var_aws_v4_key) = local_var_configuration.aws_v4_key {
|
||||
let local_var_new_headers = match local_var_aws_v4_key.sign(
|
||||
&local_var_uri_str,
|
||||
"{{{httpMethod}}}",
|
||||
{{#hasBodyParam}}
|
||||
{{#bodyParams}}
|
||||
&serde_json::to_string(&{{{paramName}}}).expect("param should serialize to string"),
|
||||
{{/bodyParams}}
|
||||
{{/hasBodyParam}}
|
||||
{{^hasBodyParam}}
|
||||
&"",
|
||||
{{/hasBodyParam}}
|
||||
) {
|
||||
Ok(new_headers) => new_headers,
|
||||
Err(err) => return Err(Error::AWSV4SignatureError(err)),
|
||||
};
|
||||
for (local_var_name, local_var_value) in local_var_new_headers.iter() {
|
||||
local_var_req_builder = local_var_req_builder.header(local_var_name.as_str(), local_var_value.as_str());
|
||||
}
|
||||
}
|
||||
{{/withAWSV4Signature}}
|
||||
{{/hasAuthMethods}}
|
||||
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
|
||||
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
|
||||
}
|
||||
|
@ -1,5 +1,8 @@
|
||||
use std::error;
|
||||
use std::fmt;
|
||||
{{#withAWSV4Signature}}
|
||||
use aws_sigv4;
|
||||
{{/withAWSV4Signature}}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ResponseContent<T> {
|
||||
@ -14,6 +17,9 @@ pub enum Error<T> {
|
||||
Serde(serde_json::Error),
|
||||
Io(std::io::Error),
|
||||
ResponseError(ResponseContent<T>),
|
||||
{{#withAWSV4Signature}}
|
||||
AWSV4SignatureError(aws_sigv4::http_request::Error),
|
||||
{{/withAWSV4Signature}}
|
||||
}
|
||||
|
||||
impl <T> fmt::Display for Error<T> {
|
||||
@ -23,6 +29,9 @@ impl <T> fmt::Display for Error<T> {
|
||||
Error::Serde(e) => ("serde", e.to_string()),
|
||||
Error::Io(e) => ("IO", e.to_string()),
|
||||
Error::ResponseError(e) => ("response", format!("status code {}", e.status)),
|
||||
{{#withAWSV4Signature}}
|
||||
Error::AWSV4SignatureError(e) => ("aws v4 signature", e.to_string()),
|
||||
{{/withAWSV4Signature}}
|
||||
};
|
||||
write!(f, "error in {}: {}", module, e)
|
||||
}
|
||||
@ -35,6 +44,9 @@ impl <T: fmt::Debug> error::Error for Error<T> {
|
||||
Error::Serde(e) => e,
|
||||
Error::Io(e) => e,
|
||||
Error::ResponseError(_) => return None,
|
||||
{{#withAWSV4Signature}}
|
||||
Error::AWSV4SignatureError(_) => return None,
|
||||
{{/withAWSV4Signature}}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,13 @@
|
||||
|
||||
use reqwest;
|
||||
|
||||
{{#withAWSV4Signature}}
|
||||
use std::time::SystemTime;
|
||||
use aws_sigv4::http_request::{sign, SigningSettings, SigningParams, SignableRequest};
|
||||
use http;
|
||||
use secrecy::{SecretString, ExposeSecret};
|
||||
{{/withAWSV4Signature}}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Configuration {
|
||||
pub base_path: String,
|
||||
@ -11,6 +18,9 @@ pub struct Configuration {
|
||||
pub oauth_access_token: Option<String>,
|
||||
pub bearer_access_token: Option<String>,
|
||||
pub api_key: Option<ApiKey>,
|
||||
{{#withAWSV4Signature}}
|
||||
pub aws_v4_key: Option<AWSv4Key>,
|
||||
{{/withAWSV4Signature}}
|
||||
// TODO: take an oauth2 token source, similar to the go one
|
||||
}
|
||||
|
||||
@ -22,6 +32,45 @@ pub struct ApiKey {
|
||||
pub key: String,
|
||||
}
|
||||
|
||||
{{#withAWSV4Signature}}
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct AWSv4Key {
|
||||
pub access_key: String,
|
||||
pub secret_key: SecretString,
|
||||
pub region: String,
|
||||
pub service: String,
|
||||
}
|
||||
|
||||
impl AWSv4Key {
|
||||
pub fn sign(&self, uri: &str, method: &str, body: &str) -> Result<Vec::<(String, String)>, aws_sigv4::http_request::Error> {
|
||||
let request = http::Request::builder()
|
||||
.uri(uri)
|
||||
.method(method)
|
||||
.body(body).unwrap();
|
||||
let signing_settings = SigningSettings::default();
|
||||
let signing_params = SigningParams::builder()
|
||||
.access_key(self.access_key.as_str())
|
||||
.secret_key(self.secret_key.expose_secret().as_str())
|
||||
.region(self.region.as_str())
|
||||
.service_name(self.service.as_str())
|
||||
.time(SystemTime::now())
|
||||
.settings(signing_settings)
|
||||
.build()
|
||||
.unwrap();
|
||||
let signable_request = SignableRequest::from(&request);
|
||||
let (mut signing_instructions, _signature) = sign(signable_request, &signing_params)?.into_parts();
|
||||
let mut additional_headers = Vec::<(String, String)>::new();
|
||||
if let Some(new_headers) = signing_instructions.take_headers() {
|
||||
for (name, value) in new_headers.into_iter() {
|
||||
additional_headers.push((name.expect("header should have name").to_string(),
|
||||
value.to_str().expect("header value should be a string").to_string()));
|
||||
}
|
||||
}
|
||||
return Ok(additional_headers);
|
||||
}
|
||||
}
|
||||
{{/withAWSV4Signature}}
|
||||
|
||||
impl Configuration {
|
||||
pub fn new() -> Configuration {
|
||||
Configuration::default()
|
||||
@ -38,6 +87,7 @@ impl Default for Configuration {
|
||||
oauth_access_token: None,
|
||||
bearer_access_token: None,
|
||||
api_key: None,
|
||||
{{#withAWSV4Signature}} aws_v4_key: None,{{/withAWSV4Signature}}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
use reqwest;
|
||||
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Configuration {
|
||||
pub base_path: String,
|
||||
@ -31,6 +32,7 @@ pub struct ApiKey {
|
||||
pub key: String,
|
||||
}
|
||||
|
||||
|
||||
impl Configuration {
|
||||
pub fn new() -> Configuration {
|
||||
Configuration::default()
|
||||
@ -47,6 +49,7 @@ impl Default for Configuration {
|
||||
oauth_access_token: None,
|
||||
bearer_access_token: None,
|
||||
api_key: None,
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
3
samples/client/petstore/rust/reqwest/petstore-awsv4signature/.gitignore
vendored
Normal file
3
samples/client/petstore/rust/reqwest/petstore-awsv4signature/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
/target/
|
||||
**/*.rs.bk
|
||||
Cargo.lock
|
@ -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
|
@ -0,0 +1,27 @@
|
||||
.gitignore
|
||||
.travis.yml
|
||||
Cargo.toml
|
||||
README.md
|
||||
docs/ApiResponse.md
|
||||
docs/Category.md
|
||||
docs/Order.md
|
||||
docs/Pet.md
|
||||
docs/PetApi.md
|
||||
docs/StoreApi.md
|
||||
docs/Tag.md
|
||||
docs/User.md
|
||||
docs/UserApi.md
|
||||
git_push.sh
|
||||
src/apis/configuration.rs
|
||||
src/apis/mod.rs
|
||||
src/apis/pet_api.rs
|
||||
src/apis/store_api.rs
|
||||
src/apis/user_api.rs
|
||||
src/lib.rs
|
||||
src/models/api_response.rs
|
||||
src/models/category.rs
|
||||
src/models/mod.rs
|
||||
src/models/order.rs
|
||||
src/models/pet.rs
|
||||
src/models/tag.rs
|
||||
src/models/user.rs
|
@ -0,0 +1 @@
|
||||
6.0.0-SNAPSHOT
|
@ -0,0 +1 @@
|
||||
language: rust
|
@ -0,0 +1,17 @@
|
||||
[package]
|
||||
name = "petstore-reqwest-awsv4signature"
|
||||
version = "1.0.0"
|
||||
authors = ["OpenAPI Generator team and contributors"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
serde = "^1.0"
|
||||
serde_derive = "^1.0"
|
||||
serde_json = "^1.0"
|
||||
url = "^2.2"
|
||||
reqwest = "~0.9"
|
||||
aws-sigv4 = "0.3.0"
|
||||
http = "0.2.5"
|
||||
secrecy = "0.8.0"
|
||||
|
||||
[dev-dependencies]
|
@ -0,0 +1,69 @@
|
||||
# Rust API client for petstore-reqwest-awsv4signature
|
||||
|
||||
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
|
||||
|
||||
## 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 in a directory named `petstore-reqwest-awsv4signature` and add the following to `Cargo.toml` under `[dependencies]`:
|
||||
|
||||
```
|
||||
petstore-reqwest-awsv4signature = { path = "./petstore-reqwest-awsv4signature" }
|
||||
```
|
||||
|
||||
## Documentation for API Endpoints
|
||||
|
||||
All URIs are relative to *http://petstore.swagger.io/v2*
|
||||
|
||||
Class | Method | HTTP request | Description
|
||||
------------ | ------------- | ------------- | -------------
|
||||
*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* | [**find_pets_by_status**](docs/PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status
|
||||
*PetApi* | [**find_pets_by_tags**](docs/PetApi.md#find_pets_by_tags) | **GET** /pet/findByTags | Finds Pets by tags
|
||||
*PetApi* | [**get_pet_by_id**](docs/PetApi.md#get_pet_by_id) | **GET** /pet/{petId} | Find pet by ID
|
||||
*PetApi* | [**update_pet**](docs/PetApi.md#update_pet) | **PUT** /pet | Update an existing pet
|
||||
*PetApi* | [**update_pet_with_form**](docs/PetApi.md#update_pet_with_form) | **POST** /pet/{petId} | Updates a pet in the store with form data
|
||||
*PetApi* | [**upload_file**](docs/PetApi.md#upload_file) | **POST** /pet/{petId}/uploadImage | uploads an image
|
||||
*StoreApi* | [**delete_order**](docs/StoreApi.md#delete_order) | **DELETE** /store/order/{orderId} | Delete purchase order by ID
|
||||
*StoreApi* | [**get_inventory**](docs/StoreApi.md#get_inventory) | **GET** /store/inventory | Returns pet inventories by status
|
||||
*StoreApi* | [**get_order_by_id**](docs/StoreApi.md#get_order_by_id) | **GET** /store/order/{orderId} | Find purchase order by ID
|
||||
*StoreApi* | [**place_order**](docs/StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet
|
||||
*UserApi* | [**create_user**](docs/UserApi.md#create_user) | **POST** /user | Create user
|
||||
*UserApi* | [**create_users_with_array_input**](docs/UserApi.md#create_users_with_array_input) | **POST** /user/createWithArray | Creates list of users with given input array
|
||||
*UserApi* | [**create_users_with_list_input**](docs/UserApi.md#create_users_with_list_input) | **POST** /user/createWithList | Creates list of users with given input array
|
||||
*UserApi* | [**delete_user**](docs/UserApi.md#delete_user) | **DELETE** /user/{username} | Delete user
|
||||
*UserApi* | [**get_user_by_name**](docs/UserApi.md#get_user_by_name) | **GET** /user/{username} | Get user by user name
|
||||
*UserApi* | [**login_user**](docs/UserApi.md#login_user) | **GET** /user/login | Logs user into the system
|
||||
*UserApi* | [**logout_user**](docs/UserApi.md#logout_user) | **GET** /user/logout | Logs out current logged in user session
|
||||
*UserApi* | [**update_user**](docs/UserApi.md#update_user) | **PUT** /user/{username} | Updated user
|
||||
|
||||
|
||||
## Documentation For Models
|
||||
|
||||
- [ApiResponse](docs/ApiResponse.md)
|
||||
- [Category](docs/Category.md)
|
||||
- [Order](docs/Order.md)
|
||||
- [Pet](docs/Pet.md)
|
||||
- [Tag](docs/Tag.md)
|
||||
- [User](docs/User.md)
|
||||
|
||||
|
||||
To get access to the crate's generated documentation, use:
|
||||
|
||||
```
|
||||
cargo doc --open
|
||||
```
|
||||
|
||||
## Author
|
||||
|
||||
|
||||
|
@ -0,0 +1,13 @@
|
||||
# ApiResponse
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**code** | Option<**i32**> | | [optional]
|
||||
**_type** | Option<**String**> | | [optional]
|
||||
**message** | 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)
|
||||
|
||||
|
@ -0,0 +1,12 @@
|
||||
# Category
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**id** | Option<**i64**> | | [optional]
|
||||
**name** | 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)
|
||||
|
||||
|
@ -0,0 +1,16 @@
|
||||
# Order
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**id** | Option<**i64**> | | [optional]
|
||||
**pet_id** | Option<**i64**> | | [optional]
|
||||
**quantity** | Option<**i32**> | | [optional]
|
||||
**ship_date** | Option<**String**> | | [optional]
|
||||
**status** | Option<**String**> | Order Status | [optional]
|
||||
**complete** | Option<**bool**> | | [optional][default to false]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,16 @@
|
||||
# Pet
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**id** | Option<**i64**> | | [optional]
|
||||
**category** | Option<[**crate::models::Category**](Category.md)> | | [optional]
|
||||
**name** | **String** | |
|
||||
**photo_urls** | **Vec<String>** | |
|
||||
**tags** | Option<[**Vec<crate::models::Tag>**](Tag.md)> | | [optional]
|
||||
**status** | Option<**String**> | pet status in the store | [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)
|
||||
|
||||
|
@ -0,0 +1,261 @@
|
||||
# \PetApi
|
||||
|
||||
All URIs are relative to *http://petstore.swagger.io/v2*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
[**add_pet**](PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store
|
||||
[**delete_pet**](PetApi.md#delete_pet) | **DELETE** /pet/{petId} | Deletes a pet
|
||||
[**find_pets_by_status**](PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status
|
||||
[**find_pets_by_tags**](PetApi.md#find_pets_by_tags) | **GET** /pet/findByTags | Finds Pets by tags
|
||||
[**get_pet_by_id**](PetApi.md#get_pet_by_id) | **GET** /pet/{petId} | Find pet by ID
|
||||
[**update_pet**](PetApi.md#update_pet) | **PUT** /pet | Update an existing pet
|
||||
[**update_pet_with_form**](PetApi.md#update_pet_with_form) | **POST** /pet/{petId} | Updates a pet in the store with form data
|
||||
[**upload_file**](PetApi.md#upload_file) | **POST** /pet/{petId}/uploadImage | uploads an image
|
||||
|
||||
|
||||
|
||||
## add_pet
|
||||
|
||||
> crate::models::Pet add_pet(pet)
|
||||
Add a new pet to the store
|
||||
|
||||
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Required | Notes
|
||||
------------- | ------------- | ------------- | ------------- | -------------
|
||||
**pet** | [**Pet**](Pet.md) | Pet object that needs to be added to the store | [required] |
|
||||
|
||||
### Return type
|
||||
|
||||
[**crate::models::Pet**](Pet.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
[petstore_auth](../README.md#petstore_auth)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json, application/xml
|
||||
- **Accept**: application/xml, 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)
|
||||
|
||||
|
||||
## delete_pet
|
||||
|
||||
> delete_pet(pet_id, api_key)
|
||||
Deletes a pet
|
||||
|
||||
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Required | Notes
|
||||
------------- | ------------- | ------------- | ------------- | -------------
|
||||
**pet_id** | **i64** | Pet id to delete | [required] |
|
||||
**api_key** | Option<**String**> | | |
|
||||
|
||||
### Return type
|
||||
|
||||
(empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
[petstore_auth](../README.md#petstore_auth)
|
||||
|
||||
### 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)
|
||||
|
||||
|
||||
## find_pets_by_status
|
||||
|
||||
> Vec<crate::models::Pet> find_pets_by_status(status)
|
||||
Finds Pets by status
|
||||
|
||||
Multiple status values can be provided with comma separated strings
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Required | Notes
|
||||
------------- | ------------- | ------------- | ------------- | -------------
|
||||
**status** | [**Vec<String>**](String.md) | Status values that need to be considered for filter | [required] |
|
||||
|
||||
### Return type
|
||||
|
||||
[**Vec<crate::models::Pet>**](Pet.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
[petstore_auth](../README.md#petstore_auth)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/xml, 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)
|
||||
|
||||
|
||||
## find_pets_by_tags
|
||||
|
||||
> Vec<crate::models::Pet> find_pets_by_tags(tags)
|
||||
Finds Pets by tags
|
||||
|
||||
Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Required | Notes
|
||||
------------- | ------------- | ------------- | ------------- | -------------
|
||||
**tags** | [**Vec<String>**](String.md) | Tags to filter by | [required] |
|
||||
|
||||
### Return type
|
||||
|
||||
[**Vec<crate::models::Pet>**](Pet.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
[petstore_auth](../README.md#petstore_auth)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/xml, 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)
|
||||
|
||||
|
||||
## get_pet_by_id
|
||||
|
||||
> crate::models::Pet get_pet_by_id(pet_id)
|
||||
Find pet by ID
|
||||
|
||||
Returns a single pet
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Required | Notes
|
||||
------------- | ------------- | ------------- | ------------- | -------------
|
||||
**pet_id** | **i64** | ID of pet to return | [required] |
|
||||
|
||||
### Return type
|
||||
|
||||
[**crate::models::Pet**](Pet.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
[api_key](../README.md#api_key)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/xml, 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)
|
||||
|
||||
|
||||
## update_pet
|
||||
|
||||
> crate::models::Pet update_pet(pet)
|
||||
Update an existing pet
|
||||
|
||||
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Required | Notes
|
||||
------------- | ------------- | ------------- | ------------- | -------------
|
||||
**pet** | [**Pet**](Pet.md) | Pet object that needs to be added to the store | [required] |
|
||||
|
||||
### Return type
|
||||
|
||||
[**crate::models::Pet**](Pet.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
[petstore_auth](../README.md#petstore_auth)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json, application/xml
|
||||
- **Accept**: application/xml, 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)
|
||||
|
||||
|
||||
## update_pet_with_form
|
||||
|
||||
> update_pet_with_form(pet_id, name, status)
|
||||
Updates a pet in the store with form data
|
||||
|
||||
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Required | Notes
|
||||
------------- | ------------- | ------------- | ------------- | -------------
|
||||
**pet_id** | **i64** | ID of pet that needs to be updated | [required] |
|
||||
**name** | Option<**String**> | Updated name of the pet | |
|
||||
**status** | Option<**String**> | Updated status of the pet | |
|
||||
|
||||
### Return type
|
||||
|
||||
(empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
[petstore_auth](../README.md#petstore_auth)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/x-www-form-urlencoded
|
||||
- **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)
|
||||
|
||||
|
||||
## upload_file
|
||||
|
||||
> crate::models::ApiResponse upload_file(pet_id, additional_metadata, file)
|
||||
uploads an image
|
||||
|
||||
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Required | Notes
|
||||
------------- | ------------- | ------------- | ------------- | -------------
|
||||
**pet_id** | **i64** | ID of pet to update | [required] |
|
||||
**additional_metadata** | Option<**String**> | Additional data to pass to server | |
|
||||
**file** | Option<**std::path::PathBuf**> | file to upload | |
|
||||
|
||||
### Return type
|
||||
|
||||
[**crate::models::ApiResponse**](ApiResponse.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
[petstore_auth](../README.md#petstore_auth)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: multipart/form-data
|
||||
- **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)
|
||||
|
@ -0,0 +1,129 @@
|
||||
# \StoreApi
|
||||
|
||||
All URIs are relative to *http://petstore.swagger.io/v2*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
[**delete_order**](StoreApi.md#delete_order) | **DELETE** /store/order/{orderId} | Delete purchase order by ID
|
||||
[**get_inventory**](StoreApi.md#get_inventory) | **GET** /store/inventory | Returns pet inventories by status
|
||||
[**get_order_by_id**](StoreApi.md#get_order_by_id) | **GET** /store/order/{orderId} | Find purchase order by ID
|
||||
[**place_order**](StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet
|
||||
|
||||
|
||||
|
||||
## delete_order
|
||||
|
||||
> delete_order(order_id)
|
||||
Delete purchase order by ID
|
||||
|
||||
For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Required | Notes
|
||||
------------- | ------------- | ------------- | ------------- | -------------
|
||||
**order_id** | **String** | ID of the order that needs to be deleted | [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)
|
||||
|
||||
|
||||
## get_inventory
|
||||
|
||||
> ::std::collections::HashMap<String, i32> get_inventory()
|
||||
Returns pet inventories by status
|
||||
|
||||
Returns a map of status codes to quantities
|
||||
|
||||
### Parameters
|
||||
|
||||
This endpoint does not need any parameter.
|
||||
|
||||
### Return type
|
||||
|
||||
**::std::collections::HashMap<String, i32>**
|
||||
|
||||
### Authorization
|
||||
|
||||
[api_key](../README.md#api_key)
|
||||
|
||||
### 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)
|
||||
|
||||
|
||||
## get_order_by_id
|
||||
|
||||
> crate::models::Order get_order_by_id(order_id)
|
||||
Find purchase order by ID
|
||||
|
||||
For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Required | Notes
|
||||
------------- | ------------- | ------------- | ------------- | -------------
|
||||
**order_id** | **i64** | ID of pet that needs to be fetched | [required] |
|
||||
|
||||
### Return type
|
||||
|
||||
[**crate::models::Order**](Order.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/xml, 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)
|
||||
|
||||
|
||||
## place_order
|
||||
|
||||
> crate::models::Order place_order(order)
|
||||
Place an order for a pet
|
||||
|
||||
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Required | Notes
|
||||
------------- | ------------- | ------------- | ------------- | -------------
|
||||
**order** | [**Order**](Order.md) | order placed for purchasing the pet | [required] |
|
||||
|
||||
### Return type
|
||||
|
||||
[**crate::models::Order**](Order.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json
|
||||
- **Accept**: application/xml, 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)
|
||||
|
@ -0,0 +1,12 @@
|
||||
# Tag
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**id** | Option<**i64**> | | [optional]
|
||||
**name** | 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)
|
||||
|
||||
|
@ -0,0 +1,18 @@
|
||||
# User
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**id** | Option<**i64**> | | [optional]
|
||||
**username** | Option<**String**> | | [optional]
|
||||
**first_name** | Option<**String**> | | [optional]
|
||||
**last_name** | Option<**String**> | | [optional]
|
||||
**email** | Option<**String**> | | [optional]
|
||||
**password** | Option<**String**> | | [optional]
|
||||
**phone** | Option<**String**> | | [optional]
|
||||
**user_status** | Option<**i32**> | User Status | [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)
|
||||
|
||||
|
@ -0,0 +1,255 @@
|
||||
# \UserApi
|
||||
|
||||
All URIs are relative to *http://petstore.swagger.io/v2*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
[**create_user**](UserApi.md#create_user) | **POST** /user | Create user
|
||||
[**create_users_with_array_input**](UserApi.md#create_users_with_array_input) | **POST** /user/createWithArray | Creates list of users with given input array
|
||||
[**create_users_with_list_input**](UserApi.md#create_users_with_list_input) | **POST** /user/createWithList | Creates list of users with given input array
|
||||
[**delete_user**](UserApi.md#delete_user) | **DELETE** /user/{username} | Delete user
|
||||
[**get_user_by_name**](UserApi.md#get_user_by_name) | **GET** /user/{username} | Get user by user name
|
||||
[**login_user**](UserApi.md#login_user) | **GET** /user/login | Logs user into the system
|
||||
[**logout_user**](UserApi.md#logout_user) | **GET** /user/logout | Logs out current logged in user session
|
||||
[**update_user**](UserApi.md#update_user) | **PUT** /user/{username} | Updated user
|
||||
|
||||
|
||||
|
||||
## create_user
|
||||
|
||||
> create_user(user)
|
||||
Create user
|
||||
|
||||
This can only be done by the logged in user.
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Required | Notes
|
||||
------------- | ------------- | ------------- | ------------- | -------------
|
||||
**user** | [**User**](User.md) | Created user object | [required] |
|
||||
|
||||
### Return type
|
||||
|
||||
(empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
[api_key](../README.md#api_key)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json
|
||||
- **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)
|
||||
|
||||
|
||||
## create_users_with_array_input
|
||||
|
||||
> create_users_with_array_input(user)
|
||||
Creates list of users with given input array
|
||||
|
||||
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Required | Notes
|
||||
------------- | ------------- | ------------- | ------------- | -------------
|
||||
**user** | [**Vec<crate::models::User>**](User.md) | List of user object | [required] |
|
||||
|
||||
### Return type
|
||||
|
||||
(empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
[api_key](../README.md#api_key)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json
|
||||
- **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)
|
||||
|
||||
|
||||
## create_users_with_list_input
|
||||
|
||||
> create_users_with_list_input(user)
|
||||
Creates list of users with given input array
|
||||
|
||||
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Required | Notes
|
||||
------------- | ------------- | ------------- | ------------- | -------------
|
||||
**user** | [**Vec<crate::models::User>**](User.md) | List of user object | [required] |
|
||||
|
||||
### Return type
|
||||
|
||||
(empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
[api_key](../README.md#api_key)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json
|
||||
- **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)
|
||||
|
||||
|
||||
## delete_user
|
||||
|
||||
> delete_user(username)
|
||||
Delete user
|
||||
|
||||
This can only be done by the logged in user.
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Required | Notes
|
||||
------------- | ------------- | ------------- | ------------- | -------------
|
||||
**username** | **String** | The name that needs to be deleted | [required] |
|
||||
|
||||
### Return type
|
||||
|
||||
(empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
[api_key](../README.md#api_key)
|
||||
|
||||
### 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)
|
||||
|
||||
|
||||
## get_user_by_name
|
||||
|
||||
> crate::models::User get_user_by_name(username)
|
||||
Get user by user name
|
||||
|
||||
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Required | Notes
|
||||
------------- | ------------- | ------------- | ------------- | -------------
|
||||
**username** | **String** | The name that needs to be fetched. Use user1 for testing. | [required] |
|
||||
|
||||
### Return type
|
||||
|
||||
[**crate::models::User**](User.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/xml, 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)
|
||||
|
||||
|
||||
## login_user
|
||||
|
||||
> String login_user(username, password)
|
||||
Logs user into the system
|
||||
|
||||
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Required | Notes
|
||||
------------- | ------------- | ------------- | ------------- | -------------
|
||||
**username** | **String** | The user name for login | [required] |
|
||||
**password** | **String** | The password for login in clear text | [required] |
|
||||
|
||||
### Return type
|
||||
|
||||
**String**
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/xml, 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)
|
||||
|
||||
|
||||
## logout_user
|
||||
|
||||
> logout_user()
|
||||
Logs out current logged in user session
|
||||
|
||||
|
||||
|
||||
### Parameters
|
||||
|
||||
This endpoint does not need any parameter.
|
||||
|
||||
### Return type
|
||||
|
||||
(empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
[api_key](../README.md#api_key)
|
||||
|
||||
### 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)
|
||||
|
||||
|
||||
## update_user
|
||||
|
||||
> update_user(username, user)
|
||||
Updated user
|
||||
|
||||
This can only be done by the logged in user.
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Required | Notes
|
||||
------------- | ------------- | ------------- | ------------- | -------------
|
||||
**username** | **String** | name that need to be deleted | [required] |
|
||||
**user** | [**User**](User.md) | Updated user object | [required] |
|
||||
|
||||
### Return type
|
||||
|
||||
(empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
[api_key](../README.md#api_key)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json
|
||||
- **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,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'
|
@ -0,0 +1,46 @@
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>RustReqwestAWSV4SignatureClientTests</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<name>Rust Reqwest AWSV4Signature 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>build</argument>
|
||||
</arguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
@ -0,0 +1,96 @@
|
||||
/*
|
||||
* 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 reqwest;
|
||||
|
||||
use std::time::SystemTime;
|
||||
use aws_sigv4::http_request::{sign, SigningSettings, SigningParams, SignableRequest};
|
||||
use http;
|
||||
use secrecy::{SecretString, ExposeSecret};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Configuration {
|
||||
pub base_path: String,
|
||||
pub user_agent: Option<String>,
|
||||
pub client: reqwest::Client,
|
||||
pub basic_auth: Option<BasicAuth>,
|
||||
pub oauth_access_token: Option<String>,
|
||||
pub bearer_access_token: Option<String>,
|
||||
pub api_key: Option<ApiKey>,
|
||||
pub aws_v4_key: Option<AWSv4Key>,
|
||||
// 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,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct AWSv4Key {
|
||||
pub access_key: String,
|
||||
pub secret_key: SecretString,
|
||||
pub region: String,
|
||||
pub service: String,
|
||||
}
|
||||
|
||||
impl AWSv4Key {
|
||||
pub fn sign(&self, uri: &str, method: &str, body: &str) -> Result<Vec::<(String, String)>, aws_sigv4::http_request::Error> {
|
||||
let request = http::Request::builder()
|
||||
.uri(uri)
|
||||
.method(method)
|
||||
.body(body).unwrap();
|
||||
let signing_settings = SigningSettings::default();
|
||||
let signing_params = SigningParams::builder()
|
||||
.access_key(self.access_key.as_str())
|
||||
.secret_key(self.secret_key.expose_secret().as_str())
|
||||
.region(self.region.as_str())
|
||||
.service_name(self.service.as_str())
|
||||
.time(SystemTime::now())
|
||||
.settings(signing_settings)
|
||||
.build()
|
||||
.unwrap();
|
||||
let signable_request = SignableRequest::from(&request);
|
||||
let (mut signing_instructions, _signature) = sign(signable_request, &signing_params)?.into_parts();
|
||||
let mut additional_headers = Vec::<(String, String)>::new();
|
||||
if let Some(new_headers) = signing_instructions.take_headers() {
|
||||
for (name, value) in new_headers.into_iter() {
|
||||
additional_headers.push((name.expect("header should have name").to_string(),
|
||||
value.to_str().expect("header value should be a string").to_string()));
|
||||
}
|
||||
}
|
||||
return Ok(additional_headers);
|
||||
}
|
||||
}
|
||||
|
||||
impl Configuration {
|
||||
pub fn new() -> Configuration {
|
||||
Configuration::default()
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Configuration {
|
||||
fn default() -> Self {
|
||||
Configuration {
|
||||
base_path: "http://petstore.swagger.io/v2".to_owned(),
|
||||
user_agent: Some("OpenAPI-Generator/1.0.0/rust".to_owned()),
|
||||
client: reqwest::Client::new(),
|
||||
basic_auth: None,
|
||||
oauth_access_token: None,
|
||||
bearer_access_token: None,
|
||||
api_key: None,
|
||||
aws_v4_key: None,
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
use std::error;
|
||||
use std::fmt;
|
||||
use aws_sigv4;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ResponseContent<T> {
|
||||
pub status: reqwest::StatusCode,
|
||||
pub content: String,
|
||||
pub entity: Option<T>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Error<T> {
|
||||
Reqwest(reqwest::Error),
|
||||
Serde(serde_json::Error),
|
||||
Io(std::io::Error),
|
||||
ResponseError(ResponseContent<T>),
|
||||
AWSV4SignatureError(aws_sigv4::http_request::Error),
|
||||
}
|
||||
|
||||
impl <T> fmt::Display for Error<T> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let (module, e) = match self {
|
||||
Error::Reqwest(e) => ("reqwest", e.to_string()),
|
||||
Error::Serde(e) => ("serde", e.to_string()),
|
||||
Error::Io(e) => ("IO", e.to_string()),
|
||||
Error::ResponseError(e) => ("response", format!("status code {}", e.status)),
|
||||
Error::AWSV4SignatureError(e) => ("aws v4 signature", e.to_string()),
|
||||
};
|
||||
write!(f, "error in {}: {}", module, e)
|
||||
}
|
||||
}
|
||||
|
||||
impl <T: fmt::Debug> error::Error for Error<T> {
|
||||
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
|
||||
Some(match self {
|
||||
Error::Reqwest(e) => e,
|
||||
Error::Serde(e) => e,
|
||||
Error::Io(e) => e,
|
||||
Error::ResponseError(_) => return None,
|
||||
Error::AWSV4SignatureError(_) => return None,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl <T> From<reqwest::Error> for Error<T> {
|
||||
fn from(e: reqwest::Error) -> Self {
|
||||
Error::Reqwest(e)
|
||||
}
|
||||
}
|
||||
|
||||
impl <T> From<serde_json::Error> for Error<T> {
|
||||
fn from(e: serde_json::Error) -> Self {
|
||||
Error::Serde(e)
|
||||
}
|
||||
}
|
||||
|
||||
impl <T> From<std::io::Error> for Error<T> {
|
||||
fn from(e: std::io::Error) -> Self {
|
||||
Error::Io(e)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn urlencode<T: AsRef<str>>(s: T) -> String {
|
||||
::url::form_urlencoded::byte_serialize(s.as_ref().as_bytes()).collect()
|
||||
}
|
||||
|
||||
pub mod pet_api;
|
||||
pub mod store_api;
|
||||
pub mod user_api;
|
||||
|
||||
pub mod configuration;
|
@ -0,0 +1,470 @@
|
||||
/*
|
||||
* 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 reqwest;
|
||||
|
||||
use crate::apis::ResponseContent;
|
||||
use super::{Error, configuration};
|
||||
|
||||
|
||||
/// struct for typed errors of method [`add_pet`]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum AddPetError {
|
||||
Status405(),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
/// struct for typed errors of method [`delete_pet`]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum DeletePetError {
|
||||
Status400(),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
/// struct for typed errors of method [`find_pets_by_status`]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum FindPetsByStatusError {
|
||||
Status400(),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
/// struct for typed errors of method [`find_pets_by_tags`]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum FindPetsByTagsError {
|
||||
Status400(),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
/// struct for typed errors of method [`get_pet_by_id`]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum GetPetByIdError {
|
||||
Status400(),
|
||||
Status404(),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
/// struct for typed errors of method [`update_pet`]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum UpdatePetError {
|
||||
Status400(),
|
||||
Status404(),
|
||||
Status405(),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
/// struct for typed errors of method [`update_pet_with_form`]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum UpdatePetWithFormError {
|
||||
Status405(),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
/// struct for typed errors of method [`upload_file`]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum UploadFileError {
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
pub fn add_pet(configuration: &configuration::Configuration, pet: crate::models::Pet) -> Result<crate::models::Pet, Error<AddPetError>> {
|
||||
let local_var_configuration = configuration;
|
||||
|
||||
let local_var_client = &local_var_configuration.client;
|
||||
|
||||
let local_var_uri_str = format!("{}/pet", local_var_configuration.base_path);
|
||||
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
|
||||
|
||||
if let Some(ref local_var_aws_v4_key) = local_var_configuration.aws_v4_key {
|
||||
let local_var_new_headers = match local_var_aws_v4_key.sign(
|
||||
&local_var_uri_str,
|
||||
"POST",
|
||||
&serde_json::to_string(&pet).expect("param should serialize to string"),
|
||||
) {
|
||||
Ok(new_headers) => new_headers,
|
||||
Err(err) => return Err(Error::AWSV4SignatureError(err)),
|
||||
};
|
||||
for (local_var_name, local_var_value) in local_var_new_headers.iter() {
|
||||
local_var_req_builder = local_var_req_builder.header(local_var_name.as_str(), local_var_value.as_str());
|
||||
}
|
||||
}
|
||||
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
|
||||
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
|
||||
}
|
||||
if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
|
||||
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
|
||||
};
|
||||
local_var_req_builder = local_var_req_builder.json(&pet);
|
||||
|
||||
let local_var_req = local_var_req_builder.build()?;
|
||||
let mut local_var_resp = local_var_client.execute(local_var_req)?;
|
||||
|
||||
let local_var_status = local_var_resp.status();
|
||||
let local_var_content = local_var_resp.text()?;
|
||||
|
||||
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
||||
serde_json::from_str(&local_var_content).map_err(Error::from)
|
||||
} else {
|
||||
let local_var_entity: Option<AddPetError> = serde_json::from_str(&local_var_content).ok();
|
||||
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
||||
Err(Error::ResponseError(local_var_error))
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
pub fn delete_pet(configuration: &configuration::Configuration, pet_id: i64, api_key: Option<&str>) -> Result<(), Error<DeletePetError>> {
|
||||
let local_var_configuration = configuration;
|
||||
|
||||
let local_var_client = &local_var_configuration.client;
|
||||
|
||||
let local_var_uri_str = format!("{}/pet/{petId}", local_var_configuration.base_path, petId=pet_id);
|
||||
let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
|
||||
|
||||
if let Some(ref local_var_aws_v4_key) = local_var_configuration.aws_v4_key {
|
||||
let local_var_new_headers = match local_var_aws_v4_key.sign(
|
||||
&local_var_uri_str,
|
||||
"DELETE",
|
||||
&"",
|
||||
) {
|
||||
Ok(new_headers) => new_headers,
|
||||
Err(err) => return Err(Error::AWSV4SignatureError(err)),
|
||||
};
|
||||
for (local_var_name, local_var_value) in local_var_new_headers.iter() {
|
||||
local_var_req_builder = local_var_req_builder.header(local_var_name.as_str(), local_var_value.as_str());
|
||||
}
|
||||
}
|
||||
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
|
||||
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
|
||||
}
|
||||
if let Some(local_var_param_value) = api_key {
|
||||
local_var_req_builder = local_var_req_builder.header("api_key", local_var_param_value.to_string());
|
||||
}
|
||||
if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
|
||||
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
|
||||
};
|
||||
|
||||
let local_var_req = local_var_req_builder.build()?;
|
||||
let mut local_var_resp = local_var_client.execute(local_var_req)?;
|
||||
|
||||
let local_var_status = local_var_resp.status();
|
||||
let local_var_content = local_var_resp.text()?;
|
||||
|
||||
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
||||
Ok(())
|
||||
} else {
|
||||
let local_var_entity: Option<DeletePetError> = serde_json::from_str(&local_var_content).ok();
|
||||
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
||||
Err(Error::ResponseError(local_var_error))
|
||||
}
|
||||
}
|
||||
|
||||
/// Multiple status values can be provided with comma separated strings
|
||||
pub fn find_pets_by_status(configuration: &configuration::Configuration, status: Vec<String>) -> Result<Vec<crate::models::Pet>, Error<FindPetsByStatusError>> {
|
||||
let local_var_configuration = configuration;
|
||||
|
||||
let local_var_client = &local_var_configuration.client;
|
||||
|
||||
let local_var_uri_str = format!("{}/pet/findByStatus", local_var_configuration.base_path);
|
||||
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
|
||||
|
||||
local_var_req_builder = match "csv" {
|
||||
"multi" => local_var_req_builder.query(&status.into_iter().map(|p| ("status".to_owned(), p)).collect::<Vec<(std::string::String, std::string::String)>>()),
|
||||
_ => local_var_req_builder.query(&[("status", &status.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
|
||||
};
|
||||
if let Some(ref local_var_aws_v4_key) = local_var_configuration.aws_v4_key {
|
||||
let local_var_new_headers = match local_var_aws_v4_key.sign(
|
||||
&local_var_uri_str,
|
||||
"GET",
|
||||
&"",
|
||||
) {
|
||||
Ok(new_headers) => new_headers,
|
||||
Err(err) => return Err(Error::AWSV4SignatureError(err)),
|
||||
};
|
||||
for (local_var_name, local_var_value) in local_var_new_headers.iter() {
|
||||
local_var_req_builder = local_var_req_builder.header(local_var_name.as_str(), local_var_value.as_str());
|
||||
}
|
||||
}
|
||||
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
|
||||
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
|
||||
}
|
||||
if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
|
||||
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
|
||||
};
|
||||
|
||||
let local_var_req = local_var_req_builder.build()?;
|
||||
let mut local_var_resp = local_var_client.execute(local_var_req)?;
|
||||
|
||||
let local_var_status = local_var_resp.status();
|
||||
let local_var_content = local_var_resp.text()?;
|
||||
|
||||
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
||||
serde_json::from_str(&local_var_content).map_err(Error::from)
|
||||
} else {
|
||||
let local_var_entity: Option<FindPetsByStatusError> = serde_json::from_str(&local_var_content).ok();
|
||||
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
||||
Err(Error::ResponseError(local_var_error))
|
||||
}
|
||||
}
|
||||
|
||||
/// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||
pub fn find_pets_by_tags(configuration: &configuration::Configuration, tags: Vec<String>) -> Result<Vec<crate::models::Pet>, Error<FindPetsByTagsError>> {
|
||||
let local_var_configuration = configuration;
|
||||
|
||||
let local_var_client = &local_var_configuration.client;
|
||||
|
||||
let local_var_uri_str = format!("{}/pet/findByTags", local_var_configuration.base_path);
|
||||
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
|
||||
|
||||
local_var_req_builder = match "csv" {
|
||||
"multi" => local_var_req_builder.query(&tags.into_iter().map(|p| ("tags".to_owned(), p)).collect::<Vec<(std::string::String, std::string::String)>>()),
|
||||
_ => local_var_req_builder.query(&[("tags", &tags.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
|
||||
};
|
||||
if let Some(ref local_var_aws_v4_key) = local_var_configuration.aws_v4_key {
|
||||
let local_var_new_headers = match local_var_aws_v4_key.sign(
|
||||
&local_var_uri_str,
|
||||
"GET",
|
||||
&"",
|
||||
) {
|
||||
Ok(new_headers) => new_headers,
|
||||
Err(err) => return Err(Error::AWSV4SignatureError(err)),
|
||||
};
|
||||
for (local_var_name, local_var_value) in local_var_new_headers.iter() {
|
||||
local_var_req_builder = local_var_req_builder.header(local_var_name.as_str(), local_var_value.as_str());
|
||||
}
|
||||
}
|
||||
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
|
||||
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
|
||||
}
|
||||
if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
|
||||
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
|
||||
};
|
||||
|
||||
let local_var_req = local_var_req_builder.build()?;
|
||||
let mut local_var_resp = local_var_client.execute(local_var_req)?;
|
||||
|
||||
let local_var_status = local_var_resp.status();
|
||||
let local_var_content = local_var_resp.text()?;
|
||||
|
||||
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
||||
serde_json::from_str(&local_var_content).map_err(Error::from)
|
||||
} else {
|
||||
let local_var_entity: Option<FindPetsByTagsError> = serde_json::from_str(&local_var_content).ok();
|
||||
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
||||
Err(Error::ResponseError(local_var_error))
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns a single pet
|
||||
pub fn get_pet_by_id(configuration: &configuration::Configuration, pet_id: i64) -> Result<crate::models::Pet, Error<GetPetByIdError>> {
|
||||
let local_var_configuration = configuration;
|
||||
|
||||
let local_var_client = &local_var_configuration.client;
|
||||
|
||||
let local_var_uri_str = format!("{}/pet/{petId}", local_var_configuration.base_path, petId=pet_id);
|
||||
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
|
||||
|
||||
if let Some(ref local_var_aws_v4_key) = local_var_configuration.aws_v4_key {
|
||||
let local_var_new_headers = match local_var_aws_v4_key.sign(
|
||||
&local_var_uri_str,
|
||||
"GET",
|
||||
&"",
|
||||
) {
|
||||
Ok(new_headers) => new_headers,
|
||||
Err(err) => return Err(Error::AWSV4SignatureError(err)),
|
||||
};
|
||||
for (local_var_name, local_var_value) in local_var_new_headers.iter() {
|
||||
local_var_req_builder = local_var_req_builder.header(local_var_name.as_str(), local_var_value.as_str());
|
||||
}
|
||||
}
|
||||
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
|
||||
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
|
||||
}
|
||||
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
|
||||
let local_var_key = local_var_apikey.key.clone();
|
||||
let local_var_value = match local_var_apikey.prefix {
|
||||
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
|
||||
None => local_var_key,
|
||||
};
|
||||
local_var_req_builder = local_var_req_builder.header("api_key", local_var_value);
|
||||
};
|
||||
|
||||
let local_var_req = local_var_req_builder.build()?;
|
||||
let mut local_var_resp = local_var_client.execute(local_var_req)?;
|
||||
|
||||
let local_var_status = local_var_resp.status();
|
||||
let local_var_content = local_var_resp.text()?;
|
||||
|
||||
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
||||
serde_json::from_str(&local_var_content).map_err(Error::from)
|
||||
} else {
|
||||
let local_var_entity: Option<GetPetByIdError> = serde_json::from_str(&local_var_content).ok();
|
||||
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
||||
Err(Error::ResponseError(local_var_error))
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
pub fn update_pet(configuration: &configuration::Configuration, pet: crate::models::Pet) -> Result<crate::models::Pet, Error<UpdatePetError>> {
|
||||
let local_var_configuration = configuration;
|
||||
|
||||
let local_var_client = &local_var_configuration.client;
|
||||
|
||||
let local_var_uri_str = format!("{}/pet", local_var_configuration.base_path);
|
||||
let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
|
||||
|
||||
if let Some(ref local_var_aws_v4_key) = local_var_configuration.aws_v4_key {
|
||||
let local_var_new_headers = match local_var_aws_v4_key.sign(
|
||||
&local_var_uri_str,
|
||||
"PUT",
|
||||
&serde_json::to_string(&pet).expect("param should serialize to string"),
|
||||
) {
|
||||
Ok(new_headers) => new_headers,
|
||||
Err(err) => return Err(Error::AWSV4SignatureError(err)),
|
||||
};
|
||||
for (local_var_name, local_var_value) in local_var_new_headers.iter() {
|
||||
local_var_req_builder = local_var_req_builder.header(local_var_name.as_str(), local_var_value.as_str());
|
||||
}
|
||||
}
|
||||
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
|
||||
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
|
||||
}
|
||||
if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
|
||||
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
|
||||
};
|
||||
local_var_req_builder = local_var_req_builder.json(&pet);
|
||||
|
||||
let local_var_req = local_var_req_builder.build()?;
|
||||
let mut local_var_resp = local_var_client.execute(local_var_req)?;
|
||||
|
||||
let local_var_status = local_var_resp.status();
|
||||
let local_var_content = local_var_resp.text()?;
|
||||
|
||||
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
||||
serde_json::from_str(&local_var_content).map_err(Error::from)
|
||||
} else {
|
||||
let local_var_entity: Option<UpdatePetError> = serde_json::from_str(&local_var_content).ok();
|
||||
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
||||
Err(Error::ResponseError(local_var_error))
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
pub fn update_pet_with_form(configuration: &configuration::Configuration, pet_id: i64, name: Option<&str>, status: Option<&str>) -> Result<(), Error<UpdatePetWithFormError>> {
|
||||
let local_var_configuration = configuration;
|
||||
|
||||
let local_var_client = &local_var_configuration.client;
|
||||
|
||||
let local_var_uri_str = format!("{}/pet/{petId}", local_var_configuration.base_path, petId=pet_id);
|
||||
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
|
||||
|
||||
if let Some(ref local_var_aws_v4_key) = local_var_configuration.aws_v4_key {
|
||||
let local_var_new_headers = match local_var_aws_v4_key.sign(
|
||||
&local_var_uri_str,
|
||||
"POST",
|
||||
&"",
|
||||
) {
|
||||
Ok(new_headers) => new_headers,
|
||||
Err(err) => return Err(Error::AWSV4SignatureError(err)),
|
||||
};
|
||||
for (local_var_name, local_var_value) in local_var_new_headers.iter() {
|
||||
local_var_req_builder = local_var_req_builder.header(local_var_name.as_str(), local_var_value.as_str());
|
||||
}
|
||||
}
|
||||
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
|
||||
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
|
||||
}
|
||||
if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
|
||||
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
|
||||
};
|
||||
let mut local_var_form_params = std::collections::HashMap::new();
|
||||
if let Some(local_var_param_value) = name {
|
||||
local_var_form_params.insert("name", local_var_param_value.to_string());
|
||||
}
|
||||
if let Some(local_var_param_value) = status {
|
||||
local_var_form_params.insert("status", local_var_param_value.to_string());
|
||||
}
|
||||
local_var_req_builder = local_var_req_builder.form(&local_var_form_params);
|
||||
|
||||
let local_var_req = local_var_req_builder.build()?;
|
||||
let mut local_var_resp = local_var_client.execute(local_var_req)?;
|
||||
|
||||
let local_var_status = local_var_resp.status();
|
||||
let local_var_content = local_var_resp.text()?;
|
||||
|
||||
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
||||
Ok(())
|
||||
} else {
|
||||
let local_var_entity: Option<UpdatePetWithFormError> = serde_json::from_str(&local_var_content).ok();
|
||||
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
||||
Err(Error::ResponseError(local_var_error))
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
pub fn upload_file(configuration: &configuration::Configuration, pet_id: i64, additional_metadata: Option<&str>, file: Option<std::path::PathBuf>) -> Result<crate::models::ApiResponse, Error<UploadFileError>> {
|
||||
let local_var_configuration = configuration;
|
||||
|
||||
let local_var_client = &local_var_configuration.client;
|
||||
|
||||
let local_var_uri_str = format!("{}/pet/{petId}/uploadImage", local_var_configuration.base_path, petId=pet_id);
|
||||
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
|
||||
|
||||
if let Some(ref local_var_aws_v4_key) = local_var_configuration.aws_v4_key {
|
||||
let local_var_new_headers = match local_var_aws_v4_key.sign(
|
||||
&local_var_uri_str,
|
||||
"POST",
|
||||
&"",
|
||||
) {
|
||||
Ok(new_headers) => new_headers,
|
||||
Err(err) => return Err(Error::AWSV4SignatureError(err)),
|
||||
};
|
||||
for (local_var_name, local_var_value) in local_var_new_headers.iter() {
|
||||
local_var_req_builder = local_var_req_builder.header(local_var_name.as_str(), local_var_value.as_str());
|
||||
}
|
||||
}
|
||||
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
|
||||
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
|
||||
}
|
||||
if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
|
||||
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
|
||||
};
|
||||
let mut local_var_form = reqwest::multipart::Form::new();
|
||||
if let Some(local_var_param_value) = additional_metadata {
|
||||
local_var_form = local_var_form.text("additionalMetadata", local_var_param_value.to_string());
|
||||
}
|
||||
if let Some(local_var_param_value) = file {
|
||||
local_var_form = local_var_form.file("file", local_var_param_value)?;
|
||||
}
|
||||
local_var_req_builder = local_var_req_builder.multipart(local_var_form);
|
||||
|
||||
let local_var_req = local_var_req_builder.build()?;
|
||||
let mut local_var_resp = local_var_client.execute(local_var_req)?;
|
||||
|
||||
let local_var_status = local_var_resp.status();
|
||||
let local_var_content = local_var_resp.text()?;
|
||||
|
||||
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
||||
serde_json::from_str(&local_var_content).map_err(Error::from)
|
||||
} else {
|
||||
let local_var_entity: Option<UploadFileError> = serde_json::from_str(&local_var_content).ok();
|
||||
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
||||
Err(Error::ResponseError(local_var_error))
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,185 @@
|
||||
/*
|
||||
* 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 reqwest;
|
||||
|
||||
use crate::apis::ResponseContent;
|
||||
use super::{Error, configuration};
|
||||
|
||||
|
||||
/// struct for typed errors of method [`delete_order`]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum DeleteOrderError {
|
||||
Status400(),
|
||||
Status404(),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
/// struct for typed errors of method [`get_inventory`]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum GetInventoryError {
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
/// struct for typed errors of method [`get_order_by_id`]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum GetOrderByIdError {
|
||||
Status400(),
|
||||
Status404(),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
/// struct for typed errors of method [`place_order`]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum PlaceOrderError {
|
||||
Status400(),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
|
||||
/// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
pub fn delete_order(configuration: &configuration::Configuration, order_id: &str) -> Result<(), Error<DeleteOrderError>> {
|
||||
let local_var_configuration = configuration;
|
||||
|
||||
let local_var_client = &local_var_configuration.client;
|
||||
|
||||
let local_var_uri_str = format!("{}/store/order/{orderId}", local_var_configuration.base_path, orderId=crate::apis::urlencode(order_id));
|
||||
let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
|
||||
|
||||
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
|
||||
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
|
||||
}
|
||||
|
||||
let local_var_req = local_var_req_builder.build()?;
|
||||
let mut local_var_resp = local_var_client.execute(local_var_req)?;
|
||||
|
||||
let local_var_status = local_var_resp.status();
|
||||
let local_var_content = local_var_resp.text()?;
|
||||
|
||||
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
||||
Ok(())
|
||||
} else {
|
||||
let local_var_entity: Option<DeleteOrderError> = serde_json::from_str(&local_var_content).ok();
|
||||
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
||||
Err(Error::ResponseError(local_var_error))
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns a map of status codes to quantities
|
||||
pub fn get_inventory(configuration: &configuration::Configuration, ) -> Result<::std::collections::HashMap<String, i32>, Error<GetInventoryError>> {
|
||||
let local_var_configuration = configuration;
|
||||
|
||||
let local_var_client = &local_var_configuration.client;
|
||||
|
||||
let local_var_uri_str = format!("{}/store/inventory", local_var_configuration.base_path);
|
||||
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
|
||||
|
||||
if let Some(ref local_var_aws_v4_key) = local_var_configuration.aws_v4_key {
|
||||
let local_var_new_headers = match local_var_aws_v4_key.sign(
|
||||
&local_var_uri_str,
|
||||
"GET",
|
||||
&"",
|
||||
) {
|
||||
Ok(new_headers) => new_headers,
|
||||
Err(err) => return Err(Error::AWSV4SignatureError(err)),
|
||||
};
|
||||
for (local_var_name, local_var_value) in local_var_new_headers.iter() {
|
||||
local_var_req_builder = local_var_req_builder.header(local_var_name.as_str(), local_var_value.as_str());
|
||||
}
|
||||
}
|
||||
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
|
||||
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
|
||||
}
|
||||
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
|
||||
let local_var_key = local_var_apikey.key.clone();
|
||||
let local_var_value = match local_var_apikey.prefix {
|
||||
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
|
||||
None => local_var_key,
|
||||
};
|
||||
local_var_req_builder = local_var_req_builder.header("api_key", local_var_value);
|
||||
};
|
||||
|
||||
let local_var_req = local_var_req_builder.build()?;
|
||||
let mut local_var_resp = local_var_client.execute(local_var_req)?;
|
||||
|
||||
let local_var_status = local_var_resp.status();
|
||||
let local_var_content = local_var_resp.text()?;
|
||||
|
||||
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
||||
serde_json::from_str(&local_var_content).map_err(Error::from)
|
||||
} else {
|
||||
let local_var_entity: Option<GetInventoryError> = serde_json::from_str(&local_var_content).ok();
|
||||
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
||||
Err(Error::ResponseError(local_var_error))
|
||||
}
|
||||
}
|
||||
|
||||
/// For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
pub fn get_order_by_id(configuration: &configuration::Configuration, order_id: i64) -> Result<crate::models::Order, Error<GetOrderByIdError>> {
|
||||
let local_var_configuration = configuration;
|
||||
|
||||
let local_var_client = &local_var_configuration.client;
|
||||
|
||||
let local_var_uri_str = format!("{}/store/order/{orderId}", local_var_configuration.base_path, orderId=order_id);
|
||||
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
|
||||
|
||||
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
|
||||
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
|
||||
}
|
||||
|
||||
let local_var_req = local_var_req_builder.build()?;
|
||||
let mut local_var_resp = local_var_client.execute(local_var_req)?;
|
||||
|
||||
let local_var_status = local_var_resp.status();
|
||||
let local_var_content = local_var_resp.text()?;
|
||||
|
||||
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
||||
serde_json::from_str(&local_var_content).map_err(Error::from)
|
||||
} else {
|
||||
let local_var_entity: Option<GetOrderByIdError> = serde_json::from_str(&local_var_content).ok();
|
||||
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
||||
Err(Error::ResponseError(local_var_error))
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
pub fn place_order(configuration: &configuration::Configuration, order: crate::models::Order) -> Result<crate::models::Order, Error<PlaceOrderError>> {
|
||||
let local_var_configuration = configuration;
|
||||
|
||||
let local_var_client = &local_var_configuration.client;
|
||||
|
||||
let local_var_uri_str = format!("{}/store/order", local_var_configuration.base_path);
|
||||
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
|
||||
|
||||
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
|
||||
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
|
||||
}
|
||||
local_var_req_builder = local_var_req_builder.json(&order);
|
||||
|
||||
let local_var_req = local_var_req_builder.build()?;
|
||||
let mut local_var_resp = local_var_client.execute(local_var_req)?;
|
||||
|
||||
let local_var_status = local_var_resp.status();
|
||||
let local_var_content = local_var_resp.text()?;
|
||||
|
||||
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
||||
serde_json::from_str(&local_var_content).map_err(Error::from)
|
||||
} else {
|
||||
let local_var_entity: Option<PlaceOrderError> = serde_json::from_str(&local_var_content).ok();
|
||||
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
||||
Err(Error::ResponseError(local_var_error))
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,441 @@
|
||||
/*
|
||||
* 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 reqwest;
|
||||
|
||||
use crate::apis::ResponseContent;
|
||||
use super::{Error, configuration};
|
||||
|
||||
|
||||
/// struct for typed errors of method [`create_user`]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum CreateUserError {
|
||||
DefaultResponse(),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
/// struct for typed errors of method [`create_users_with_array_input`]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum CreateUsersWithArrayInputError {
|
||||
DefaultResponse(),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
/// struct for typed errors of method [`create_users_with_list_input`]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum CreateUsersWithListInputError {
|
||||
DefaultResponse(),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
/// struct for typed errors of method [`delete_user`]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum DeleteUserError {
|
||||
Status400(),
|
||||
Status404(),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
/// struct for typed errors of method [`get_user_by_name`]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum GetUserByNameError {
|
||||
Status400(),
|
||||
Status404(),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
/// struct for typed errors of method [`login_user`]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum LoginUserError {
|
||||
Status400(),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
/// struct for typed errors of method [`logout_user`]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum LogoutUserError {
|
||||
DefaultResponse(),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
/// struct for typed errors of method [`update_user`]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum UpdateUserError {
|
||||
Status400(),
|
||||
Status404(),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
|
||||
/// This can only be done by the logged in user.
|
||||
pub fn create_user(configuration: &configuration::Configuration, user: crate::models::User) -> Result<(), Error<CreateUserError>> {
|
||||
let local_var_configuration = configuration;
|
||||
|
||||
let local_var_client = &local_var_configuration.client;
|
||||
|
||||
let local_var_uri_str = format!("{}/user", local_var_configuration.base_path);
|
||||
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
|
||||
|
||||
if let Some(ref local_var_aws_v4_key) = local_var_configuration.aws_v4_key {
|
||||
let local_var_new_headers = match local_var_aws_v4_key.sign(
|
||||
&local_var_uri_str,
|
||||
"POST",
|
||||
&serde_json::to_string(&user).expect("param should serialize to string"),
|
||||
) {
|
||||
Ok(new_headers) => new_headers,
|
||||
Err(err) => return Err(Error::AWSV4SignatureError(err)),
|
||||
};
|
||||
for (local_var_name, local_var_value) in local_var_new_headers.iter() {
|
||||
local_var_req_builder = local_var_req_builder.header(local_var_name.as_str(), local_var_value.as_str());
|
||||
}
|
||||
}
|
||||
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
|
||||
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
|
||||
}
|
||||
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
|
||||
let local_var_key = local_var_apikey.key.clone();
|
||||
let local_var_value = match local_var_apikey.prefix {
|
||||
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
|
||||
None => local_var_key,
|
||||
};
|
||||
local_var_req_builder = local_var_req_builder.header("api_key", local_var_value);
|
||||
};
|
||||
local_var_req_builder = local_var_req_builder.json(&user);
|
||||
|
||||
let local_var_req = local_var_req_builder.build()?;
|
||||
let mut local_var_resp = local_var_client.execute(local_var_req)?;
|
||||
|
||||
let local_var_status = local_var_resp.status();
|
||||
let local_var_content = local_var_resp.text()?;
|
||||
|
||||
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
||||
Ok(())
|
||||
} else {
|
||||
let local_var_entity: Option<CreateUserError> = serde_json::from_str(&local_var_content).ok();
|
||||
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
||||
Err(Error::ResponseError(local_var_error))
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
pub fn create_users_with_array_input(configuration: &configuration::Configuration, user: Vec<crate::models::User>) -> Result<(), Error<CreateUsersWithArrayInputError>> {
|
||||
let local_var_configuration = configuration;
|
||||
|
||||
let local_var_client = &local_var_configuration.client;
|
||||
|
||||
let local_var_uri_str = format!("{}/user/createWithArray", local_var_configuration.base_path);
|
||||
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
|
||||
|
||||
if let Some(ref local_var_aws_v4_key) = local_var_configuration.aws_v4_key {
|
||||
let local_var_new_headers = match local_var_aws_v4_key.sign(
|
||||
&local_var_uri_str,
|
||||
"POST",
|
||||
&serde_json::to_string(&user).expect("param should serialize to string"),
|
||||
) {
|
||||
Ok(new_headers) => new_headers,
|
||||
Err(err) => return Err(Error::AWSV4SignatureError(err)),
|
||||
};
|
||||
for (local_var_name, local_var_value) in local_var_new_headers.iter() {
|
||||
local_var_req_builder = local_var_req_builder.header(local_var_name.as_str(), local_var_value.as_str());
|
||||
}
|
||||
}
|
||||
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
|
||||
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
|
||||
}
|
||||
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
|
||||
let local_var_key = local_var_apikey.key.clone();
|
||||
let local_var_value = match local_var_apikey.prefix {
|
||||
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
|
||||
None => local_var_key,
|
||||
};
|
||||
local_var_req_builder = local_var_req_builder.header("api_key", local_var_value);
|
||||
};
|
||||
local_var_req_builder = local_var_req_builder.json(&user);
|
||||
|
||||
let local_var_req = local_var_req_builder.build()?;
|
||||
let mut local_var_resp = local_var_client.execute(local_var_req)?;
|
||||
|
||||
let local_var_status = local_var_resp.status();
|
||||
let local_var_content = local_var_resp.text()?;
|
||||
|
||||
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
||||
Ok(())
|
||||
} else {
|
||||
let local_var_entity: Option<CreateUsersWithArrayInputError> = serde_json::from_str(&local_var_content).ok();
|
||||
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
||||
Err(Error::ResponseError(local_var_error))
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
pub fn create_users_with_list_input(configuration: &configuration::Configuration, user: Vec<crate::models::User>) -> Result<(), Error<CreateUsersWithListInputError>> {
|
||||
let local_var_configuration = configuration;
|
||||
|
||||
let local_var_client = &local_var_configuration.client;
|
||||
|
||||
let local_var_uri_str = format!("{}/user/createWithList", local_var_configuration.base_path);
|
||||
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
|
||||
|
||||
if let Some(ref local_var_aws_v4_key) = local_var_configuration.aws_v4_key {
|
||||
let local_var_new_headers = match local_var_aws_v4_key.sign(
|
||||
&local_var_uri_str,
|
||||
"POST",
|
||||
&serde_json::to_string(&user).expect("param should serialize to string"),
|
||||
) {
|
||||
Ok(new_headers) => new_headers,
|
||||
Err(err) => return Err(Error::AWSV4SignatureError(err)),
|
||||
};
|
||||
for (local_var_name, local_var_value) in local_var_new_headers.iter() {
|
||||
local_var_req_builder = local_var_req_builder.header(local_var_name.as_str(), local_var_value.as_str());
|
||||
}
|
||||
}
|
||||
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
|
||||
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
|
||||
}
|
||||
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
|
||||
let local_var_key = local_var_apikey.key.clone();
|
||||
let local_var_value = match local_var_apikey.prefix {
|
||||
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
|
||||
None => local_var_key,
|
||||
};
|
||||
local_var_req_builder = local_var_req_builder.header("api_key", local_var_value);
|
||||
};
|
||||
local_var_req_builder = local_var_req_builder.json(&user);
|
||||
|
||||
let local_var_req = local_var_req_builder.build()?;
|
||||
let mut local_var_resp = local_var_client.execute(local_var_req)?;
|
||||
|
||||
let local_var_status = local_var_resp.status();
|
||||
let local_var_content = local_var_resp.text()?;
|
||||
|
||||
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
||||
Ok(())
|
||||
} else {
|
||||
let local_var_entity: Option<CreateUsersWithListInputError> = serde_json::from_str(&local_var_content).ok();
|
||||
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
||||
Err(Error::ResponseError(local_var_error))
|
||||
}
|
||||
}
|
||||
|
||||
/// This can only be done by the logged in user.
|
||||
pub fn delete_user(configuration: &configuration::Configuration, username: &str) -> Result<(), Error<DeleteUserError>> {
|
||||
let local_var_configuration = configuration;
|
||||
|
||||
let local_var_client = &local_var_configuration.client;
|
||||
|
||||
let local_var_uri_str = format!("{}/user/{username}", local_var_configuration.base_path, username=crate::apis::urlencode(username));
|
||||
let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
|
||||
|
||||
if let Some(ref local_var_aws_v4_key) = local_var_configuration.aws_v4_key {
|
||||
let local_var_new_headers = match local_var_aws_v4_key.sign(
|
||||
&local_var_uri_str,
|
||||
"DELETE",
|
||||
&"",
|
||||
) {
|
||||
Ok(new_headers) => new_headers,
|
||||
Err(err) => return Err(Error::AWSV4SignatureError(err)),
|
||||
};
|
||||
for (local_var_name, local_var_value) in local_var_new_headers.iter() {
|
||||
local_var_req_builder = local_var_req_builder.header(local_var_name.as_str(), local_var_value.as_str());
|
||||
}
|
||||
}
|
||||
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
|
||||
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
|
||||
}
|
||||
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
|
||||
let local_var_key = local_var_apikey.key.clone();
|
||||
let local_var_value = match local_var_apikey.prefix {
|
||||
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
|
||||
None => local_var_key,
|
||||
};
|
||||
local_var_req_builder = local_var_req_builder.header("api_key", local_var_value);
|
||||
};
|
||||
|
||||
let local_var_req = local_var_req_builder.build()?;
|
||||
let mut local_var_resp = local_var_client.execute(local_var_req)?;
|
||||
|
||||
let local_var_status = local_var_resp.status();
|
||||
let local_var_content = local_var_resp.text()?;
|
||||
|
||||
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
||||
Ok(())
|
||||
} else {
|
||||
let local_var_entity: Option<DeleteUserError> = serde_json::from_str(&local_var_content).ok();
|
||||
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
||||
Err(Error::ResponseError(local_var_error))
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
pub fn get_user_by_name(configuration: &configuration::Configuration, username: &str) -> Result<crate::models::User, Error<GetUserByNameError>> {
|
||||
let local_var_configuration = configuration;
|
||||
|
||||
let local_var_client = &local_var_configuration.client;
|
||||
|
||||
let local_var_uri_str = format!("{}/user/{username}", local_var_configuration.base_path, username=crate::apis::urlencode(username));
|
||||
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
|
||||
|
||||
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
|
||||
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
|
||||
}
|
||||
|
||||
let local_var_req = local_var_req_builder.build()?;
|
||||
let mut local_var_resp = local_var_client.execute(local_var_req)?;
|
||||
|
||||
let local_var_status = local_var_resp.status();
|
||||
let local_var_content = local_var_resp.text()?;
|
||||
|
||||
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
||||
serde_json::from_str(&local_var_content).map_err(Error::from)
|
||||
} else {
|
||||
let local_var_entity: Option<GetUserByNameError> = serde_json::from_str(&local_var_content).ok();
|
||||
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
||||
Err(Error::ResponseError(local_var_error))
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
pub fn login_user(configuration: &configuration::Configuration, username: &str, password: &str) -> Result<String, Error<LoginUserError>> {
|
||||
let local_var_configuration = configuration;
|
||||
|
||||
let local_var_client = &local_var_configuration.client;
|
||||
|
||||
let local_var_uri_str = format!("{}/user/login", local_var_configuration.base_path);
|
||||
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
|
||||
|
||||
local_var_req_builder = local_var_req_builder.query(&[("username", &username.to_string())]);
|
||||
local_var_req_builder = local_var_req_builder.query(&[("password", &password.to_string())]);
|
||||
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
|
||||
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
|
||||
}
|
||||
|
||||
let local_var_req = local_var_req_builder.build()?;
|
||||
let mut local_var_resp = local_var_client.execute(local_var_req)?;
|
||||
|
||||
let local_var_status = local_var_resp.status();
|
||||
let local_var_content = local_var_resp.text()?;
|
||||
|
||||
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
||||
serde_json::from_str(&local_var_content).map_err(Error::from)
|
||||
} else {
|
||||
let local_var_entity: Option<LoginUserError> = serde_json::from_str(&local_var_content).ok();
|
||||
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
||||
Err(Error::ResponseError(local_var_error))
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
pub fn logout_user(configuration: &configuration::Configuration, ) -> Result<(), Error<LogoutUserError>> {
|
||||
let local_var_configuration = configuration;
|
||||
|
||||
let local_var_client = &local_var_configuration.client;
|
||||
|
||||
let local_var_uri_str = format!("{}/user/logout", local_var_configuration.base_path);
|
||||
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
|
||||
|
||||
if let Some(ref local_var_aws_v4_key) = local_var_configuration.aws_v4_key {
|
||||
let local_var_new_headers = match local_var_aws_v4_key.sign(
|
||||
&local_var_uri_str,
|
||||
"GET",
|
||||
&"",
|
||||
) {
|
||||
Ok(new_headers) => new_headers,
|
||||
Err(err) => return Err(Error::AWSV4SignatureError(err)),
|
||||
};
|
||||
for (local_var_name, local_var_value) in local_var_new_headers.iter() {
|
||||
local_var_req_builder = local_var_req_builder.header(local_var_name.as_str(), local_var_value.as_str());
|
||||
}
|
||||
}
|
||||
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
|
||||
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
|
||||
}
|
||||
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
|
||||
let local_var_key = local_var_apikey.key.clone();
|
||||
let local_var_value = match local_var_apikey.prefix {
|
||||
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
|
||||
None => local_var_key,
|
||||
};
|
||||
local_var_req_builder = local_var_req_builder.header("api_key", local_var_value);
|
||||
};
|
||||
|
||||
let local_var_req = local_var_req_builder.build()?;
|
||||
let mut local_var_resp = local_var_client.execute(local_var_req)?;
|
||||
|
||||
let local_var_status = local_var_resp.status();
|
||||
let local_var_content = local_var_resp.text()?;
|
||||
|
||||
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
||||
Ok(())
|
||||
} else {
|
||||
let local_var_entity: Option<LogoutUserError> = serde_json::from_str(&local_var_content).ok();
|
||||
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
||||
Err(Error::ResponseError(local_var_error))
|
||||
}
|
||||
}
|
||||
|
||||
/// This can only be done by the logged in user.
|
||||
pub fn update_user(configuration: &configuration::Configuration, username: &str, user: crate::models::User) -> Result<(), Error<UpdateUserError>> {
|
||||
let local_var_configuration = configuration;
|
||||
|
||||
let local_var_client = &local_var_configuration.client;
|
||||
|
||||
let local_var_uri_str = format!("{}/user/{username}", local_var_configuration.base_path, username=crate::apis::urlencode(username));
|
||||
let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
|
||||
|
||||
if let Some(ref local_var_aws_v4_key) = local_var_configuration.aws_v4_key {
|
||||
let local_var_new_headers = match local_var_aws_v4_key.sign(
|
||||
&local_var_uri_str,
|
||||
"PUT",
|
||||
&serde_json::to_string(&user).expect("param should serialize to string"),
|
||||
) {
|
||||
Ok(new_headers) => new_headers,
|
||||
Err(err) => return Err(Error::AWSV4SignatureError(err)),
|
||||
};
|
||||
for (local_var_name, local_var_value) in local_var_new_headers.iter() {
|
||||
local_var_req_builder = local_var_req_builder.header(local_var_name.as_str(), local_var_value.as_str());
|
||||
}
|
||||
}
|
||||
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
|
||||
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
|
||||
}
|
||||
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
|
||||
let local_var_key = local_var_apikey.key.clone();
|
||||
let local_var_value = match local_var_apikey.prefix {
|
||||
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
|
||||
None => local_var_key,
|
||||
};
|
||||
local_var_req_builder = local_var_req_builder.header("api_key", local_var_value);
|
||||
};
|
||||
local_var_req_builder = local_var_req_builder.json(&user);
|
||||
|
||||
let local_var_req = local_var_req_builder.build()?;
|
||||
let mut local_var_resp = local_var_client.execute(local_var_req)?;
|
||||
|
||||
let local_var_status = local_var_resp.status();
|
||||
let local_var_content = local_var_resp.text()?;
|
||||
|
||||
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
||||
Ok(())
|
||||
} else {
|
||||
let local_var_entity: Option<UpdateUserError> = serde_json::from_str(&local_var_content).ok();
|
||||
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
||||
Err(Error::ResponseError(local_var_error))
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
#[macro_use]
|
||||
extern crate serde_derive;
|
||||
|
||||
extern crate serde;
|
||||
extern crate serde_json;
|
||||
extern crate url;
|
||||
extern crate reqwest;
|
||||
|
||||
pub mod apis;
|
||||
pub mod models;
|
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
/// ApiResponse : Describes the result of uploading an image resource
|
||||
|
||||
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
|
||||
pub struct ApiResponse {
|
||||
#[serde(rename = "code", skip_serializing_if = "Option::is_none")]
|
||||
pub code: Option<i32>,
|
||||
#[serde(rename = "type", skip_serializing_if = "Option::is_none")]
|
||||
pub _type: Option<String>,
|
||||
#[serde(rename = "message", skip_serializing_if = "Option::is_none")]
|
||||
pub message: Option<String>,
|
||||
}
|
||||
|
||||
impl ApiResponse {
|
||||
/// Describes the result of uploading an image resource
|
||||
pub fn new() -> ApiResponse {
|
||||
ApiResponse {
|
||||
code: None,
|
||||
_type: None,
|
||||
message: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
/// Category : A category for a pet
|
||||
|
||||
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
|
||||
pub struct Category {
|
||||
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
|
||||
pub id: Option<i64>,
|
||||
#[serde(rename = "name", skip_serializing_if = "Option::is_none")]
|
||||
pub name: Option<String>,
|
||||
}
|
||||
|
||||
impl Category {
|
||||
/// A category for a pet
|
||||
pub fn new() -> Category {
|
||||
Category {
|
||||
id: None,
|
||||
name: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,12 @@
|
||||
pub mod api_response;
|
||||
pub use self::api_response::ApiResponse;
|
||||
pub mod category;
|
||||
pub use self::category::Category;
|
||||
pub mod order;
|
||||
pub use self::order::Order;
|
||||
pub mod pet;
|
||||
pub use self::pet::Pet;
|
||||
pub mod tag;
|
||||
pub use self::tag::Tag;
|
||||
pub mod user;
|
||||
pub use self::user::User;
|
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
/// Order : An order for a pets from the pet store
|
||||
|
||||
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
|
||||
pub struct Order {
|
||||
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
|
||||
pub id: Option<i64>,
|
||||
#[serde(rename = "petId", skip_serializing_if = "Option::is_none")]
|
||||
pub pet_id: Option<i64>,
|
||||
#[serde(rename = "quantity", skip_serializing_if = "Option::is_none")]
|
||||
pub quantity: Option<i32>,
|
||||
#[serde(rename = "shipDate", skip_serializing_if = "Option::is_none")]
|
||||
pub ship_date: Option<String>,
|
||||
/// Order Status
|
||||
#[serde(rename = "status", skip_serializing_if = "Option::is_none")]
|
||||
pub status: Option<Status>,
|
||||
#[serde(rename = "complete", skip_serializing_if = "Option::is_none")]
|
||||
pub complete: Option<bool>,
|
||||
}
|
||||
|
||||
impl Order {
|
||||
/// An order for a pets from the pet store
|
||||
pub fn new() -> Order {
|
||||
Order {
|
||||
id: None,
|
||||
pet_id: None,
|
||||
quantity: None,
|
||||
ship_date: None,
|
||||
status: None,
|
||||
complete: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Order Status
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
|
||||
pub enum Status {
|
||||
#[serde(rename = "placed")]
|
||||
Placed,
|
||||
#[serde(rename = "approved")]
|
||||
Approved,
|
||||
#[serde(rename = "delivered")]
|
||||
Delivered,
|
||||
}
|
||||
|
||||
impl Default for Status {
|
||||
fn default() -> Status {
|
||||
Self::Placed
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
/// Pet : A pet for sale in the pet store
|
||||
|
||||
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
|
||||
pub struct Pet {
|
||||
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
|
||||
pub id: Option<i64>,
|
||||
#[serde(rename = "category", skip_serializing_if = "Option::is_none")]
|
||||
pub category: Option<Box<crate::models::Category>>,
|
||||
#[serde(rename = "name")]
|
||||
pub name: String,
|
||||
#[serde(rename = "photoUrls")]
|
||||
pub photo_urls: Vec<String>,
|
||||
#[serde(rename = "tags", skip_serializing_if = "Option::is_none")]
|
||||
pub tags: Option<Vec<crate::models::Tag>>,
|
||||
/// pet status in the store
|
||||
#[serde(rename = "status", skip_serializing_if = "Option::is_none")]
|
||||
pub status: Option<Status>,
|
||||
}
|
||||
|
||||
impl Pet {
|
||||
/// A pet for sale in the pet store
|
||||
pub fn new(name: String, photo_urls: Vec<String>) -> Pet {
|
||||
Pet {
|
||||
id: None,
|
||||
category: None,
|
||||
name,
|
||||
photo_urls,
|
||||
tags: None,
|
||||
status: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// pet status in the store
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
|
||||
pub enum Status {
|
||||
#[serde(rename = "available")]
|
||||
Available,
|
||||
#[serde(rename = "pending")]
|
||||
Pending,
|
||||
#[serde(rename = "sold")]
|
||||
Sold,
|
||||
}
|
||||
|
||||
impl Default for Status {
|
||||
fn default() -> Status {
|
||||
Self::Available
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
/// Tag : A tag for a pet
|
||||
|
||||
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
|
||||
pub struct Tag {
|
||||
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
|
||||
pub id: Option<i64>,
|
||||
#[serde(rename = "name", skip_serializing_if = "Option::is_none")]
|
||||
pub name: Option<String>,
|
||||
}
|
||||
|
||||
impl Tag {
|
||||
/// A tag for a pet
|
||||
pub fn new() -> Tag {
|
||||
Tag {
|
||||
id: None,
|
||||
name: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
/// User : A User who is purchasing from the pet store
|
||||
|
||||
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
|
||||
pub struct User {
|
||||
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
|
||||
pub id: Option<i64>,
|
||||
#[serde(rename = "username", skip_serializing_if = "Option::is_none")]
|
||||
pub username: Option<String>,
|
||||
#[serde(rename = "firstName", skip_serializing_if = "Option::is_none")]
|
||||
pub first_name: Option<String>,
|
||||
#[serde(rename = "lastName", skip_serializing_if = "Option::is_none")]
|
||||
pub last_name: Option<String>,
|
||||
#[serde(rename = "email", skip_serializing_if = "Option::is_none")]
|
||||
pub email: Option<String>,
|
||||
#[serde(rename = "password", skip_serializing_if = "Option::is_none")]
|
||||
pub password: Option<String>,
|
||||
#[serde(rename = "phone", skip_serializing_if = "Option::is_none")]
|
||||
pub phone: Option<String>,
|
||||
/// User Status
|
||||
#[serde(rename = "userStatus", skip_serializing_if = "Option::is_none")]
|
||||
pub user_status: Option<i32>,
|
||||
}
|
||||
|
||||
impl User {
|
||||
/// A User who is purchasing from the pet store
|
||||
pub fn new() -> User {
|
||||
User {
|
||||
id: None,
|
||||
username: None,
|
||||
first_name: None,
|
||||
last_name: None,
|
||||
email: None,
|
||||
password: None,
|
||||
phone: None,
|
||||
user_status: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
use reqwest;
|
||||
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Configuration {
|
||||
pub base_path: String,
|
||||
@ -31,6 +32,7 @@ pub struct ApiKey {
|
||||
pub key: String,
|
||||
}
|
||||
|
||||
|
||||
impl Configuration {
|
||||
pub fn new() -> Configuration {
|
||||
Configuration::default()
|
||||
@ -47,6 +49,7 @@ impl Default for Configuration {
|
||||
oauth_access_token: None,
|
||||
bearer_access_token: None,
|
||||
api_key: None,
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user