[BugFix] [Rust*] model-name-prefix causing invalid generated code (#19922)

* [BugFix] [Rust*] model-name-prefix causing invalid generated code]

* Update

* Fix

* Update

* Update
This commit is contained in:
Linh Tran Tuan 2024-10-21 19:10:16 +09:00 committed by GitHub
parent 266193f95f
commit 52610e026e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
64 changed files with 3374 additions and 157 deletions

View File

@ -6,6 +6,7 @@ generateAliasAsModel: true
additionalProperties:
hideGenerationTimestamp: "true"
packageName: rust-server-test
modelNamePrefix: "Foo"
globalProperties:
skipFormModel: false
enablePostProcessFile: true

View File

@ -0,0 +1,11 @@
generatorName: rust
outputDir: samples/client/petstore/rust/reqwest/petstore-model-name-prefix
library: reqwest
inputSpec: modules/openapi-generator/src/test/resources/3_0/rust/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/rust
additionalProperties:
supportAsync: false
packageName: petstore-reqwest-model-name-prefix
modelNamePrefix: "Foo"
enumNameMappings:
delivered: shipped

View File

@ -245,8 +245,7 @@ public abstract class AbstractRustCodegen extends DefaultCodegen implements Code
} else if (!org.apache.commons.lang3.StringUtils.isEmpty(p.get$ref())) {
String datatype;
try {
datatype = toModelName(ModelUtils.getSimpleRef(p.get$ref()));
datatype = "models::" + toModelName(datatype);
datatype = "models::" + toModelName(ModelUtils.getSimpleRef(p.get$ref()));
} catch (Exception e) {
LOGGER.warn("Error obtaining the datatype from schema (model):{}. Datatype default to Object", p);
datatype = "Object";
@ -438,6 +437,6 @@ public abstract class AbstractRustCodegen extends DefaultCodegen implements Code
if (this.reservedWordsMappings().containsKey(name)) {
return this.reservedWordsMappings().get(name);
}
return "r#"+ name;
return "r#" + name;
}
}

View File

@ -0,0 +1,3 @@
/target/
**/*.rs.bk
Cargo.lock

View File

@ -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

View File

@ -0,0 +1,55 @@
.gitignore
.travis.yml
Cargo.toml
README.md
docs/FakeApi.md
docs/FooActionContainer.md
docs/FooApiResponse.md
docs/FooArrayItemRefTest.md
docs/FooBaz.md
docs/FooCategory.md
docs/FooEnumArrayTesting.md
docs/FooNullableArray.md
docs/FooNumericEnumTesting.md
docs/FooOptionalTesting.md
docs/FooOrder.md
docs/FooPet.md
docs/FooPropertyTest.md
docs/FooRef.md
docs/FooReturn.md
docs/FooTag.md
docs/FooTypeTesting.md
docs/FooUniqueItemArrayTesting.md
docs/FooUser.md
docs/PetApi.md
docs/StoreApi.md
docs/TestingApi.md
docs/UserApi.md
git_push.sh
src/apis/configuration.rs
src/apis/fake_api.rs
src/apis/mod.rs
src/apis/pet_api.rs
src/apis/store_api.rs
src/apis/testing_api.rs
src/apis/user_api.rs
src/lib.rs
src/models/foo_action_container.rs
src/models/foo_api_response.rs
src/models/foo_array_item_ref_test.rs
src/models/foo_baz.rs
src/models/foo_category.rs
src/models/foo_enum_array_testing.rs
src/models/foo_nullable_array.rs
src/models/foo_numeric_enum_testing.rs
src/models/foo_optional_testing.rs
src/models/foo_order.rs
src/models/foo_pet.rs
src/models/foo_property_test.rs
src/models/foo_ref.rs
src/models/foo_return.rs
src/models/foo_tag.rs
src/models/foo_type_testing.rs
src/models/foo_unique_item_array_testing.rs
src/models/foo_user.rs
src/models/mod.rs

View File

@ -0,0 +1 @@
language: rust

View File

@ -0,0 +1,16 @@
[package]
name = "petstore-reqwest-model-name-prefix"
version = "1.0.0"
authors = ["OpenAPI Generator team and contributors"]
description = "This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters."
license = "Apache-2.0"
edition = "2021"
[dependencies]
serde = { version = "^1.0", features = ["derive"] }
serde_with = { version = "^3.8", default-features = false, features = ["base64", "std", "macros"] }
serde_json = "^1.0"
serde_repr = "^0.1"
url = "^2.5"
uuid = { version = "^1.8", features = ["serde", "v4"] }
reqwest = { version = "^0.12", features = ["json", "blocking", "multipart"] }

View File

@ -0,0 +1,85 @@
# Rust API client for petstore-reqwest-model-name-prefix
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
- Generator version: 7.10.0-SNAPSHOT
- Build package: `org.openapitools.codegen.languages.RustClientCodegen`
## Installation
Put the package under your project folder in a directory named `petstore-reqwest-model-name-prefix` and add the following to `Cargo.toml` under `[dependencies]`:
```
petstore-reqwest-model-name-prefix = { path = "./petstore-reqwest-model-name-prefix" }
```
## Documentation for API Endpoints
All URIs are relative to *http://petstore.swagger.io/v2*
Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*FakeApi* | [**test_nullable_required_param**](docs/FakeApi.md#test_nullable_required_param) | **GET** /fake/user/{username} | To test nullable required parameters
*PetApi* | [**add_pet**](docs/PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store
*PetApi* | [**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
*TestingApi* | [**tests_file_response_get**](docs/TestingApi.md#tests_file_response_get) | **GET** /tests/fileResponse | Returns an image file
*TestingApi* | [**tests_type_testing_get**](docs/TestingApi.md#tests_type_testing_get) | **GET** /tests/typeTesting | Route to test the TypeTesting schema
*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
- [FooActionContainer](docs/FooActionContainer.md)
- [FooApiResponse](docs/FooApiResponse.md)
- [FooArrayItemRefTest](docs/FooArrayItemRefTest.md)
- [FooBaz](docs/FooBaz.md)
- [FooCategory](docs/FooCategory.md)
- [FooEnumArrayTesting](docs/FooEnumArrayTesting.md)
- [FooNullableArray](docs/FooNullableArray.md)
- [FooNumericEnumTesting](docs/FooNumericEnumTesting.md)
- [FooOptionalTesting](docs/FooOptionalTesting.md)
- [FooOrder](docs/FooOrder.md)
- [FooPet](docs/FooPet.md)
- [FooPropertyTest](docs/FooPropertyTest.md)
- [FooRef](docs/FooRef.md)
- [FooReturn](docs/FooReturn.md)
- [FooTag](docs/FooTag.md)
- [FooTypeTesting](docs/FooTypeTesting.md)
- [FooUniqueItemArrayTesting](docs/FooUniqueItemArrayTesting.md)
- [FooUser](docs/FooUser.md)
To get access to the crate's generated documentation, use:
```
cargo doc --open
```
## Author

View File

@ -0,0 +1,41 @@
# \FakeApi
All URIs are relative to *http://petstore.swagger.io/v2*
Method | HTTP request | Description
------------- | ------------- | -------------
[**test_nullable_required_param**](FakeApi.md#test_nullable_required_param) | **GET** /fake/user/{username} | To test nullable required parameters
## test_nullable_required_param
> test_nullable_required_param(username, dummy_required_nullable_param, uppercase)
To test nullable required parameters
### Parameters
Name | Type | Description | Required | Notes
------------- | ------------- | ------------- | ------------- | -------------
**username** | **String** | The name that needs to be fetched. Use user1 for testing. | [required] |
**dummy_required_nullable_param** | Option<**String**> | To test nullable required parameters | [required] |
**uppercase** | Option<**String**> | To test parameter names in upper case | |
### Return type
(empty response body)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: Not defined
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

View File

@ -0,0 +1,11 @@
# FooActionContainer
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**action** | [**models::FooBaz**](Baz.md) | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,13 @@
# FooApiResponse
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**code** | Option<**i32**> | | [optional]
**r#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)

View File

@ -0,0 +1,12 @@
# FooArrayItemRefTest
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**list_with_array_ref** | [**Vec<Vec<String>>**](Vec.md) | |
**list_with_object_ref** | [**Vec<std::collections::HashMap<String, serde_json::Value>>**](std::collections::HashMap.md) | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,14 @@
# FooBaz
## Enum Variants
| Name | Value |
|---- | -----|
| A | A |
| B | B |
| Empty | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,12 @@
# FooCategory
## 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)

View File

@ -0,0 +1,11 @@
# FooEnumArrayTesting
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**required_enums** | **Vec<String>** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,14 @@
# FooNullableArray
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**array_nullable** | Option<**Vec<String>**> | | [optional]
**just_array** | Option<**Vec<String>**> | | [optional]
**nullable_string** | Option<**String**> | | [optional]
**just_string** | 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)

View File

@ -0,0 +1,15 @@
# FooNumericEnumTesting
## Enum Variants
| Name | Value |
|---- | -----|
| Variant0 | 0 |
| Variant1 | 1 |
| Variant2 | 2 |
| Variant3 | 3 |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,14 @@
# FooOptionalTesting
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**optional_nonnull** | Option<**String**> | | [optional]
**required_nonnull** | **String** | |
**optional_nullable** | Option<**String**> | | [optional]
**required_nullable** | Option<**String**> | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,16 @@
# FooOrder
## 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)

View File

@ -0,0 +1,16 @@
# FooPet
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | Option<**i64**> | | [optional]
**category** | Option<[**models::FooCategory**](Category.md)> | | [optional]
**name** | **String** | |
**photo_urls** | **Vec<String>** | |
**tags** | Option<[**Vec<models::FooTag>**](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)

View File

@ -0,0 +1,11 @@
# FooPropertyTest
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**uuid** | Option<[**uuid::Uuid**](uuid::Uuid.md)> | | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,11 @@
# FooRef
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**dummy** | 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)

View File

@ -0,0 +1,13 @@
# FooReturn
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**r#match** | Option<**i32**> | | [optional]
**r#async** | Option<**bool**> | | [optional]
**param_super** | Option<**bool**> | | [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)

View File

@ -0,0 +1,12 @@
# FooTag
## 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)

View File

@ -0,0 +1,18 @@
# FooTypeTesting
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**int32** | **i32** | |
**int64** | **i64** | |
**float** | **f32** | |
**double** | **f64** | |
**string** | **String** | |
**boolean** | **bool** | |
**uuid** | [**uuid::Uuid**](uuid::Uuid.md) | |
**bytes** | **String** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,11 @@
# FooUniqueItemArrayTesting
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**unique_item_array** | **Vec<String>** | Helper object for the unique item array test |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,18 @@
# FooUser
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | Option<**i64**> | | [optional]
**username** | **String** | |
**first_name** | Option<**String**> | | [optional]
**last_name** | **String** | |
**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)

View File

@ -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
> models::FooPet add_pet(foo_pet)
Add a new pet to the store
### Parameters
Name | Type | Description | Required | Notes
------------- | ------------- | ------------- | ------------- | -------------
**foo_pet** | [**FooPet**](FooPet.md) | Pet object that needs to be added to the store | [required] |
### Return type
[**models::FooPet**](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<models::FooPet> 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<models::FooPet>**](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<models::FooPet> 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<models::FooPet>**](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
> models::FooPet 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
[**models::FooPet**](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
> models::FooPet update_pet(foo_pet)
Update an existing pet
### Parameters
Name | Type | Description | Required | Notes
------------- | ------------- | ------------- | ------------- | -------------
**foo_pet** | [**FooPet**](FooPet.md) | Pet object that needs to be added to the store | [required] |
### Return type
[**models::FooPet**](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
> models::FooApiResponse 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
[**models::FooApiResponse**](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)

View File

@ -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
> models::FooOrder 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 generate exceptions
### Parameters
Name | Type | Description | Required | Notes
------------- | ------------- | ------------- | ------------- | -------------
**order_id** | **i64** | ID of pet that needs to be fetched | [required] |
### Return type
[**models::FooOrder**](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
> models::FooOrder place_order(foo_order)
Place an order for a pet
### Parameters
Name | Type | Description | Required | Notes
------------- | ------------- | ------------- | ------------- | -------------
**foo_order** | [**FooOrder**](FooOrder.md) | order placed for purchasing the pet | [required] |
### Return type
[**models::FooOrder**](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)

View File

@ -0,0 +1,60 @@
# \TestingApi
All URIs are relative to *http://petstore.swagger.io/v2*
Method | HTTP request | Description
------------- | ------------- | -------------
[**tests_file_response_get**](TestingApi.md#tests_file_response_get) | **GET** /tests/fileResponse | Returns an image file
[**tests_type_testing_get**](TestingApi.md#tests_type_testing_get) | **GET** /tests/typeTesting | Route to test the TypeTesting schema
## tests_file_response_get
> std::path::PathBuf tests_file_response_get()
Returns an image file
### Parameters
This endpoint does not need any parameter.
### Return type
[**std::path::PathBuf**](std::path::PathBuf.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: image/jpeg
[[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)
## tests_type_testing_get
> models::FooTypeTesting tests_type_testing_get()
Route to test the TypeTesting schema
### Parameters
This endpoint does not need any parameter.
### Return type
[**models::FooTypeTesting**](TypeTesting.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

View File

@ -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(foo_user)
Create user
This can only be done by the logged in user.
### Parameters
Name | Type | Description | Required | Notes
------------- | ------------- | ------------- | ------------- | -------------
**foo_user** | [**FooUser**](FooUser.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<models::FooUser>**](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<models::FooUser>**](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
> models::FooUser 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
[**models::FooUser**](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, foo_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] |
**foo_user** | [**FooUser**](FooUser.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)

View File

@ -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'

View File

@ -0,0 +1,51 @@
/*
* 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
*/
#[derive(Debug, Clone)]
pub struct Configuration {
pub base_path: String,
pub user_agent: Option<String>,
pub client: reqwest::blocking::Client,
pub basic_auth: Option<BasicAuth>,
pub oauth_access_token: Option<String>,
pub bearer_access_token: Option<String>,
pub api_key: Option<ApiKey>,
}
pub type BasicAuth = (String, Option<String>);
#[derive(Debug, Clone)]
pub struct ApiKey {
pub prefix: Option<String>,
pub key: String,
}
impl Configuration {
pub fn new() -> Configuration {
Configuration::default()
}
}
impl Default for Configuration {
fn default() -> Self {
Configuration {
base_path: "http://petstore.swagger.io/v2".to_owned(),
user_agent: Some("OpenAPI-Generator/1.0.0/rust".to_owned()),
client: reqwest::blocking::Client::new(),
basic_auth: None,
oauth_access_token: None,
bearer_access_token: None,
api_key: None,
}
}
}

