diff --git a/bin/configs/manual/rust-axum-test.yaml b/bin/configs/manual/rust-axum-test.yaml index c15e2e77aaa..ce53c1d24ac 100644 --- a/bin/configs/manual/rust-axum-test.yaml +++ b/bin/configs/manual/rust-axum-test.yaml @@ -6,6 +6,7 @@ generateAliasAsModel: true additionalProperties: hideGenerationTimestamp: "true" packageName: rust-server-test + modelNamePrefix: "Foo" globalProperties: skipFormModel: false enablePostProcessFile: true diff --git a/bin/configs/rust-reqwest-petstore-model-name-prefix.yaml b/bin/configs/rust-reqwest-petstore-model-name-prefix.yaml new file mode 100644 index 00000000000..2668c9044eb --- /dev/null +++ b/bin/configs/rust-reqwest-petstore-model-name-prefix.yaml @@ -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 diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractRustCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractRustCodegen.java index 567f6ec4159..55bd4290126 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractRustCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractRustCodegen.java @@ -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; } } diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/.gitignore b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/.gitignore new file mode 100644 index 00000000000..6aa106405a4 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/.gitignore @@ -0,0 +1,3 @@ +/target/ +**/*.rs.bk +Cargo.lock diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/.openapi-generator-ignore b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/.openapi-generator-ignore new file mode 100644 index 00000000000..7484ee590a3 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/.openapi-generator-ignore @@ -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 diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/.openapi-generator/FILES b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/.openapi-generator/FILES new file mode 100644 index 00000000000..13e753f3902 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/.openapi-generator/FILES @@ -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 diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/.openapi-generator/VERSION b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/.openapi-generator/VERSION new file mode 100644 index 00000000000..6935482704c --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.10.0-SNAPSHOT diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/.travis.yml b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/.travis.yml new file mode 100644 index 00000000000..22761ba7ee1 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/.travis.yml @@ -0,0 +1 @@ +language: rust diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/Cargo.toml b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/Cargo.toml new file mode 100644 index 00000000000..4696d501ae9 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/Cargo.toml @@ -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"] } diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/README.md b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/README.md new file mode 100644 index 00000000000..3604c72d58b --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/README.md @@ -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 + + + diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FakeApi.md b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FakeApi.md new file mode 100644 index 00000000000..55bf612aa21 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FakeApi.md @@ -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) + diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooActionContainer.md b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooActionContainer.md new file mode 100644 index 00000000000..d6ce7501490 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooActionContainer.md @@ -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) + + diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooApiResponse.md b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooApiResponse.md new file mode 100644 index 00000000000..ec78e1c3a12 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooApiResponse.md @@ -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) + + diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooArrayItemRefTest.md b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooArrayItemRefTest.md new file mode 100644 index 00000000000..2cd0ec4d9ca --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooArrayItemRefTest.md @@ -0,0 +1,12 @@ +# FooArrayItemRefTest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**list_with_array_ref** | [**Vec>**](Vec.md) | | +**list_with_object_ref** | [**Vec>**](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) + + diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooBaz.md b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooBaz.md new file mode 100644 index 00000000000..0af2c0a01c0 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooBaz.md @@ -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) + + diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooCategory.md b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooCategory.md new file mode 100644 index 00000000000..9dc5658f921 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooCategory.md @@ -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) + + diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooEnumArrayTesting.md b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooEnumArrayTesting.md new file mode 100644 index 00000000000..3f1eee35068 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooEnumArrayTesting.md @@ -0,0 +1,11 @@ +# FooEnumArrayTesting + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**required_enums** | **Vec** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooNullableArray.md b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooNullableArray.md new file mode 100644 index 00000000000..2f1f51510d4 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooNullableArray.md @@ -0,0 +1,14 @@ +# FooNullableArray + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**array_nullable** | Option<**Vec**> | | [optional] +**just_array** | Option<**Vec**> | | [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) + + diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooNumericEnumTesting.md b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooNumericEnumTesting.md new file mode 100644 index 00000000000..ccf36b2acd9 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooNumericEnumTesting.md @@ -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) + + diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooOptionalTesting.md b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooOptionalTesting.md new file mode 100644 index 00000000000..bce7845c2d7 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooOptionalTesting.md @@ -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) + + diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooOrder.md b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooOrder.md new file mode 100644 index 00000000000..5a5e81cb347 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooOrder.md @@ -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) + + diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooPet.md b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooPet.md new file mode 100644 index 00000000000..02172d58736 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooPet.md @@ -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** | | +**tags** | Option<[**Vec**](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) + + diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooPropertyTest.md b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooPropertyTest.md new file mode 100644 index 00000000000..cf58ec6c6ce --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooPropertyTest.md @@ -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) + + diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooRef.md b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooRef.md new file mode 100644 index 00000000000..088009fd1a1 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooRef.md @@ -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) + + diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooReturn.md b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooReturn.md new file mode 100644 index 00000000000..a078ac88767 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooReturn.md @@ -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) + + diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooTag.md b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooTag.md new file mode 100644 index 00000000000..fa3ecb4b8c0 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooTag.md @@ -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) + + diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooTypeTesting.md b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooTypeTesting.md new file mode 100644 index 00000000000..9d847fc1cbf --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooTypeTesting.md @@ -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) + + diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooUniqueItemArrayTesting.md b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooUniqueItemArrayTesting.md new file mode 100644 index 00000000000..5377655af8d --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooUniqueItemArrayTesting.md @@ -0,0 +1,11 @@ +# FooUniqueItemArrayTesting + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**unique_item_array** | **Vec** | 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) + + diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooUser.md b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooUser.md new file mode 100644 index 00000000000..887df5e270c --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooUser.md @@ -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) + + diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/PetApi.md b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/PetApi.md new file mode 100644 index 00000000000..a0b77436523 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/PetApi.md @@ -0,0 +1,261 @@ +# \PetApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**add_pet**](PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store +[**delete_pet**](PetApi.md#delete_pet) | **DELETE** /pet/{petId} | Deletes a pet +[**find_pets_by_status**](PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status +[**find_pets_by_tags**](PetApi.md#find_pets_by_tags) | **GET** /pet/findByTags | Finds Pets by tags +[**get_pet_by_id**](PetApi.md#get_pet_by_id) | **GET** /pet/{petId} | Find pet by ID +[**update_pet**](PetApi.md#update_pet) | **PUT** /pet | Update an existing pet +[**update_pet_with_form**](PetApi.md#update_pet_with_form) | **POST** /pet/{petId} | Updates a pet in the store with form data +[**upload_file**](PetApi.md#upload_file) | **POST** /pet/{petId}/uploadImage | uploads an image + + + +## add_pet + +> 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 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.md) | Status values that need to be considered for filter | [required] | + +### Return type + +[**Vec**](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 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.md) | Tags to filter by | [required] | + +### Return type + +[**Vec**](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) + diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/StoreApi.md b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/StoreApi.md new file mode 100644 index 00000000000..511a67746c9 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/StoreApi.md @@ -0,0 +1,129 @@ +# \StoreApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**delete_order**](StoreApi.md#delete_order) | **DELETE** /store/order/{orderId} | Delete purchase order by ID +[**get_inventory**](StoreApi.md#get_inventory) | **GET** /store/inventory | Returns pet inventories by status +[**get_order_by_id**](StoreApi.md#get_order_by_id) | **GET** /store/order/{orderId} | Find purchase order by ID +[**place_order**](StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet + + + +## delete_order + +> delete_order(order_id) +Delete purchase order by ID + +For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**order_id** | **String** | ID of the order that needs to be deleted | [required] | + +### Return type + + (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_inventory + +> std::collections::HashMap 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** + +### 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) + diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/TestingApi.md b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/TestingApi.md new file mode 100644 index 00000000000..b4e85b93b20 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/TestingApi.md @@ -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) + diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/UserApi.md b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/UserApi.md new file mode 100644 index 00000000000..3673dbe718d --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/UserApi.md @@ -0,0 +1,255 @@ +# \UserApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**create_user**](UserApi.md#create_user) | **POST** /user | Create user +[**create_users_with_array_input**](UserApi.md#create_users_with_array_input) | **POST** /user/createWithArray | Creates list of users with given input array +[**create_users_with_list_input**](UserApi.md#create_users_with_list_input) | **POST** /user/createWithList | Creates list of users with given input array +[**delete_user**](UserApi.md#delete_user) | **DELETE** /user/{username} | Delete user +[**get_user_by_name**](UserApi.md#get_user_by_name) | **GET** /user/{username} | Get user by user name +[**login_user**](UserApi.md#login_user) | **GET** /user/login | Logs user into the system +[**logout_user**](UserApi.md#logout_user) | **GET** /user/logout | Logs out current logged in user session +[**update_user**](UserApi.md#update_user) | **PUT** /user/{username} | Updated user + + + +## create_user + +> create_user(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**](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**](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) + diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/git_push.sh b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/git_push.sh new file mode 100644 index 00000000000..f53a75d4fab --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/git_push.sh @@ -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' diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/apis/configuration.rs b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/apis/configuration.rs new file mode 100644 index 00000000000..b1787d23b6e --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/apis/configuration.rs @@ -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, + pub client: reqwest::blocking::Client, + pub basic_auth: Option, + pub oauth_access_token: Option, + pub bearer_access_token: Option, + pub api_key: Option, +} + +pub type BasicAuth = (String, Option); + +#[derive(Debug, Clone)] +pub struct ApiKey { + pub prefix: Option, + 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, + } + } +} diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/apis/fake_api.rs b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/apis/fake_api.rs new file mode 100644 index 00000000000..d14a0f233be --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/apis/fake_api.rs @@ -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> { + 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 = 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)) + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/apis/mod.rs b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/apis/mod.rs new file mode 100644 index 00000000000..d791dfb5a89 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/apis/mod.rs @@ -0,0 +1,99 @@ +use std::error; +use std::fmt; + +#[derive(Debug, Clone)] +pub struct ResponseContent { + pub status: reqwest::StatusCode, + pub content: String, + pub entity: Option, +} + +#[derive(Debug)] +pub enum Error { + Reqwest(reqwest::Error), + Serde(serde_json::Error), + Io(std::io::Error), + ResponseError(ResponseContent), +} + +impl fmt::Display for Error { + 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 error::Error for Error { + 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 From for Error { + fn from(e: reqwest::Error) -> Self { + Error::Reqwest(e) + } +} + +impl From for Error { + fn from(e: serde_json::Error) -> Self { + Error::Serde(e) + } +} + +impl From for Error { + fn from(e: std::io::Error) -> Self { + Error::Io(e) + } +} + +pub fn urlencode>(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; diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/apis/pet_api.rs b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/apis/pet_api.rs new file mode 100644 index 00000000000..d7274d9986b --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/apis/pet_api.rs @@ -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> { + 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 = 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> { + 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 = 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) -> Result, Error> { + 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::>()), + _ => local_var_req_builder.query(&[("status", &status.into_iter().map(|p| p.to_string()).collect::>().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 = 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) -> Result, Error> { + 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::>()), + _ => local_var_req_builder.query(&[("tags", &tags.into_iter().map(|p| p.to_string()).collect::>().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 = 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> { + 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 = 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> { + 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 = 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> { + 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 = 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) -> Result> { + 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 = 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)) + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/apis/store_api.rs b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/apis/store_api.rs new file mode 100644 index 00000000000..2dc92a8a41b --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/apis/store_api.rs @@ -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> { + 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 = 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, Error> { + 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 = 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> { + 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 = 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> { + 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 = 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)) + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/apis/testing_api.rs b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/apis/testing_api.rs new file mode 100644 index 00000000000..8f42fae4014 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/apis/testing_api.rs @@ -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> { + 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 = 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> { + 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 = 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)) + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/apis/user_api.rs b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/apis/user_api.rs new file mode 100644 index 00000000000..45f728426b7 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/apis/user_api.rs @@ -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> { + 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 = 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) -> Result<(), Error> { + 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 = 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) -> Result<(), Error> { + 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 = 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> { + 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 = 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> { + 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 = 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> { + 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 = 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> { + 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 = 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> { + 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 = 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)) + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/lib.rs b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/lib.rs new file mode 100644 index 00000000000..e1520628d76 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/lib.rs @@ -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; diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_action_container.rs b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_action_container.rs new file mode 100644 index 00000000000..986f7013e3a --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_action_container.rs @@ -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, +} + +impl FooActionContainer { + pub fn new(action: models::FooBaz) -> FooActionContainer { + FooActionContainer { + action: Box::new(action), + } + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_api_response.rs b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_api_response.rs new file mode 100644 index 00000000000..aa2d9292b3b --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_api_response.rs @@ -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, + #[serde(rename = "type", skip_serializing_if = "Option::is_none")] + pub r#type: Option, + #[serde(rename = "message", skip_serializing_if = "Option::is_none")] + pub message: Option, +} + +impl FooApiResponse { + /// Describes the result of uploading an image resource + pub fn new() -> FooApiResponse { + FooApiResponse { + code: None, + r#type: None, + message: None, + } + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_array_item_ref_test.rs b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_array_item_ref_test.rs new file mode 100644 index 00000000000..4f2cf2bbf05 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_array_item_ref_test.rs @@ -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>, + #[serde(rename = "list_with_object_ref")] + pub list_with_object_ref: Vec>, +} + +impl FooArrayItemRefTest { + /// Test handling of object reference in arrays + pub fn new(list_with_array_ref: Vec>, list_with_object_ref: Vec>) -> FooArrayItemRefTest { + FooArrayItemRefTest { + list_with_array_ref, + list_with_object_ref, + } + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_baz.rs b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_baz.rs new file mode 100644 index 00000000000..44566e73afc --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_baz.rs @@ -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 + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_category.rs b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_category.rs new file mode 100644 index 00000000000..93d078290b2 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_category.rs @@ -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, + #[serde(rename = "name", skip_serializing_if = "Option::is_none")] + pub name: Option, +} + +impl FooCategory { + /// A category for a pet + pub fn new() -> FooCategory { + FooCategory { + id: None, + name: None, + } + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_enum_array_testing.rs b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_enum_array_testing.rs new file mode 100644 index 00000000000..7ef4f239d9b --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_enum_array_testing.rs @@ -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, +} + +impl FooEnumArrayTesting { + /// Test of enum array + pub fn new(required_enums: Vec) -> 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 + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_nullable_array.rs b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_nullable_array.rs new file mode 100644 index 00000000000..bce4ae0c95b --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_nullable_array.rs @@ -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>>, + #[serde(rename = "just_array", skip_serializing_if = "Option::is_none")] + pub just_array: Option>, + #[serde(rename = "nullable_string", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub nullable_string: Option>, + #[serde(rename = "just_string", skip_serializing_if = "Option::is_none")] + pub just_string: Option, +} + +impl FooNullableArray { + pub fn new() -> FooNullableArray { + FooNullableArray { + array_nullable: None, + just_array: None, + nullable_string: None, + just_string: None, + } + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_numeric_enum_testing.rs b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_numeric_enum_testing.rs new file mode 100644 index 00000000000..9c006d9d238 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_numeric_enum_testing.rs @@ -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 + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_optional_testing.rs b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_optional_testing.rs new file mode 100644 index 00000000000..624898a78d4 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_optional_testing.rs @@ -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, + #[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>, + #[serde(rename = "required_nullable", deserialize_with = "Option::deserialize")] + pub required_nullable: Option, +} + +impl FooOptionalTesting { + /// Test handling of optional and nullable fields + pub fn new(required_nonnull: String, required_nullable: Option) -> FooOptionalTesting { + FooOptionalTesting { + optional_nonnull: None, + required_nonnull, + optional_nullable: None, + required_nullable, + } + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_order.rs b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_order.rs new file mode 100644 index 00000000000..1b504b7a984 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_order.rs @@ -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, + #[serde(rename = "petId", skip_serializing_if = "Option::is_none")] + pub pet_id: Option, + #[serde(rename = "quantity", skip_serializing_if = "Option::is_none")] + pub quantity: Option, + #[serde(rename = "shipDate", skip_serializing_if = "Option::is_none")] + pub ship_date: Option, + /// Order Status + #[serde(rename = "status", skip_serializing_if = "Option::is_none")] + pub status: Option, + #[serde(rename = "complete", skip_serializing_if = "Option::is_none")] + pub complete: Option, +} + +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 + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_pet.rs b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_pet.rs new file mode 100644 index 00000000000..f5758f22283 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_pet.rs @@ -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, + #[serde(rename = "category", skip_serializing_if = "Option::is_none")] + pub category: Option>, + #[serde(rename = "name")] + pub name: String, + #[serde(rename = "photoUrls")] + pub photo_urls: Vec, + #[serde(rename = "tags", skip_serializing_if = "Option::is_none")] + pub tags: Option>, + /// pet status in the store + #[serde(rename = "status", skip_serializing_if = "Option::is_none")] + pub status: Option, +} + +impl FooPet { + /// A pet for sale in the pet store + pub fn new(name: String, photo_urls: Vec) -> 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 + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_property_test.rs b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_property_test.rs new file mode 100644 index 00000000000..8dae0d43d74 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_property_test.rs @@ -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, +} + +impl FooPropertyTest { + /// A model to test various formats, e.g. UUID + pub fn new() -> FooPropertyTest { + FooPropertyTest { + uuid: None, + } + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_ref.rs b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_ref.rs new file mode 100644 index 00000000000..a5ff541e6a6 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_ref.rs @@ -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, +} + +impl FooRef { + /// using reserved word as model name + pub fn new() -> FooRef { + FooRef { + dummy: None, + } + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_return.rs b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_return.rs new file mode 100644 index 00000000000..b886d6e6d86 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_return.rs @@ -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, + #[serde(rename = "async", skip_serializing_if = "Option::is_none")] + pub r#async: Option, + #[serde(rename = "super", skip_serializing_if = "Option::is_none")] + pub param_super: Option, +} + +impl FooReturn { + /// Test using keywords + pub fn new() -> FooReturn { + FooReturn { + r#match: None, + r#async: None, + param_super: None, + } + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_tag.rs b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_tag.rs new file mode 100644 index 00000000000..017acd986d5 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_tag.rs @@ -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, + #[serde(rename = "name", skip_serializing_if = "Option::is_none")] + pub name: Option, +} + +impl FooTag { + /// A tag for a pet + pub fn new() -> FooTag { + FooTag { + id: None, + name: None, + } + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_type_testing.rs b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_type_testing.rs new file mode 100644 index 00000000000..62147ee60b7 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_type_testing.rs @@ -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, +} + +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) -> FooTypeTesting { + FooTypeTesting { + int32, + int64, + float, + double, + string, + boolean, + uuid, + bytes, + } + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_unique_item_array_testing.rs b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_unique_item_array_testing.rs new file mode 100644 index 00000000000..5091809a337 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_unique_item_array_testing.rs @@ -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, +} + +impl FooUniqueItemArrayTesting { + /// Test handling of enum array with unique items + pub fn new(unique_item_array: std::collections::HashSet) -> 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 + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_user.rs b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_user.rs new file mode 100644 index 00000000000..33680ecfdf8 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_user.rs @@ -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, + #[serde(rename = "username")] + pub username: String, + #[serde(rename = "firstName", skip_serializing_if = "Option::is_none")] + pub first_name: Option, + #[serde(rename = "lastName")] + pub last_name: String, + #[serde(rename = "email", skip_serializing_if = "Option::is_none")] + pub email: Option, + #[serde(rename = "password", skip_serializing_if = "Option::is_none")] + pub password: Option, + #[serde(rename = "phone", skip_serializing_if = "Option::is_none")] + pub phone: Option, + /// User Status + #[serde(rename = "userStatus", skip_serializing_if = "Option::is_none")] + pub user_status: Option, +} + +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, + } + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/mod.rs b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/mod.rs new file mode 100644 index 00000000000..11d4654e790 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/mod.rs @@ -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; diff --git a/samples/server/petstore/rust-axum/output/rust-axum-test/src/apis/default.rs b/samples/server/petstore/rust-axum/output/rust-axum-test/src/apis/default.rs index b6809341c82..08985bd64e5 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-test/src/apis/default.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-test/src/apis/default.rs @@ -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; /// Get a file. diff --git a/samples/server/petstore/rust-axum/output/rust-axum-test/src/models.rs b/samples/server/petstore/rust-axum/output/rust-axum-test/src/models.rs index 748d8c7dcef..26c25bb354f 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-test/src/models.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-test/src/models.rs @@ -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, } -impl ANullableContainer { +impl FooANullableContainer { #[allow(clippy::new_without_default, clippy::too_many_arguments)] - pub fn new(required_nullable_thing: Nullable) -> ANullableContainer { - ANullableContainer { + pub fn new(required_nullable_thing: Nullable) -> 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> = 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 { @@ -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 and HeaderValue +// Methods for converting between header::IntoHeaderValue and HeaderValue #[cfg(feature = "server")] -impl std::convert::TryFrom> for HeaderValue { +impl std::convert::TryFrom> for HeaderValue { type Error = String; fn try_from( - hdr_value: header::IntoHeaderValue, + hdr_value: header::IntoHeaderValue, ) -> std::result::Result { 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> for Head } #[cfg(feature = "server")] -impl std::convert::TryFrom for header::IntoHeaderValue { +impl std::convert::TryFrom for header::IntoHeaderValue { type Error = String; fn try_from(hdr_value: HeaderValue) -> std::result::Result { match hdr_value.to_str() { std::result::Result::Ok(value) => { - match ::from_str(value) { + match ::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 for header::IntoHeaderValue); +pub struct FooAdditionalPropertiesObject(std::collections::HashMap); -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> for AdditionalPropertiesObject { +impl std::convert::From> + for FooAdditionalPropertiesObject +{ fn from(x: std::collections::HashMap) -> Self { - AdditionalPropertiesObject(x) + FooAdditionalPropertiesObject(x) } } -impl std::convert::From for std::collections::HashMap { - fn from(x: AdditionalPropertiesObject) -> Self { +impl std::convert::From + for std::collections::HashMap +{ + fn from(x: FooAdditionalPropertiesObject) -> Self { x.0 } } -impl std::ops::Deref for AdditionalPropertiesObject { +impl std::ops::Deref for FooAdditionalPropertiesObject { type Target = std::collections::HashMap; fn deref(&self) -> &std::collections::HashMap { &self.0 } } -impl std::ops::DerefMut for AdditionalPropertiesObject { +impl std::ops::DerefMut for FooAdditionalPropertiesObject { fn deref_mut(&mut self) -> &mut std::collections::HashMap { &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 { 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, @@ -233,20 +237,20 @@ pub struct AllOfObject { pub sample_base_property: Option, } -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> = 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 { @@ -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 and HeaderValue +// Methods for converting between header::IntoHeaderValue and HeaderValue #[cfg(feature = "server")] -impl std::convert::TryFrom> for HeaderValue { +impl std::convert::TryFrom> for HeaderValue { type Error = String; fn try_from( - hdr_value: header::IntoHeaderValue, + hdr_value: header::IntoHeaderValue, ) -> std::result::Result { 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> for HeaderValue } #[cfg(feature = "server")] -impl std::convert::TryFrom for header::IntoHeaderValue { +impl std::convert::TryFrom for header::IntoHeaderValue { type Error = String; fn try_from(hdr_value: HeaderValue) -> std::result::Result { match hdr_value.to_str() { std::result::Result::Ok(value) => { - match ::from_str(value) { + match ::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 for header::IntoHeaderValue #[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, } -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> = 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 { @@ -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 and HeaderValue +// Methods for converting between header::IntoHeaderValue and HeaderValue #[cfg(feature = "server")] -impl std::convert::TryFrom> for HeaderValue { +impl std::convert::TryFrom> for HeaderValue { type Error = String; fn try_from( - hdr_value: header::IntoHeaderValue, + hdr_value: header::IntoHeaderValue, ) -> std::result::Result { 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> for HeaderValue { } #[cfg(feature = "server")] -impl std::convert::TryFrom for header::IntoHeaderValue { +impl std::convert::TryFrom for header::IntoHeaderValue { type Error = String; fn try_from(hdr_value: HeaderValue) -> std::result::Result { match hdr_value.to_str() { std::result::Result::Ok(value) => { - match ::from_str(value) { + match ::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 for header::IntoHeaderValue { #[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, } -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> = 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 { @@ -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 and HeaderValue +// Methods for converting between header::IntoHeaderValue and HeaderValue #[cfg(feature = "server")] -impl std::convert::TryFrom> for HeaderValue { +impl std::convert::TryFrom> for HeaderValue { type Error = String; fn try_from( - hdr_value: header::IntoHeaderValue, + hdr_value: header::IntoHeaderValue, ) -> std::result::Result { 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> for HeaderV } #[cfg(feature = "server")] -impl std::convert::TryFrom for header::IntoHeaderValue { +impl std::convert::TryFrom for header::IntoHeaderValue { type Error = String; fn try_from(hdr_value: HeaderValue) -> std::result::Result { match hdr_value.to_str() { std::result::Result::Ok(value) => { - match ::from_str(value) { + match ::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 for header::IntoHeaderValue, } -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> = 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 { @@ -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 and HeaderValue +// Methods for converting between header::IntoHeaderValue and HeaderValue #[cfg(feature = "server")] -impl std::convert::TryFrom> for HeaderValue { +impl std::convert::TryFrom> for HeaderValue { type Error = String; fn try_from( - hdr_value: header::IntoHeaderValue, + hdr_value: header::IntoHeaderValue, ) -> std::result::Result { 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> for HeaderV } #[cfg(feature = "server")] -impl std::convert::TryFrom for header::IntoHeaderValue { +impl std::convert::TryFrom for header::IntoHeaderValue { type Error = String; fn try_from(hdr_value: HeaderValue) -> std::result::Result { match hdr_value.to_str() { std::result::Result::Ok(value) => { - match ::from_str(value) { + match ::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 for header::IntoHeaderValue, + pub inner: Option, } -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> = 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 { @@ -852,7 +856,7 @@ impl std::str::FromStr for ObjectOfObjects { #[derive(Default)] #[allow(dead_code)] struct IntermediateRep { - pub inner: Vec, + pub inner: Vec, } 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( - ::from_str(val) + ::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 and HeaderValue +// Methods for converting between header::IntoHeaderValue and HeaderValue #[cfg(feature = "server")] -impl std::convert::TryFrom> for HeaderValue { +impl std::convert::TryFrom> for HeaderValue { type Error = String; fn try_from( - hdr_value: header::IntoHeaderValue, + hdr_value: header::IntoHeaderValue, ) -> std::result::Result { 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> for HeaderV } #[cfg(feature = "server")] -impl std::convert::TryFrom for header::IntoHeaderValue { +impl std::convert::TryFrom for header::IntoHeaderValue { type Error = String; fn try_from(hdr_value: HeaderValue) -> std::result::Result { match hdr_value.to_str() { std::result::Result::Ok(value) => { - match ::from_str(value) { + match ::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 for header::IntoHeaderValue, } -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> = 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 { @@ -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 and HeaderValue +// Methods for converting between header::IntoHeaderValue and HeaderValue #[cfg(feature = "server")] -impl std::convert::TryFrom> for HeaderValue { +impl std::convert::TryFrom> for HeaderValue { type Error = String; fn try_from( - hdr_value: header::IntoHeaderValue, + hdr_value: header::IntoHeaderValue, ) -> std::result::Result { 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> for He } #[cfg(feature = "server")] -impl std::convert::TryFrom for header::IntoHeaderValue { +impl std::convert::TryFrom for header::IntoHeaderValue { type Error = String; fn try_from(hdr_value: HeaderValue) -> std::result::Result { match hdr_value.to_str() { std::result::Result::Ok(value) => { - match ::from_str(value) { + match ::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 )), } diff --git a/samples/server/petstore/rust-axum/output/rust-axum-test/src/server/mod.rs b/samples/server/petstore/rust-axum/output/rust-axum-test/src/server/mod.rs index f16aec9b6e1..c8205254790 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-test/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-test/src/server/mod.rs @@ -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( host: Host, cookies: CookieJar, State(api_impl): State, - Json(body): Json, + Json(body): Json, ) -> Result where I: AsRef + Send + Sync,