View File

@ -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
*/
use reqwest;
use serde::{Deserialize, Serialize};
use crate::{apis::ResponseContent, models};
use super::{Error, configuration};
/// struct for typed errors of method [`test_nullable_required_param`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum TestNullableRequiredParamError {
Status400(),
Status404(),
UnknownValue(serde_json::Value),
}
///
pub fn test_nullable_required_param(configuration: &configuration::Configuration, username: &str, dummy_required_nullable_param: Option<&str>, uppercase: Option<&str>) -> Result<(), Error<TestNullableRequiredParamError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/fake/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());
}
match dummy_required_nullable_param {
Some(local_var_param_value) => { local_var_req_builder = local_var_req_builder.header("dummy_required_nullable_param", local_var_param_value.to_string()); },
None => { local_var_req_builder = local_var_req_builder.header("dummy_required_nullable_param", ""); },
}
if let Some(local_var_param_value) = uppercase {
local_var_req_builder = local_var_req_builder.header("UPPERCASE", local_var_param_value.to_string());
}
let local_var_req = local_var_req_builder.build()?;
let 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<TestNullableRequiredParamError> = 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))
}
}

View File

@ -0,0 +1,99 @@
use std::error;
use std::fmt;
#[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>),
}
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)),
};
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,
})
}
}
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 fn parse_deep_object(prefix: &str, value: &serde_json::Value) -> Vec<(String, String)> {
if let serde_json::Value::Object(object) = value {
let mut params = vec![];
for (key, value) in object {
match value {
serde_json::Value::Object(_) => params.append(&mut parse_deep_object(
&format!("{}[{}]", prefix, key),
value,
)),
serde_json::Value::Array(array) => {
for (i, value) in array.iter().enumerate() {
params.append(&mut parse_deep_object(
&format!("{}[{}][{}]", prefix, key, i),
value,
));
}
},
serde_json::Value::String(s) => params.push((format!("{}[{}]", prefix, key), s.clone())),
_ => params.push((format!("{}[{}]", prefix, key), value.to_string())),
}
}
return params;
}
unimplemented!("Only objects are supported with style=deepObject")
}
pub mod fake_api;
pub mod pet_api;
pub mod store_api;
pub mod testing_api;
pub mod user_api;
pub mod configuration;

View File

@ -0,0 +1,366 @@
/*
* 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 serde::{Deserialize, Serialize};
use crate::{apis::ResponseContent, models};
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, foo_pet: models::FooPet) -> Result<models::FooPet, 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_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(&foo_pet);
let local_var_req = local_var_req_builder.build()?;
let 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_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 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<models::FooPet>, 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.to_string())).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_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 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<models::FooPet>, 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.to_string())).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_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 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<models::FooPet, 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_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 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, foo_pet: models::FooPet) -> Result<models::FooPet, 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_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(&foo_pet);
let local_var_req = local_var_req_builder.build()?;
let 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_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 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<models::FooApiResponse, 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_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::blocking::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 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))
}
}

View File

@ -0,0 +1,172 @@
/*
* 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 serde::{Deserialize, Serialize};
use crate::{apis::ResponseContent, models};
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 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_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 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 generate exceptions
pub fn get_order_by_id(configuration: &configuration::Configuration, order_id: i64) -> Result<models::FooOrder, 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 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, foo_order: models::FooOrder) -> Result<models::FooOrder, 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(&foo_order);
let local_var_req = local_var_req_builder.build()?;
let 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))
}
}

View File

@ -0,0 +1,86 @@
/*
* 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 serde::{Deserialize, Serialize};
use crate::{apis::ResponseContent, models};
use super::{Error, configuration};
/// struct for typed errors of method [`tests_file_response_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum TestsFileResponseGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`tests_type_testing_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum TestsTypeTestingGetError {
UnknownValue(serde_json::Value),
}
pub fn tests_file_response_get(configuration: &configuration::Configuration, ) -> Result<std::path::PathBuf, Error<TestsFileResponseGetError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/tests/fileResponse", 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_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 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<TestsFileResponseGetError> = 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 tests_type_testing_get(configuration: &configuration::Configuration, ) -> Result<models::FooTypeTesting, Error<TestsTypeTestingGetError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/tests/typeTesting", 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_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 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<TestsTypeTestingGetError> = 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))
}
}

View File

@ -0,0 +1,363 @@
/*
* 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 serde::{Deserialize, Serialize};
use crate::{apis::ResponseContent, models};
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, foo_user: models::FooUser) -> 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_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(&foo_user);
let local_var_req = local_var_req_builder.build()?;
let 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<models::FooUser>) -> 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_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 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<models::FooUser>) -> 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_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 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_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 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<models::FooUser, 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 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 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_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 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, foo_user: models::FooUser) -> 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_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(&foo_user);
let local_var_req = local_var_req_builder.build()?;
let 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))
}
}

View File

@ -0,0 +1,11 @@
#![allow(unused_imports)]
#![allow(clippy::too_many_arguments)]
extern crate serde_repr;
extern crate serde;
extern crate serde_json;
extern crate url;
extern crate reqwest;
pub mod apis;
pub mod models;

View File

@ -0,0 +1,27 @@
/*
* 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 crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct FooActionContainer {
#[serde(rename = "action")]
pub action: Box<models::FooBaz>,
}
impl FooActionContainer {
pub fn new(action: models::FooBaz) -> FooActionContainer {
FooActionContainer {
action: Box::new(action),
}
}
}

View File

@ -0,0 +1,35 @@
/*
* 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 crate::models;
use serde::{Deserialize, Serialize};
/// FooApiResponse : Describes the result of uploading an image resource
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct FooApiResponse {
#[serde(rename = "code", skip_serializing_if = "Option::is_none")]
pub code: Option<i32>,
#[serde(rename = "type", skip_serializing_if = "Option::is_none")]
pub r#type: Option<String>,
#[serde(rename = "message", skip_serializing_if = "Option::is_none")]
pub message: Option<String>,
}
impl FooApiResponse {
/// Describes the result of uploading an image resource
pub fn new() -> FooApiResponse {
FooApiResponse {
code: None,
r#type: None,
message: None,
}
}
}

View File

@ -0,0 +1,32 @@
/*
* 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 crate::models;
use serde::{Deserialize, Serialize};
/// FooArrayItemRefTest : Test handling of object reference in arrays
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct FooArrayItemRefTest {
#[serde(rename = "list_with_array_ref")]
pub list_with_array_ref: Vec<Vec<String>>,
#[serde(rename = "list_with_object_ref")]
pub list_with_object_ref: Vec<std::collections::HashMap<String, serde_json::Value>>,
}
impl FooArrayItemRefTest {
/// Test handling of object reference in arrays
pub fn new(list_with_array_ref: Vec<Vec<String>>, list_with_object_ref: Vec<std::collections::HashMap<String, serde_json::Value>>) -> FooArrayItemRefTest {
FooArrayItemRefTest {
list_with_array_ref,
list_with_object_ref,
}
}
}

View File

@ -0,0 +1,42 @@
/*
* 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 crate::models;
use serde::{Deserialize, Serialize};
/// FooBaz : Test handling of empty variants
/// Test handling of empty variants
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum FooBaz {
#[serde(rename = "A")]
A,
#[serde(rename = "B")]
B,
#[serde(rename = "")]
Empty,
}
impl std::fmt::Display for FooBaz {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match self {
Self::A => write!(f, "A"),
Self::B => write!(f, "B"),
Self::Empty => write!(f, ""),
}
}
}
impl Default for FooBaz {
fn default() -> FooBaz {
Self::A
}
}

View File

@ -0,0 +1,32 @@
/*
* 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 crate::models;
use serde::{Deserialize, Serialize};
/// FooCategory : A category for a pet
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct FooCategory {
#[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 FooCategory {
/// A category for a pet
pub fn new() -> FooCategory {
FooCategory {
id: None,
name: None,
}
}
}

View File

@ -0,0 +1,45 @@
/*
* 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 crate::models;
use serde::{Deserialize, Serialize};
/// FooEnumArrayTesting : Test of enum array
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct FooEnumArrayTesting {
#[serde(rename = "required_enums")]
pub required_enums: Vec<RequiredEnums>,
}
impl FooEnumArrayTesting {
/// Test of enum array
pub fn new(required_enums: Vec<RequiredEnums>) -> FooEnumArrayTesting {
FooEnumArrayTesting {
required_enums,
}
}
}
///
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum RequiredEnums {
#[serde(rename = "A")]
A,
#[serde(rename = "B")]
B,
#[serde(rename = "C")]
C,
}
impl Default for RequiredEnums {
fn default() -> RequiredEnums {
Self::A
}
}

View File

@ -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
*/
use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct FooNullableArray {
#[serde(rename = "array_nullable", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub array_nullable: Option<Option<Vec<String>>>,
#[serde(rename = "just_array", skip_serializing_if = "Option::is_none")]
pub just_array: Option<Vec<String>>,
#[serde(rename = "nullable_string", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub nullable_string: Option<Option<String>>,
#[serde(rename = "just_string", skip_serializing_if = "Option::is_none")]
pub just_string: Option<String>,
}
impl FooNullableArray {
pub fn new() -> FooNullableArray {
FooNullableArray {
array_nullable: None,
just_array: None,
nullable_string: None,
just_string: None,
}
}
}

View File

@ -0,0 +1,42 @@
/*
* 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 crate::models;
use serde::{Deserialize, Serialize};
use serde_repr::{Serialize_repr,Deserialize_repr};
/// FooNumericEnumTesting : testing that numeric enums are converted correctly
/// testing that numeric enums are converted correctly
#[repr(i64)]
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize_repr, Deserialize_repr)]
pub enum FooNumericEnumTesting {
Variant0 = 0,
Variant1 = 1,
Variant2 = 2,
Variant3 = 3,
}
impl std::fmt::Display for FooNumericEnumTesting {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", match self {
Self::Variant0 => "0",
Self::Variant1 => "1",
Self::Variant2 => "2",
Self::Variant3 => "3",
})
}
}
impl Default for FooNumericEnumTesting {
fn default() -> FooNumericEnumTesting {
Self::Variant0
}
}

View File

@ -0,0 +1,38 @@
/*
* 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 crate::models;
use serde::{Deserialize, Serialize};
/// FooOptionalTesting : Test handling of optional and nullable fields
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct FooOptionalTesting {
#[serde(rename = "optional_nonnull", skip_serializing_if = "Option::is_none")]
pub optional_nonnull: Option<String>,
#[serde(rename = "required_nonnull")]
pub required_nonnull: String,
#[serde(rename = "optional_nullable", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub optional_nullable: Option<Option<String>>,
#[serde(rename = "required_nullable", deserialize_with = "Option::deserialize")]
pub required_nullable: Option<String>,
}
impl FooOptionalTesting {
/// Test handling of optional and nullable fields
pub fn new(required_nonnull: String, required_nullable: Option<String>) -> FooOptionalTesting {
FooOptionalTesting {
optional_nonnull: None,
required_nonnull,
optional_nullable: None,
required_nullable,
}
}
}

View File

@ -0,0 +1,61 @@
/*
* 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 crate::models;
use serde::{Deserialize, Serialize};
/// FooOrder : An order for a pets from the pet store
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct FooOrder {
#[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 FooOrder {
/// An order for a pets from the pet store
pub fn new() -> FooOrder {
FooOrder {
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")]
shipped,
}
impl Default for Status {
fn default() -> Status {
Self::Placed
}
}

View File

@ -0,0 +1,61 @@
/*
* 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 crate::models;
use serde::{Deserialize, Serialize};
/// FooPet : A pet for sale in the pet store
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct FooPet {
#[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<models::FooCategory>>,
#[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<models::FooTag>>,
/// pet status in the store
#[serde(rename = "status", skip_serializing_if = "Option::is_none")]
pub status: Option<Status>,
}
impl FooPet {
/// A pet for sale in the pet store
pub fn new(name: String, photo_urls: Vec<String>) -> FooPet {
FooPet {
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
}
}

View File

@ -0,0 +1,29 @@
/*
* 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 crate::models;
use serde::{Deserialize, Serialize};
/// FooPropertyTest : A model to test various formats, e.g. UUID
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct FooPropertyTest {
#[serde(rename = "uuid", skip_serializing_if = "Option::is_none")]
pub uuid: Option<uuid::Uuid>,
}
impl FooPropertyTest {
/// A model to test various formats, e.g. UUID
pub fn new() -> FooPropertyTest {
FooPropertyTest {
uuid: None,
}
}
}

View File

@ -0,0 +1,29 @@
/*
* 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 crate::models;
use serde::{Deserialize, Serialize};
/// FooRef : using reserved word as model name
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct FooRef {
#[serde(rename = "dummy", skip_serializing_if = "Option::is_none")]
pub dummy: Option<String>,
}
impl FooRef {
/// using reserved word as model name
pub fn new() -> FooRef {
FooRef {
dummy: None,
}
}
}

View File

@ -0,0 +1,35 @@
/*
* 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 crate::models;
use serde::{Deserialize, Serialize};
/// FooReturn : Test using keywords
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct FooReturn {
#[serde(rename = "match", skip_serializing_if = "Option::is_none")]
pub r#match: Option<i32>,
#[serde(rename = "async", skip_serializing_if = "Option::is_none")]
pub r#async: Option<bool>,
#[serde(rename = "super", skip_serializing_if = "Option::is_none")]
pub param_super: Option<bool>,
}
impl FooReturn {
/// Test using keywords
pub fn new() -> FooReturn {
FooReturn {
r#match: None,
r#async: None,
param_super: None,
}
}
}

View File

@ -0,0 +1,32 @@
/*
* 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 crate::models;
use serde::{Deserialize, Serialize};
/// FooTag : A tag for a pet
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct FooTag {
#[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 FooTag {
/// A tag for a pet
pub fn new() -> FooTag {
FooTag {
id: None,
name: None,
}
}
}

View File

@ -0,0 +1,54 @@
/*
* 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 crate::models;
use serde::{Deserialize, Serialize};
use serde_with::serde_as;
/// FooTypeTesting : Test handling of different field data types
#[serde_as]
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct FooTypeTesting {
#[serde(rename = "int32")]
pub int32: i32,
#[serde(rename = "int64")]
pub int64: i64,
#[serde(rename = "float")]
pub float: f32,
#[serde(rename = "double")]
pub double: f64,
#[serde(rename = "string")]
pub string: String,
#[serde(rename = "boolean")]
pub boolean: bool,
#[serde(rename = "uuid")]
pub uuid: uuid::Uuid,
#[serde_as(as = "serde_with::base64::Base64")]
#[serde(rename = "bytes")]
pub bytes: Vec<u8>,
}
impl FooTypeTesting {
/// Test handling of different field data types
pub fn new(int32: i32, int64: i64, float: f32, double: f64, string: String, boolean: bool, uuid: uuid::Uuid, bytes: Vec<u8>) -> FooTypeTesting {
FooTypeTesting {
int32,
int64,
float,
double,
string,
boolean,
uuid,
bytes,
}
}
}

View File

@ -0,0 +1,46 @@
/*
* 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 crate::models;
use serde::{Deserialize, Serialize};
/// FooUniqueItemArrayTesting : Test handling of enum array with unique items
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct FooUniqueItemArrayTesting {
/// Helper object for the unique item array test
#[serde(rename = "unique_item_array")]
pub unique_item_array: std::collections::HashSet<UniqueItemArray>,
}
impl FooUniqueItemArrayTesting {
/// Test handling of enum array with unique items
pub fn new(unique_item_array: std::collections::HashSet<UniqueItemArray>) -> FooUniqueItemArrayTesting {
FooUniqueItemArrayTesting {
unique_item_array,
}
}
}
/// Helper object for the unique item array test
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum UniqueItemArray {
#[serde(rename = "unique_item_1")]
Variant1,
#[serde(rename = "unique_item_2")]
Variant2,
#[serde(rename = "unique_item_3")]
Variant3,
}
impl Default for UniqueItemArray {
fn default() -> UniqueItemArray {
Self::Variant1
}
}

View File

@ -0,0 +1,51 @@
/*
* 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 crate::models;
use serde::{Deserialize, Serialize};
/// FooUser : A User who is purchasing from the pet store
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct FooUser {
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
pub id: Option<i64>,
#[serde(rename = "username")]
pub username: String,
#[serde(rename = "firstName", skip_serializing_if = "Option::is_none")]
pub first_name: Option<String>,
#[serde(rename = "lastName")]
pub last_name: 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 FooUser {
/// A User who is purchasing from the pet store
pub fn new(username: String, last_name: String) -> FooUser {
FooUser {
id: None,
username,
first_name: None,
last_name,
email: None,
password: None,
phone: None,
user_status: None,
}
}
}

View File

@ -0,0 +1,36 @@
pub mod foo_action_container;
pub use self::foo_action_container::FooActionContainer;
pub mod foo_api_response;
pub use self::foo_api_response::FooApiResponse;
pub mod foo_array_item_ref_test;
pub use self::foo_array_item_ref_test::FooArrayItemRefTest;
pub mod foo_baz;
pub use self::foo_baz::FooBaz;
pub mod foo_category;
pub use self::foo_category::FooCategory;
pub mod foo_enum_array_testing;
pub use self::foo_enum_array_testing::FooEnumArrayTesting;
pub mod foo_nullable_array;
pub use self::foo_nullable_array::FooNullableArray;
pub mod foo_numeric_enum_testing;
pub use self::foo_numeric_enum_testing::FooNumericEnumTesting;
pub mod foo_optional_testing;
pub use self::foo_optional_testing::FooOptionalTesting;
pub mod foo_order;
pub use self::foo_order::FooOrder;
pub mod foo_pet;
pub use self::foo_pet::FooPet;
pub mod foo_property_test;
pub use self::foo_property_test::FooPropertyTest;
pub mod foo_ref;
pub use self::foo_ref::FooRef;
pub mod foo_return;
pub use self::foo_return::FooReturn;
pub mod foo_tag;
pub use self::foo_tag::FooTag;
pub mod foo_type_testing;
pub use self::foo_type_testing::FooTypeTesting;
pub mod foo_unique_item_array_testing;
pub use self::foo_unique_item_array_testing::FooUniqueItemArrayTesting;
pub mod foo_user;
pub use self::foo_user::FooUser;

View File

@ -12,7 +12,7 @@ use crate::{models, types::*};
#[allow(clippy::large_enum_variant)]
pub enum AllOfGetResponse {
/// OK
Status200_OK(models::AllOfObject),
Status200_OK(models::FooAllOfObject),
}
#[derive(Debug, PartialEq, Serialize, Deserialize)]
@ -107,7 +107,7 @@ pub trait Default {
method: Method,
host: Host,
cookies: CookieJar,
body: models::DummyPutRequest,
body: models::FooDummyPutRequest,
) -> Result<DummyPutResponse, String>;
/// Get a file.

View File

@ -9,7 +9,7 @@ use crate::{models, types::*};
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct ANullableContainer {
pub struct FooANullableContainer {
#[serde(rename = "NullableThing")]
#[serde(deserialize_with = "deserialize_optional_nullable")]
#[serde(default = "default_optional_nullable")]
@ -20,20 +20,20 @@ pub struct ANullableContainer {
pub required_nullable_thing: Nullable<String>,
}
impl ANullableContainer {
impl FooANullableContainer {
#[allow(clippy::new_without_default, clippy::too_many_arguments)]
pub fn new(required_nullable_thing: Nullable<String>) -> ANullableContainer {
ANullableContainer {
pub fn new(required_nullable_thing: Nullable<String>) -> FooANullableContainer {
FooANullableContainer {
nullable_thing: None,
required_nullable_thing,
}
}
}
/// Converts the ANullableContainer value to the Query Parameters representation (style=form, explode=false)
/// Converts the FooANullableContainer value to the Query Parameters representation (style=form, explode=false)
/// specified in https://swagger.io/docs/specification/serialization/
/// Should be implemented in a serde serializer
impl std::fmt::Display for ANullableContainer {
impl std::fmt::Display for FooANullableContainer {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let params: Vec<Option<String>> = vec![
self.nullable_thing.as_ref().map(|nullable_thing| {
@ -61,10 +61,10 @@ impl std::fmt::Display for ANullableContainer {
}
}
/// Converts Query Parameters representation (style=form, explode=false) to a ANullableContainer value
/// Converts Query Parameters representation (style=form, explode=false) to a FooANullableContainer value
/// as specified in https://swagger.io/docs/specification/serialization/
/// Should be implemented in a serde deserializer
impl std::str::FromStr for ANullableContainer {
impl std::str::FromStr for FooANullableContainer {
type Err = String;
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
@ -87,7 +87,7 @@ impl std::str::FromStr for ANullableContainer {
Some(x) => x,
None => {
return std::result::Result::Err(
"Missing value while parsing ANullableContainer".to_string(),
"Missing value while parsing FooANullableContainer".to_string(),
)
}
};
@ -95,9 +95,9 @@ impl std::str::FromStr for ANullableContainer {
if let Some(key) = key_result {
#[allow(clippy::match_single_binding)]
match key {
"NullableThing" => return std::result::Result::Err("Parsing a nullable type in this style is not supported in ANullableContainer".to_string()),
"RequiredNullableThing" => return std::result::Result::Err("Parsing a nullable type in this style is not supported in ANullableContainer".to_string()),
_ => return std::result::Result::Err("Unexpected key while parsing ANullableContainer".to_string())
"NullableThing" => return std::result::Result::Err("Parsing a nullable type in this style is not supported in FooANullableContainer".to_string()),
"RequiredNullableThing" => return std::result::Result::Err("Parsing a nullable type in this style is not supported in FooANullableContainer".to_string()),
_ => return std::result::Result::Err("Unexpected key while parsing FooANullableContainer".to_string())
}
}
@ -106,31 +106,31 @@ impl std::str::FromStr for ANullableContainer {
}
// Use the intermediate representation to return the struct
std::result::Result::Ok(ANullableContainer {
std::result::Result::Ok(FooANullableContainer {
nullable_thing: std::result::Result::Err(
"Nullable types not supported in ANullableContainer".to_string(),
"Nullable types not supported in FooANullableContainer".to_string(),
)?,
required_nullable_thing: std::result::Result::Err(
"Nullable types not supported in ANullableContainer".to_string(),
"Nullable types not supported in FooANullableContainer".to_string(),
)?,
})
}
}
// Methods for converting between header::IntoHeaderValue<ANullableContainer> and HeaderValue
// Methods for converting between header::IntoHeaderValue<FooANullableContainer> and HeaderValue
#[cfg(feature = "server")]
impl std::convert::TryFrom<header::IntoHeaderValue<ANullableContainer>> for HeaderValue {
impl std::convert::TryFrom<header::IntoHeaderValue<FooANullableContainer>> for HeaderValue {
type Error = String;
fn try_from(
hdr_value: header::IntoHeaderValue<ANullableContainer>,
hdr_value: header::IntoHeaderValue<FooANullableContainer>,
) -> std::result::Result<Self, Self::Error> {
let hdr_value = hdr_value.to_string();
match HeaderValue::from_str(&hdr_value) {
std::result::Result::Ok(value) => std::result::Result::Ok(value),
std::result::Result::Err(e) => std::result::Result::Err(format!(
"Invalid header value for ANullableContainer - value: {} is invalid {}",
"Invalid header value for FooANullableContainer - value: {} is invalid {}",
hdr_value, e
)),
}
@ -138,18 +138,18 @@ impl std::convert::TryFrom<header::IntoHeaderValue<ANullableContainer>> for Head
}
#[cfg(feature = "server")]
impl std::convert::TryFrom<HeaderValue> for header::IntoHeaderValue<ANullableContainer> {
impl std::convert::TryFrom<HeaderValue> for header::IntoHeaderValue<FooANullableContainer> {
type Error = String;
fn try_from(hdr_value: HeaderValue) -> std::result::Result<Self, Self::Error> {
match hdr_value.to_str() {
std::result::Result::Ok(value) => {
match <ANullableContainer as std::str::FromStr>::from_str(value) {
match <FooANullableContainer as std::str::FromStr>::from_str(value) {
std::result::Result::Ok(value) => {
std::result::Result::Ok(header::IntoHeaderValue(value))
}
std::result::Result::Err(err) => std::result::Result::Err(format!(
"Unable to convert header value '{}' into ANullableContainer - {}",
"Unable to convert header value '{}' into FooANullableContainer - {}",
value, err
)),
}
@ -165,65 +165,69 @@ impl std::convert::TryFrom<HeaderValue> for header::IntoHeaderValue<ANullableCon
/// An additionalPropertiesObject
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct AdditionalPropertiesObject(std::collections::HashMap<String, String>);
pub struct FooAdditionalPropertiesObject(std::collections::HashMap<String, String>);
impl validator::Validate for AdditionalPropertiesObject {
impl validator::Validate for FooAdditionalPropertiesObject {
fn validate(&self) -> std::result::Result<(), validator::ValidationErrors> {
std::result::Result::Ok(())
}
}
impl std::convert::From<std::collections::HashMap<String, String>> for AdditionalPropertiesObject {
impl std::convert::From<std::collections::HashMap<String, String>>
for FooAdditionalPropertiesObject
{
fn from(x: std::collections::HashMap<String, String>) -> Self {
AdditionalPropertiesObject(x)
FooAdditionalPropertiesObject(x)
}
}
impl std::convert::From<AdditionalPropertiesObject> for std::collections::HashMap<String, String> {
fn from(x: AdditionalPropertiesObject) -> Self {
impl std::convert::From<FooAdditionalPropertiesObject>
for std::collections::HashMap<String, String>
{
fn from(x: FooAdditionalPropertiesObject) -> Self {
x.0
}
}
impl std::ops::Deref for AdditionalPropertiesObject {
impl std::ops::Deref for FooAdditionalPropertiesObject {
type Target = std::collections::HashMap<String, String>;
fn deref(&self) -> &std::collections::HashMap<String, String> {
&self.0
}
}
impl std::ops::DerefMut for AdditionalPropertiesObject {
impl std::ops::DerefMut for FooAdditionalPropertiesObject {
fn deref_mut(&mut self) -> &mut std::collections::HashMap<String, String> {
&mut self.0
}
}
/// Converts the AdditionalPropertiesObject value to the Query Parameters representation (style=form, explode=false)
/// Converts the FooAdditionalPropertiesObject value to the Query Parameters representation (style=form, explode=false)
/// specified in https://swagger.io/docs/specification/serialization/
/// Should be implemented in a serde serializer
impl std::fmt::Display for AdditionalPropertiesObject {
impl std::fmt::Display for FooAdditionalPropertiesObject {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
// Skipping additionalProperties in query parameter serialization
write!(f, "")
}
}
/// Converts Query Parameters representation (style=form, explode=false) to a AdditionalPropertiesObject value
/// Converts Query Parameters representation (style=form, explode=false) to a FooAdditionalPropertiesObject value
/// as specified in https://swagger.io/docs/specification/serialization/
/// Should be implemented in a serde deserializer
impl ::std::str::FromStr for AdditionalPropertiesObject {
impl ::std::str::FromStr for FooAdditionalPropertiesObject {
type Err = &'static str;
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
std::result::Result::Err(
"Parsing additionalProperties for AdditionalPropertiesObject is not supported",
"Parsing additionalProperties for FooAdditionalPropertiesObject is not supported",
)
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct AllOfObject {
pub struct FooAllOfObject {
#[serde(rename = "sampleProperty")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sample_property: Option<String>,
@ -233,20 +237,20 @@ pub struct AllOfObject {
pub sample_base_property: Option<String>,
}
impl AllOfObject {
impl FooAllOfObject {
#[allow(clippy::new_without_default, clippy::too_many_arguments)]
pub fn new() -> AllOfObject {
AllOfObject {
pub fn new() -> FooAllOfObject {
FooAllOfObject {
sample_property: None,
sample_base_property: None,
}
}
}
/// Converts the AllOfObject value to the Query Parameters representation (style=form, explode=false)
/// Converts the FooAllOfObject value to the Query Parameters representation (style=form, explode=false)
/// specified in https://swagger.io/docs/specification/serialization/
/// Should be implemented in a serde serializer
impl std::fmt::Display for AllOfObject {
impl std::fmt::Display for FooAllOfObject {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let params: Vec<Option<String>> = vec![
self.sample_property.as_ref().map(|sample_property| {
@ -271,10 +275,10 @@ impl std::fmt::Display for AllOfObject {
}
}
/// Converts Query Parameters representation (style=form, explode=false) to a AllOfObject value
/// Converts Query Parameters representation (style=form, explode=false) to a FooAllOfObject value
/// as specified in https://swagger.io/docs/specification/serialization/
/// Should be implemented in a serde deserializer
impl std::str::FromStr for AllOfObject {
impl std::str::FromStr for FooAllOfObject {
type Err = String;
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
@ -297,7 +301,7 @@ impl std::str::FromStr for AllOfObject {
Some(x) => x,
None => {
return std::result::Result::Err(
"Missing value while parsing AllOfObject".to_string(),
"Missing value while parsing FooAllOfObject".to_string(),
)
}
};
@ -315,7 +319,7 @@ impl std::str::FromStr for AllOfObject {
),
_ => {
return std::result::Result::Err(
"Unexpected key while parsing AllOfObject".to_string(),
"Unexpected key while parsing FooAllOfObject".to_string(),
)
}
}
@ -326,27 +330,27 @@ impl std::str::FromStr for AllOfObject {
}
// Use the intermediate representation to return the struct
std::result::Result::Ok(AllOfObject {
std::result::Result::Ok(FooAllOfObject {
sample_property: intermediate_rep.sample_property.into_iter().next(),
sample_base_property: intermediate_rep.sample_base_property.into_iter().next(),
})
}
}
// Methods for converting between header::IntoHeaderValue<AllOfObject> and HeaderValue
// Methods for converting between header::IntoHeaderValue<FooAllOfObject> and HeaderValue
#[cfg(feature = "server")]
impl std::convert::TryFrom<header::IntoHeaderValue<AllOfObject>> for HeaderValue {
impl std::convert::TryFrom<header::IntoHeaderValue<FooAllOfObject>> for HeaderValue {
type Error = String;
fn try_from(
hdr_value: header::IntoHeaderValue<AllOfObject>,
hdr_value: header::IntoHeaderValue<FooAllOfObject>,
) -> std::result::Result<Self, Self::Error> {
let hdr_value = hdr_value.to_string();
match HeaderValue::from_str(&hdr_value) {
std::result::Result::Ok(value) => std::result::Result::Ok(value),
std::result::Result::Err(e) => std::result::Result::Err(format!(
"Invalid header value for AllOfObject - value: {} is invalid {}",
"Invalid header value for FooAllOfObject - value: {} is invalid {}",
hdr_value, e
)),
}
@ -354,18 +358,18 @@ impl std::convert::TryFrom<header::IntoHeaderValue<AllOfObject>> for HeaderValue
}
#[cfg(feature = "server")]
impl std::convert::TryFrom<HeaderValue> for header::IntoHeaderValue<AllOfObject> {
impl std::convert::TryFrom<HeaderValue> for header::IntoHeaderValue<FooAllOfObject> {
type Error = String;
fn try_from(hdr_value: HeaderValue) -> std::result::Result<Self, Self::Error> {
match hdr_value.to_str() {
std::result::Result::Ok(value) => {
match <AllOfObject as std::str::FromStr>::from_str(value) {
match <FooAllOfObject as std::str::FromStr>::from_str(value) {
std::result::Result::Ok(value) => {
std::result::Result::Ok(header::IntoHeaderValue(value))
}
std::result::Result::Err(err) => std::result::Result::Err(format!(
"Unable to convert header value '{}' into AllOfObject - {}",
"Unable to convert header value '{}' into FooAllOfObject - {}",
value, err
)),
}
@ -380,25 +384,25 @@ impl std::convert::TryFrom<HeaderValue> for header::IntoHeaderValue<AllOfObject>
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct BaseAllOf {
pub struct FooBaseAllOf {
#[serde(rename = "sampleBaseProperty")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sample_base_property: Option<String>,
}
impl BaseAllOf {
impl FooBaseAllOf {
#[allow(clippy::new_without_default, clippy::too_many_arguments)]
pub fn new() -> BaseAllOf {
BaseAllOf {
pub fn new() -> FooBaseAllOf {
FooBaseAllOf {
sample_base_property: None,
}
}
}
/// Converts the BaseAllOf value to the Query Parameters representation (style=form, explode=false)
/// Converts the FooBaseAllOf value to the Query Parameters representation (style=form, explode=false)
/// specified in https://swagger.io/docs/specification/serialization/
/// Should be implemented in a serde serializer
impl std::fmt::Display for BaseAllOf {
impl std::fmt::Display for FooBaseAllOf {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let params: Vec<Option<String>> =
vec![self
@ -420,10 +424,10 @@ impl std::fmt::Display for BaseAllOf {
}
}
/// Converts Query Parameters representation (style=form, explode=false) to a BaseAllOf value
/// Converts Query Parameters representation (style=form, explode=false) to a FooBaseAllOf value
/// as specified in https://swagger.io/docs/specification/serialization/
/// Should be implemented in a serde deserializer
impl std::str::FromStr for BaseAllOf {
impl std::str::FromStr for FooBaseAllOf {
type Err = String;
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
@ -445,7 +449,7 @@ impl std::str::FromStr for BaseAllOf {
Some(x) => x,
None => {
return std::result::Result::Err(
"Missing value while parsing BaseAllOf".to_string(),
"Missing value while parsing FooBaseAllOf".to_string(),
)
}
};
@ -459,7 +463,7 @@ impl std::str::FromStr for BaseAllOf {
),
_ => {
return std::result::Result::Err(
"Unexpected key while parsing BaseAllOf".to_string(),
"Unexpected key while parsing FooBaseAllOf".to_string(),
)
}
}
@ -470,26 +474,26 @@ impl std::str::FromStr for BaseAllOf {
}
// Use the intermediate representation to return the struct
std::result::Result::Ok(BaseAllOf {
std::result::Result::Ok(FooBaseAllOf {
sample_base_property: intermediate_rep.sample_base_property.into_iter().next(),
})
}
}
// Methods for converting between header::IntoHeaderValue<BaseAllOf> and HeaderValue
// Methods for converting between header::IntoHeaderValue<FooBaseAllOf> and HeaderValue
#[cfg(feature = "server")]
impl std::convert::TryFrom<header::IntoHeaderValue<BaseAllOf>> for HeaderValue {
impl std::convert::TryFrom<header::IntoHeaderValue<FooBaseAllOf>> for HeaderValue {
type Error = String;
fn try_from(
hdr_value: header::IntoHeaderValue<BaseAllOf>,
hdr_value: header::IntoHeaderValue<FooBaseAllOf>,
) -> std::result::Result<Self, Self::Error> {
let hdr_value = hdr_value.to_string();
match HeaderValue::from_str(&hdr_value) {
std::result::Result::Ok(value) => std::result::Result::Ok(value),
std::result::Result::Err(e) => std::result::Result::Err(format!(
"Invalid header value for BaseAllOf - value: {} is invalid {}",
"Invalid header value for FooBaseAllOf - value: {} is invalid {}",
hdr_value, e
)),
}
@ -497,18 +501,18 @@ impl std::convert::TryFrom<header::IntoHeaderValue<BaseAllOf>> for HeaderValue {
}
#[cfg(feature = "server")]
impl std::convert::TryFrom<HeaderValue> for header::IntoHeaderValue<BaseAllOf> {
impl std::convert::TryFrom<HeaderValue> for header::IntoHeaderValue<FooBaseAllOf> {
type Error = String;
fn try_from(hdr_value: HeaderValue) -> std::result::Result<Self, Self::Error> {
match hdr_value.to_str() {
std::result::Result::Ok(value) => {
match <BaseAllOf as std::str::FromStr>::from_str(value) {
match <FooBaseAllOf as std::str::FromStr>::from_str(value) {
std::result::Result::Ok(value) => {
std::result::Result::Ok(header::IntoHeaderValue(value))
}
std::result::Result::Err(err) => std::result::Result::Err(format!(
"Unable to convert header value '{}' into BaseAllOf - {}",
"Unable to convert header value '{}' into FooBaseAllOf - {}",
value, err
)),
}
@ -523,7 +527,7 @@ impl std::convert::TryFrom<HeaderValue> for header::IntoHeaderValue<BaseAllOf> {
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct DummyPutRequest {
pub struct FooDummyPutRequest {
#[serde(rename = "id")]
pub id: String,
@ -532,17 +536,17 @@ pub struct DummyPutRequest {
pub password: Option<String>,
}
impl DummyPutRequest {
impl FooDummyPutRequest {
#[allow(clippy::new_without_default, clippy::too_many_arguments)]
pub fn new(id: String) -> DummyPutRequest {
DummyPutRequest { id, password: None }
pub fn new(id: String) -> FooDummyPutRequest {
FooDummyPutRequest { id, password: None }
}
}
/// Converts the DummyPutRequest value to the Query Parameters representation (style=form, explode=false)
/// Converts the FooDummyPutRequest value to the Query Parameters representation (style=form, explode=false)
/// specified in https://swagger.io/docs/specification/serialization/
/// Should be implemented in a serde serializer
impl std::fmt::Display for DummyPutRequest {
impl std::fmt::Display for FooDummyPutRequest {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let params: Vec<Option<String>> = vec![
Some("id".to_string()),
@ -560,10 +564,10 @@ impl std::fmt::Display for DummyPutRequest {
}
}
/// Converts Query Parameters representation (style=form, explode=false) to a DummyPutRequest value
/// Converts Query Parameters representation (style=form, explode=false) to a FooDummyPutRequest value
/// as specified in https://swagger.io/docs/specification/serialization/
/// Should be implemented in a serde deserializer
impl std::str::FromStr for DummyPutRequest {
impl std::str::FromStr for FooDummyPutRequest {
type Err = String;
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
@ -586,7 +590,7 @@ impl std::str::FromStr for DummyPutRequest {
Some(x) => x,
None => {
return std::result::Result::Err(
"Missing value while parsing DummyPutRequest".to_string(),
"Missing value while parsing FooDummyPutRequest".to_string(),
)
}
};
@ -604,7 +608,7 @@ impl std::str::FromStr for DummyPutRequest {
),
_ => {
return std::result::Result::Err(
"Unexpected key while parsing DummyPutRequest".to_string(),
"Unexpected key while parsing FooDummyPutRequest".to_string(),
)
}
}
@ -615,31 +619,31 @@ impl std::str::FromStr for DummyPutRequest {
}
// Use the intermediate representation to return the struct
std::result::Result::Ok(DummyPutRequest {
std::result::Result::Ok(FooDummyPutRequest {
id: intermediate_rep
.id
.into_iter()
.next()
.ok_or_else(|| "id missing in DummyPutRequest".to_string())?,
.ok_or_else(|| "id missing in FooDummyPutRequest".to_string())?,
password: intermediate_rep.password.into_iter().next(),
})
}
}
// Methods for converting between header::IntoHeaderValue<DummyPutRequest> and HeaderValue
// Methods for converting between header::IntoHeaderValue<FooDummyPutRequest> and HeaderValue
#[cfg(feature = "server")]
impl std::convert::TryFrom<header::IntoHeaderValue<DummyPutRequest>> for HeaderValue {
impl std::convert::TryFrom<header::IntoHeaderValue<FooDummyPutRequest>> for HeaderValue {
type Error = String;
fn try_from(
hdr_value: header::IntoHeaderValue<DummyPutRequest>,
hdr_value: header::IntoHeaderValue<FooDummyPutRequest>,
) -> std::result::Result<Self, Self::Error> {
let hdr_value = hdr_value.to_string();
match HeaderValue::from_str(&hdr_value) {
std::result::Result::Ok(value) => std::result::Result::Ok(value),
std::result::Result::Err(e) => std::result::Result::Err(format!(
"Invalid header value for DummyPutRequest - value: {} is invalid {}",
"Invalid header value for FooDummyPutRequest - value: {} is invalid {}",
hdr_value, e
)),
}
@ -647,18 +651,18 @@ impl std::convert::TryFrom<header::IntoHeaderValue<DummyPutRequest>> for HeaderV
}
#[cfg(feature = "server")]
impl std::convert::TryFrom<HeaderValue> for header::IntoHeaderValue<DummyPutRequest> {
impl std::convert::TryFrom<HeaderValue> for header::IntoHeaderValue<FooDummyPutRequest> {
type Error = String;
fn try_from(hdr_value: HeaderValue) -> std::result::Result<Self, Self::Error> {
match hdr_value.to_str() {
std::result::Result::Ok(value) => {
match <DummyPutRequest as std::str::FromStr>::from_str(value) {
match <FooDummyPutRequest as std::str::FromStr>::from_str(value) {
std::result::Result::Ok(value) => {
std::result::Result::Ok(header::IntoHeaderValue(value))
}
std::result::Result::Err(err) => std::result::Result::Err(format!(
"Unable to convert header value '{}' into DummyPutRequest - {}",
"Unable to convert header value '{}' into FooDummyPutRequest - {}",
value, err
)),
}
@ -674,24 +678,24 @@ impl std::convert::TryFrom<HeaderValue> for header::IntoHeaderValue<DummyPutRequ
/// structured response
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct GetYamlResponse {
pub struct FooGetYamlResponse {
/// Inner string
#[serde(rename = "value")]
#[serde(skip_serializing_if = "Option::is_none")]
pub value: Option<String>,
}
impl GetYamlResponse {
impl FooGetYamlResponse {
#[allow(clippy::new_without_default, clippy::too_many_arguments)]
pub fn new() -> GetYamlResponse {
GetYamlResponse { value: None }
pub fn new() -> FooGetYamlResponse {
FooGetYamlResponse { value: None }
}
}
/// Converts the GetYamlResponse value to the Query Parameters representation (style=form, explode=false)
/// Converts the FooGetYamlResponse value to the Query Parameters representation (style=form, explode=false)
/// specified in https://swagger.io/docs/specification/serialization/
/// Should be implemented in a serde serializer
impl std::fmt::Display for GetYamlResponse {
impl std::fmt::Display for FooGetYamlResponse {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let params: Vec<Option<String>> = vec![self
.value
@ -706,10 +710,10 @@ impl std::fmt::Display for GetYamlResponse {
}
}
/// Converts Query Parameters representation (style=form, explode=false) to a GetYamlResponse value
/// Converts Query Parameters representation (style=form, explode=false) to a FooGetYamlResponse value
/// as specified in https://swagger.io/docs/specification/serialization/
/// Should be implemented in a serde deserializer
impl std::str::FromStr for GetYamlResponse {
impl std::str::FromStr for FooGetYamlResponse {
type Err = String;
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
@ -731,7 +735,7 @@ impl std::str::FromStr for GetYamlResponse {
Some(x) => x,
None => {
return std::result::Result::Err(
"Missing value while parsing GetYamlResponse".to_string(),
"Missing value while parsing FooGetYamlResponse".to_string(),
)
}
};
@ -745,7 +749,7 @@ impl std::str::FromStr for GetYamlResponse {
),
_ => {
return std::result::Result::Err(
"Unexpected key while parsing GetYamlResponse".to_string(),
"Unexpected key while parsing FooGetYamlResponse".to_string(),
)
}
}
@ -756,26 +760,26 @@ impl std::str::FromStr for GetYamlResponse {
}
// Use the intermediate representation to return the struct
std::result::Result::Ok(GetYamlResponse {
std::result::Result::Ok(FooGetYamlResponse {
value: intermediate_rep.value.into_iter().next(),
})
}
}
// Methods for converting between header::IntoHeaderValue<GetYamlResponse> and HeaderValue
// Methods for converting between header::IntoHeaderValue<FooGetYamlResponse> and HeaderValue
#[cfg(feature = "server")]
impl std::convert::TryFrom<header::IntoHeaderValue<GetYamlResponse>> for HeaderValue {
impl std::convert::TryFrom<header::IntoHeaderValue<FooGetYamlResponse>> for HeaderValue {
type Error = String;
fn try_from(
hdr_value: header::IntoHeaderValue<GetYamlResponse>,
hdr_value: header::IntoHeaderValue<FooGetYamlResponse>,
) -> std::result::Result<Self, Self::Error> {
let hdr_value = hdr_value.to_string();
match HeaderValue::from_str(&hdr_value) {
std::result::Result::Ok(value) => std::result::Result::Ok(value),
std::result::Result::Err(e) => std::result::Result::Err(format!(
"Invalid header value for GetYamlResponse - value: {} is invalid {}",
"Invalid header value for FooGetYamlResponse - value: {} is invalid {}",
hdr_value, e
)),
}
@ -783,18 +787,18 @@ impl std::convert::TryFrom<header::IntoHeaderValue<GetYamlResponse>> for HeaderV
}
#[cfg(feature = "server")]
impl std::convert::TryFrom<HeaderValue> for header::IntoHeaderValue<GetYamlResponse> {
impl std::convert::TryFrom<HeaderValue> for header::IntoHeaderValue<FooGetYamlResponse> {
type Error = String;
fn try_from(hdr_value: HeaderValue) -> std::result::Result<Self, Self::Error> {
match hdr_value.to_str() {
std::result::Result::Ok(value) => {
match <GetYamlResponse as std::str::FromStr>::from_str(value) {
match <FooGetYamlResponse as std::str::FromStr>::from_str(value) {
std::result::Result::Ok(value) => {
std::result::Result::Ok(header::IntoHeaderValue(value))
}
std::result::Result::Err(err) => std::result::Result::Err(format!(
"Unable to convert header value '{}' into GetYamlResponse - {}",
"Unable to convert header value '{}' into FooGetYamlResponse - {}",
value, err
)),
}
@ -810,23 +814,23 @@ impl std::convert::TryFrom<HeaderValue> for header::IntoHeaderValue<GetYamlRespo
/// An object of objects
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct ObjectOfObjects {
pub struct FooObjectOfObjects {
#[serde(rename = "inner")]
#[serde(skip_serializing_if = "Option::is_none")]
pub inner: Option<models::ObjectOfObjectsInner>,
pub inner: Option<models::FooObjectOfObjectsInner>,
}
impl ObjectOfObjects {
impl FooObjectOfObjects {
#[allow(clippy::new_without_default, clippy::too_many_arguments)]
pub fn new() -> ObjectOfObjects {
ObjectOfObjects { inner: None }
pub fn new() -> FooObjectOfObjects {
FooObjectOfObjects { inner: None }
}
}
/// Converts the ObjectOfObjects value to the Query Parameters representation (style=form, explode=false)
/// Converts the FooObjectOfObjects value to the Query Parameters representation (style=form, explode=false)
/// specified in https://swagger.io/docs/specification/serialization/
/// Should be implemented in a serde serializer
impl std::fmt::Display for ObjectOfObjects {
impl std::fmt::Display for FooObjectOfObjects {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let params: Vec<Option<String>> = vec![
// Skipping inner in query parameter serialization
@ -841,10 +845,10 @@ impl std::fmt::Display for ObjectOfObjects {
}
}
/// Converts Query Parameters representation (style=form, explode=false) to a ObjectOfObjects value
/// Converts Query Parameters representation (style=form, explode=false) to a FooObjectOfObjects value
/// as specified in https://swagger.io/docs/specification/serialization/
/// Should be implemented in a serde deserializer
impl std::str::FromStr for ObjectOfObjects {
impl std::str::FromStr for FooObjectOfObjects {
type Err = String;
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
@ -852,7 +856,7 @@ impl std::str::FromStr for ObjectOfObjects {
#[derive(Default)]
#[allow(dead_code)]
struct IntermediateRep {
pub inner: Vec<models::ObjectOfObjectsInner>,
pub inner: Vec<models::FooObjectOfObjectsInner>,
}
let mut intermediate_rep = IntermediateRep::default();
@ -866,7 +870,7 @@ impl std::str::FromStr for ObjectOfObjects {
Some(x) => x,
None => {
return std::result::Result::Err(
"Missing value while parsing ObjectOfObjects".to_string(),
"Missing value while parsing FooObjectOfObjects".to_string(),
)
}
};
@ -876,12 +880,12 @@ impl std::str::FromStr for ObjectOfObjects {
match key {
#[allow(clippy::redundant_clone)]
"inner" => intermediate_rep.inner.push(
<models::ObjectOfObjectsInner as std::str::FromStr>::from_str(val)
<models::FooObjectOfObjectsInner as std::str::FromStr>::from_str(val)
.map_err(|x| x.to_string())?,
),
_ => {
return std::result::Result::Err(
"Unexpected key while parsing ObjectOfObjects".to_string(),
"Unexpected key while parsing FooObjectOfObjects".to_string(),
)
}
}
@ -892,26 +896,26 @@ impl std::str::FromStr for ObjectOfObjects {
}
// Use the intermediate representation to return the struct
std::result::Result::Ok(ObjectOfObjects {
std::result::Result::Ok(FooObjectOfObjects {
inner: intermediate_rep.inner.into_iter().next(),
})
}
}
// Methods for converting between header::IntoHeaderValue<ObjectOfObjects> and HeaderValue
// Methods for converting between header::IntoHeaderValue<FooObjectOfObjects> and HeaderValue
#[cfg(feature = "server")]
impl std::convert::TryFrom<header::IntoHeaderValue<ObjectOfObjects>> for HeaderValue {
impl std::convert::TryFrom<header::IntoHeaderValue<FooObjectOfObjects>> for HeaderValue {
type Error = String;
fn try_from(
hdr_value: header::IntoHeaderValue<ObjectOfObjects>,
hdr_value: header::IntoHeaderValue<FooObjectOfObjects>,
) -> std::result::Result<Self, Self::Error> {
let hdr_value = hdr_value.to_string();
match HeaderValue::from_str(&hdr_value) {
std::result::Result::Ok(value) => std::result::Result::Ok(value),
std::result::Result::Err(e) => std::result::Result::Err(format!(
"Invalid header value for ObjectOfObjects - value: {} is invalid {}",
"Invalid header value for FooObjectOfObjects - value: {} is invalid {}",
hdr_value, e
)),
}
@ -919,18 +923,18 @@ impl std::convert::TryFrom<header::IntoHeaderValue<ObjectOfObjects>> for HeaderV
}
#[cfg(feature = "server")]
impl std::convert::TryFrom<HeaderValue> for header::IntoHeaderValue<ObjectOfObjects> {
impl std::convert::TryFrom<HeaderValue> for header::IntoHeaderValue<FooObjectOfObjects> {
type Error = String;
fn try_from(hdr_value: HeaderValue) -> std::result::Result<Self, Self::Error> {
match hdr_value.to_str() {
std::result::Result::Ok(value) => {
match <ObjectOfObjects as std::str::FromStr>::from_str(value) {
match <FooObjectOfObjects as std::str::FromStr>::from_str(value) {
std::result::Result::Ok(value) => {
std::result::Result::Ok(header::IntoHeaderValue(value))
}
std::result::Result::Err(err) => std::result::Result::Err(format!(
"Unable to convert header value '{}' into ObjectOfObjects - {}",
"Unable to convert header value '{}' into FooObjectOfObjects - {}",
value, err
)),
}
@ -945,7 +949,7 @@ impl std::convert::TryFrom<HeaderValue> for header::IntoHeaderValue<ObjectOfObje
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct ObjectOfObjectsInner {
pub struct FooObjectOfObjectsInner {
#[serde(rename = "required_thing")]
pub required_thing: String,
@ -954,20 +958,20 @@ pub struct ObjectOfObjectsInner {
pub optional_thing: Option<i32>,
}
impl ObjectOfObjectsInner {
impl FooObjectOfObjectsInner {
#[allow(clippy::new_without_default, clippy::too_many_arguments)]
pub fn new(required_thing: String) -> ObjectOfObjectsInner {
ObjectOfObjectsInner {
pub fn new(required_thing: String) -> FooObjectOfObjectsInner {
FooObjectOfObjectsInner {
required_thing,
optional_thing: None,
}
}
}
/// Converts the ObjectOfObjectsInner value to the Query Parameters representation (style=form, explode=false)
/// Converts the FooObjectOfObjectsInner value to the Query Parameters representation (style=form, explode=false)
/// specified in https://swagger.io/docs/specification/serialization/
/// Should be implemented in a serde serializer
impl std::fmt::Display for ObjectOfObjectsInner {
impl std::fmt::Display for FooObjectOfObjectsInner {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let params: Vec<Option<String>> = vec![
Some("required_thing".to_string()),
@ -985,10 +989,10 @@ impl std::fmt::Display for ObjectOfObjectsInner {
}
}
/// Converts Query Parameters representation (style=form, explode=false) to a ObjectOfObjectsInner value
/// Converts Query Parameters representation (style=form, explode=false) to a FooObjectOfObjectsInner value
/// as specified in https://swagger.io/docs/specification/serialization/
/// Should be implemented in a serde deserializer
impl std::str::FromStr for ObjectOfObjectsInner {
impl std::str::FromStr for FooObjectOfObjectsInner {
type Err = String;
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
@ -1011,7 +1015,7 @@ impl std::str::FromStr for ObjectOfObjectsInner {
Some(x) => x,
None => {
return std::result::Result::Err(
"Missing value while parsing ObjectOfObjectsInner".to_string(),
"Missing value while parsing FooObjectOfObjectsInner".to_string(),
)
}
};
@ -1029,7 +1033,7 @@ impl std::str::FromStr for ObjectOfObjectsInner {
),
_ => {
return std::result::Result::Err(
"Unexpected key while parsing ObjectOfObjectsInner".to_string(),
"Unexpected key while parsing FooObjectOfObjectsInner".to_string(),
)
}
}
@ -1040,31 +1044,31 @@ impl std::str::FromStr for ObjectOfObjectsInner {
}
// Use the intermediate representation to return the struct
std::result::Result::Ok(ObjectOfObjectsInner {
std::result::Result::Ok(FooObjectOfObjectsInner {
required_thing: intermediate_rep
.required_thing
.into_iter()
.next()
.ok_or_else(|| "required_thing missing in ObjectOfObjectsInner".to_string())?,
.ok_or_else(|| "required_thing missing in FooObjectOfObjectsInner".to_string())?,
optional_thing: intermediate_rep.optional_thing.into_iter().next(),
})
}
}
// Methods for converting between header::IntoHeaderValue<ObjectOfObjectsInner> and HeaderValue
// Methods for converting between header::IntoHeaderValue<FooObjectOfObjectsInner> and HeaderValue
#[cfg(feature = "server")]
impl std::convert::TryFrom<header::IntoHeaderValue<ObjectOfObjectsInner>> for HeaderValue {
impl std::convert::TryFrom<header::IntoHeaderValue<FooObjectOfObjectsInner>> for HeaderValue {
type Error = String;
fn try_from(
hdr_value: header::IntoHeaderValue<ObjectOfObjectsInner>,
hdr_value: header::IntoHeaderValue<FooObjectOfObjectsInner>,
) -> std::result::Result<Self, Self::Error> {
let hdr_value = hdr_value.to_string();
match HeaderValue::from_str(&hdr_value) {
std::result::Result::Ok(value) => std::result::Result::Ok(value),
std::result::Result::Err(e) => std::result::Result::Err(format!(
"Invalid header value for ObjectOfObjectsInner - value: {} is invalid {}",
"Invalid header value for FooObjectOfObjectsInner - value: {} is invalid {}",
hdr_value, e
)),
}
@ -1072,18 +1076,18 @@ impl std::convert::TryFrom<header::IntoHeaderValue<ObjectOfObjectsInner>> for He
}
#[cfg(feature = "server")]
impl std::convert::TryFrom<HeaderValue> for header::IntoHeaderValue<ObjectOfObjectsInner> {
impl std::convert::TryFrom<HeaderValue> for header::IntoHeaderValue<FooObjectOfObjectsInner> {
type Error = String;
fn try_from(hdr_value: HeaderValue) -> std::result::Result<Self, Self::Error> {
match hdr_value.to_str() {
std::result::Result::Ok(value) => {
match <ObjectOfObjectsInner as std::str::FromStr>::from_str(value) {
match <FooObjectOfObjectsInner as std::str::FromStr>::from_str(value) {
std::result::Result::Ok(value) => {
std::result::Result::Ok(header::IntoHeaderValue(value))
}
std::result::Result::Err(err) => std::result::Result::Err(format!(
"Unable to convert header value '{}' into ObjectOfObjectsInner - {}",
"Unable to convert header value '{}' into FooObjectOfObjectsInner - {}",
value, err
)),
}

View File

@ -158,13 +158,13 @@ where
#[allow(dead_code)]
struct DummyPutBodyValidator<'a> {
#[validate(nested)]
body: &'a models::DummyPutRequest,
body: &'a models::FooDummyPutRequest,
}
#[tracing::instrument(skip_all)]
fn dummy_put_validation(
body: models::DummyPutRequest,
) -> std::result::Result<(models::DummyPutRequest,), ValidationErrors> {
body: models::FooDummyPutRequest,
) -> std::result::Result<(models::FooDummyPutRequest,), ValidationErrors> {
let b = DummyPutBodyValidator { body: &body };
b.validate()?;
@ -177,7 +177,7 @@ async fn dummy_put<I, A>(
host: Host,
cookies: CookieJar,
State(api_impl): State<I>,
Json(body): Json<models::DummyPutRequest>,
Json(body): Json<models::FooDummyPutRequest>,
) -> Result<Response, StatusCode>
where
I: AsRef<A> + Send + Sync,