Rust: Support Integer enums using Serde_repr (#19199)

* rust: support repr(int) enum

* Regen APIS

* remove the extra lines

* merge most recent commits from master

* update tests to ensure that enum compiles correctly

* drop changes to kotlin files

---------

Co-authored-by: Jihyun Yu <yjh0502@gmail.com>
This commit is contained in:
Bert Downs 2024-07-24 21:14:17 +12:00 committed by GitHub
parent 8950892652
commit 9a673ea09a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
81 changed files with 519 additions and 0 deletions

View File

@ -37,6 +37,7 @@ serde = { version = "^1.0", features = ["derive"] }
serde_with = { version = "^3.8", default-features = false, features = ["base64", "std", "macros"] }
{{/serdeWith}}
serde_json = "^1.0"
serde_repr = "^0.1"
url = "^2.5"
uuid = { version = "^1.8", features = ["serde", "v4"] }
{{#hyper}}

View File

@ -1,6 +1,7 @@
#![allow(unused_imports)]
#![allow(clippy::too_many_arguments)]
extern crate serde_repr;
extern crate serde;
extern crate serde_json;
extern crate url;

View File

@ -6,11 +6,43 @@ use serde::{Deserialize, Serialize};
{{^isEnum}}{{#vendorExtensions.x-rust-has-byte-array}}
use serde_with::serde_as;
{{/vendorExtensions.x-rust-has-byte-array}}{{/isEnum}}
{{#isEnum}}
{{#isInteger}}
use serde_repr::{Serialize_repr,Deserialize_repr};
{{/isInteger}}
{{/isEnum}}
{{#description}}
/// {{{classname}}} : {{{description}}}
{{/description}}
{{!-- for repr(int) enum schemas --}}
{{#isEnum}}
{{#isInteger}}
/// {{{description}}}
#[repr(i64)]
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize_repr, Deserialize_repr)]
pub enum {{{classname}}} {
{{#allowableValues}}
{{#enumVars}}
{{{name}}} = {{{value}}},
{{/enumVars}}{{/allowableValues}}
}
impl ToString for {{{classname}}} {
fn to_string(&self) -> String {
match self {
{{#allowableValues}}
{{#enumVars}}
Self::{{{name}}} => String::from("{{{value}}}"),
{{/enumVars}}
{{/allowableValues}}
}
}
}
{{/isInteger}}
{{/isEnum}}
{{!-- for enum schemas --}}
{{#isEnum}}
{{^isInteger}}
/// {{{description}}}
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum {{{classname}}} {
@ -33,6 +65,7 @@ impl std::fmt::Display for {{{classname}}} {
}
}
{{/isInteger}}
impl Default for {{{classname}}} {
fn default() -> {{{classname}}} {
{{#allowableValues}}

View File

@ -959,6 +959,14 @@ components:
nullable: true
just_string:
type: string
NumericEnumTesting:
description: testing that numeric enums are converted correctly
enum:
- 0
- 1
- 2
- 3
type: integer
ref:
description: using reserved word as model name
type: object

View File

@ -10,6 +10,7 @@ edition = "2021"
[dependencies]
serde = { version = "^1.0", features = ["derive"] }
serde_json = "^1.0"
serde_repr = "^0.1"
url = "^2.5"
uuid = { version = "^1.8", features = ["serde", "v4"] }
hyper = { version = "^1.3.1", features = ["full"] }

View File

@ -1,6 +1,7 @@
#![allow(unused_imports)]
#![allow(clippy::too_many_arguments)]
extern crate serde_repr;
extern crate serde;
extern crate serde_json;
extern crate url;

View File

@ -10,6 +10,7 @@ edition = "2021"
[dependencies]
serde = { version = "^1.0", features = ["derive"] }
serde_json = "^1.0"
serde_repr = "^0.1"
url = "^2.5"
uuid = { version = "^1.8", features = ["serde", "v4"] }
hyper = { version = "^1.3.1", features = ["full"] }

View File

@ -1,6 +1,7 @@
#![allow(unused_imports)]
#![allow(clippy::too_many_arguments)]
extern crate serde_repr;
extern crate serde;
extern crate serde_json;
extern crate url;

View File

@ -10,6 +10,7 @@ edition = "2021"
[dependencies]
serde = { version = "^1.0", features = ["derive"] }
serde_json = "^1.0"
serde_repr = "^0.1"
url = "^2.5"
uuid = { version = "^1.8", features = ["serde", "v4"] }
hyper = { version = "^1.3.1", features = ["full"] }

View File

@ -1,6 +1,7 @@
#![allow(unused_imports)]
#![allow(clippy::too_many_arguments)]
extern crate serde_repr;
extern crate serde;
extern crate serde_json;
extern crate url;

View File

@ -10,6 +10,7 @@ edition = "2021"
[dependencies]
serde = { version = "^1.0", features = ["derive"] }
serde_json = "^1.0"
serde_repr = "^0.1"
url = "^2.5"
uuid = { version = "^1.8", features = ["serde", "v4"] }
hyper = { version = "^1.3.1", features = ["full"] }

View File

@ -1,6 +1,7 @@
#![allow(unused_imports)]
#![allow(clippy::too_many_arguments)]
extern crate serde_repr;
extern crate serde;
extern crate serde_json;
extern crate url;

View File

@ -9,6 +9,7 @@ edition = "2021"
[dependencies]
serde = { version = "^1.0", features = ["derive"] }
serde_json = "^1.0"
serde_repr = "^0.1"
url = "^2.5"
uuid = { version = "^1.8", features = ["serde", "v4"] }
hyper = { version = "^1.3.1", features = ["full"] }

View File

@ -1,6 +1,7 @@
#![allow(unused_imports)]
#![allow(clippy::too_many_arguments)]
extern crate serde_repr;
extern crate serde;
extern crate serde_json;
extern crate url;

View File

@ -10,6 +10,7 @@ edition = "2021"
[dependencies]
serde = { version = "^1.0", features = ["derive"] }
serde_json = "^1.0"
serde_repr = "^0.1"
url = "^2.5"
uuid = { version = "^1.8", features = ["serde", "v4"] }
hyper = { version = "^1.3.1", features = ["full"] }

View File

@ -1,6 +1,7 @@
#![allow(unused_imports)]
#![allow(clippy::too_many_arguments)]
extern crate serde_repr;
extern crate serde;
extern crate serde_json;
extern crate url;

View File

@ -10,6 +10,7 @@ edition = "2021"
[dependencies]
serde = { version = "^1.0", features = ["derive"] }
serde_json = "^1.0"
serde_repr = "^0.1"
url = "^2.5"
uuid = { version = "^1.8", features = ["serde", "v4"] }
reqwest = { version = "^0.12", features = ["json", "blocking", "multipart"] }

View File

@ -1,6 +1,7 @@
#![allow(unused_imports)]
#![allow(clippy::too_many_arguments)]
extern crate serde_repr;
extern crate serde;
extern crate serde_json;
extern crate url;

View File

@ -10,6 +10,7 @@ edition = "2021"
[dependencies]
serde = { version = "^1.0", features = ["derive"] }
serde_json = "^1.0"
serde_repr = "^0.1"
url = "^2.5"
uuid = { version = "^1.8", features = ["serde", "v4"] }
reqwest = { version = "^0.12", features = ["json", "multipart"] }

View File

@ -1,6 +1,7 @@
#![allow(unused_imports)]
#![allow(clippy::too_many_arguments)]
extern crate serde_repr;
extern crate serde;
extern crate serde_json;
extern crate url;

View File

@ -10,6 +10,7 @@ edition = "2021"
[dependencies]
serde = { version = "^1.0", features = ["derive"] }
serde_json = "^1.0"
serde_repr = "^0.1"
url = "^2.5"
uuid = { version = "^1.8", features = ["serde", "v4"] }
reqwest = { version = "^0.12", features = ["json", "blocking", "multipart"] }

View File

@ -1,6 +1,7 @@
#![allow(unused_imports)]
#![allow(clippy::too_many_arguments)]
extern crate serde_repr;
extern crate serde;
extern crate serde_json;
extern crate url;

View File

@ -10,6 +10,7 @@ edition = "2021"
[dependencies]
serde = { version = "^1.0", features = ["derive"] }
serde_json = "^1.0"
serde_repr = "^0.1"
url = "^2.5"
uuid = { version = "^1.8", features = ["serde", "v4"] }
reqwest = { version = "^0.12", features = ["json", "blocking", "multipart"] }

View File

@ -1,6 +1,7 @@
#![allow(unused_imports)]
#![allow(clippy::too_many_arguments)]
extern crate serde_repr;
extern crate serde;
extern crate serde_json;
extern crate url;

View File

@ -10,6 +10,7 @@ edition = "2021"
[dependencies]
serde = { version = "^1.0", features = ["derive"] }
serde_json = "^1.0"
serde_repr = "^0.1"
url = "^2.5"
uuid = { version = "^1.8", features = ["serde", "v4"] }
reqwest = { version = "^0.12", features = ["json", "blocking", "multipart"] }

View File

@ -1,6 +1,7 @@
#![allow(unused_imports)]
#![allow(clippy::too_many_arguments)]
extern crate serde_repr;
extern crate serde;
extern crate serde_json;
extern crate url;

View File

@ -9,6 +9,7 @@ edition = "2021"
[dependencies]
serde = { version = "^1.0", features = ["derive"] }
serde_json = "^1.0"
serde_repr = "^0.1"
url = "^2.5"
uuid = { version = "^1.8", features = ["serde", "v4"] }
reqwest = { version = "^0.12", features = ["json", "blocking", "multipart"] }

View File

@ -1,6 +1,7 @@
#![allow(unused_imports)]
#![allow(clippy::too_many_arguments)]
extern crate serde_repr;
extern crate serde;
extern crate serde_json;
extern crate url;

View File

@ -10,6 +10,7 @@ edition = "2021"
[dependencies]
serde = { version = "^1.0", features = ["derive"] }
serde_json = "^1.0"
serde_repr = "^0.1"
url = "^2.5"
uuid = { version = "^1.8", features = ["serde", "v4"] }
reqwest = { version = "^0.12", features = ["json", "blocking", "multipart"] }

View File

@ -1,6 +1,7 @@
#![allow(unused_imports)]
#![allow(clippy::too_many_arguments)]
extern crate serde_repr;
extern crate serde;
extern crate serde_json;
extern crate url;

View File

@ -10,6 +10,7 @@ docs/Category.md
docs/EnumArrayTesting.md
docs/FakeApi.md
docs/NullableArray.md
docs/NumericEnumTesting.md
docs/OptionalTesting.md
docs/Order.md
docs/Pet.md
@ -45,6 +46,7 @@ src/models/mod.rs
src/models/model_ref.rs
src/models/model_return.rs
src/models/nullable_array.rs
src/models/numeric_enum_testing.rs
src/models/optional_testing.rs
src/models/order.rs
src/models/pet.rs

View File

@ -10,6 +10,7 @@ edition = "2021"
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"] }
hyper = { version = "^1.3.1", features = ["full"] }

View File

@ -60,6 +60,7 @@ Class | Method | HTTP request | Description
- [Category](docs/Category.md)
- [EnumArrayTesting](docs/EnumArrayTesting.md)
- [NullableArray](docs/NullableArray.md)
- [NumericEnumTesting](docs/NumericEnumTesting.md)
- [OptionalTesting](docs/OptionalTesting.md)
- [Order](docs/Order.md)
- [Pet](docs/Pet.md)

View File

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

View File

@ -1,6 +1,7 @@
#![allow(unused_imports)]
#![allow(clippy::too_many_arguments)]
extern crate serde_repr;
extern crate serde;
extern crate serde_json;
extern crate url;

View File

@ -12,6 +12,8 @@ pub mod enum_array_testing;
pub use self::enum_array_testing::EnumArrayTesting;
pub mod nullable_array;
pub use self::nullable_array::NullableArray;
pub mod numeric_enum_testing;
pub use self::numeric_enum_testing::NumericEnumTesting;
pub mod optional_testing;
pub use self::optional_testing::OptionalTesting;
pub mod order;

View File

@ -0,0 +1,42 @@
/*
* OpenAPI Petstore
*
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
use serde_repr::{Serialize_repr,Deserialize_repr};
/// NumericEnumTesting : 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 NumericEnumTesting {
Variant0 = 0,
Variant1 = 1,
Variant2 = 2,
Variant3 = 3,
}
impl ToString for NumericEnumTesting {
fn to_string(&self) -> String {
match self {
Self::Variant0 => String::from("0"),
Self::Variant1 => String::from("1"),
Self::Variant2 => String::from("2"),
Self::Variant3 => String::from("3"),
}
}
}
impl Default for NumericEnumTesting {
fn default() -> NumericEnumTesting {
Self::Variant0
}
}

View File

@ -10,6 +10,7 @@ docs/Category.md
docs/EnumArrayTesting.md
docs/FakeApi.md
docs/NullableArray.md
docs/NumericEnumTesting.md
docs/OptionalTesting.md
docs/Order.md
docs/Pet.md
@ -43,6 +44,7 @@ src/models/mod.rs
src/models/model_ref.rs
src/models/model_return.rs
src/models/nullable_array.rs
src/models/numeric_enum_testing.rs
src/models/optional_testing.rs
src/models/order.rs
src/models/pet.rs

View File

@ -10,6 +10,7 @@ edition = "2021"
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"] }
hyper = { version = "~0.14", features = ["full"] }

View File

@ -60,6 +60,7 @@ Class | Method | HTTP request | Description
- [Category](docs/Category.md)
- [EnumArrayTesting](docs/EnumArrayTesting.md)
- [NullableArray](docs/NullableArray.md)
- [NumericEnumTesting](docs/NumericEnumTesting.md)
- [OptionalTesting](docs/OptionalTesting.md)
- [Order](docs/Order.md)
- [Pet](docs/Pet.md)

View File

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

View File

@ -1,6 +1,7 @@
#![allow(unused_imports)]
#![allow(clippy::too_many_arguments)]
extern crate serde_repr;
extern crate serde;
extern crate serde_json;
extern crate url;

View File

@ -12,6 +12,8 @@ pub mod enum_array_testing;
pub use self::enum_array_testing::EnumArrayTesting;
pub mod nullable_array;
pub use self::nullable_array::NullableArray;
pub mod numeric_enum_testing;
pub use self::numeric_enum_testing::NumericEnumTesting;
pub mod optional_testing;
pub use self::optional_testing::OptionalTesting;
pub mod order;

View File

@ -0,0 +1,42 @@
/*
* OpenAPI Petstore
*
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
use serde_repr::{Serialize_repr,Deserialize_repr};
/// NumericEnumTesting : 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 NumericEnumTesting {
Variant0 = 0,
Variant1 = 1,
Variant2 = 2,
Variant3 = 3,
}
impl ToString for NumericEnumTesting {
fn to_string(&self) -> String {
match self {
Self::Variant0 => String::from("0"),
Self::Variant1 => String::from("1"),
Self::Variant2 => String::from("2"),
Self::Variant3 => String::from("3"),
}
}
}
impl Default for NumericEnumTesting {
fn default() -> NumericEnumTesting {
Self::Variant0
}
}

View File

@ -9,6 +9,7 @@ edition = "2021"
[dependencies]
serde = { version = "^1.0", features = ["derive"] }
serde_json = "^1.0"
serde_repr = "^0.1"
url = "^2.5"
uuid = { version = "^1.8", features = ["serde", "v4"] }
reqwest = { version = "^0.12", features = ["json", "blocking", "multipart"] }

View File

@ -1,6 +1,7 @@
#![allow(unused_imports)]
#![allow(clippy::too_many_arguments)]
extern crate serde_repr;
extern crate serde;
extern crate serde_json;
extern crate url;

View File

@ -10,6 +10,7 @@ docs/Category.md
docs/EnumArrayTesting.md
docs/FakeApi.md
docs/NullableArray.md
docs/NumericEnumTesting.md
docs/OptionalTesting.md
docs/Order.md
docs/Pet.md
@ -43,6 +44,7 @@ src/models/mod.rs
src/models/model_ref.rs
src/models/model_return.rs
src/models/nullable_array.rs
src/models/numeric_enum_testing.rs
src/models/optional_testing.rs
src/models/order.rs
src/models/pet.rs

View File

@ -10,6 +10,7 @@ edition = "2021"
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", "multipart"] }

View File

@ -60,6 +60,7 @@ Class | Method | HTTP request | Description
- [Category](docs/Category.md)
- [EnumArrayTesting](docs/EnumArrayTesting.md)
- [NullableArray](docs/NullableArray.md)
- [NumericEnumTesting](docs/NumericEnumTesting.md)
- [OptionalTesting](docs/OptionalTesting.md)
- [Order](docs/Order.md)
- [Pet](docs/Pet.md)

View File

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

View File

@ -1,6 +1,7 @@
#![allow(unused_imports)]
#![allow(clippy::too_many_arguments)]
extern crate serde_repr;
extern crate serde;
extern crate serde_json;
extern crate url;

View File

@ -12,6 +12,8 @@ pub mod enum_array_testing;
pub use self::enum_array_testing::EnumArrayTesting;
pub mod nullable_array;
pub use self::nullable_array::NullableArray;
pub mod numeric_enum_testing;
pub use self::numeric_enum_testing::NumericEnumTesting;
pub mod optional_testing;
pub use self::optional_testing::OptionalTesting;
pub mod order;

View File

@ -0,0 +1,42 @@
/*
* OpenAPI Petstore
*
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
use serde_repr::{Serialize_repr,Deserialize_repr};
/// NumericEnumTesting : 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 NumericEnumTesting {
Variant0 = 0,
Variant1 = 1,
Variant2 = 2,
Variant3 = 3,
}
impl ToString for NumericEnumTesting {
fn to_string(&self) -> String {
match self {
Self::Variant0 => String::from("0"),
Self::Variant1 => String::from("1"),
Self::Variant2 => String::from("2"),
Self::Variant3 => String::from("3"),
}
}
}
impl Default for NumericEnumTesting {
fn default() -> NumericEnumTesting {
Self::Variant0
}
}

View File

@ -10,6 +10,7 @@ docs/Category.md
docs/EnumArrayTesting.md
docs/FakeApi.md
docs/NullableArray.md
docs/NumericEnumTesting.md
docs/OptionalTesting.md
docs/Order.md
docs/Pet.md
@ -43,6 +44,7 @@ src/models/mod.rs
src/models/model_ref.rs
src/models/model_return.rs
src/models/nullable_array.rs
src/models/numeric_enum_testing.rs
src/models/optional_testing.rs
src/models/order.rs
src/models/pet.rs

View File

@ -10,6 +10,7 @@ edition = "2021"
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", "multipart"] }

View File

@ -60,6 +60,7 @@ Class | Method | HTTP request | Description
- [Category](docs/Category.md)
- [EnumArrayTesting](docs/EnumArrayTesting.md)
- [NullableArray](docs/NullableArray.md)
- [NumericEnumTesting](docs/NumericEnumTesting.md)
- [OptionalTesting](docs/OptionalTesting.md)
- [Order](docs/Order.md)
- [Pet](docs/Pet.md)

View File

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

View File

@ -1,6 +1,7 @@
#![allow(unused_imports)]
#![allow(clippy::too_many_arguments)]
extern crate serde_repr;
extern crate serde;
extern crate serde_json;
extern crate url;

View File

@ -12,6 +12,8 @@ pub mod enum_array_testing;
pub use self::enum_array_testing::EnumArrayTesting;
pub mod nullable_array;
pub use self::nullable_array::NullableArray;
pub mod numeric_enum_testing;
pub use self::numeric_enum_testing::NumericEnumTesting;
pub mod optional_testing;
pub use self::optional_testing::OptionalTesting;
pub mod order;

View File

@ -0,0 +1,42 @@
/*
* OpenAPI Petstore
*
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
use serde_repr::{Serialize_repr,Deserialize_repr};
/// NumericEnumTesting : 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 NumericEnumTesting {
Variant0 = 0,
Variant1 = 1,
Variant2 = 2,
Variant3 = 3,
}
impl ToString for NumericEnumTesting {
fn to_string(&self) -> String {
match self {
Self::Variant0 => String::from("0"),
Self::Variant1 => String::from("1"),
Self::Variant2 => String::from("2"),
Self::Variant3 => String::from("3"),
}
}
}
impl Default for NumericEnumTesting {
fn default() -> NumericEnumTesting {
Self::Variant0
}
}

View File

@ -10,6 +10,7 @@ docs/Category.md
docs/EnumArrayTesting.md
docs/FakeApi.md
docs/NullableArray.md
docs/NumericEnumTesting.md
docs/OptionalTesting.md
docs/Order.md
docs/Pet.md
@ -43,6 +44,7 @@ src/models/mod.rs
src/models/model_ref.rs
src/models/model_return.rs
src/models/nullable_array.rs
src/models/numeric_enum_testing.rs
src/models/optional_testing.rs
src/models/order.rs
src/models/pet.rs

View File

@ -10,6 +10,7 @@ edition = "2021"
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", "multipart"] }

View File

@ -60,6 +60,7 @@ Class | Method | HTTP request | Description
- [Category](docs/Category.md)
- [EnumArrayTesting](docs/EnumArrayTesting.md)
- [NullableArray](docs/NullableArray.md)
- [NumericEnumTesting](docs/NumericEnumTesting.md)
- [OptionalTesting](docs/OptionalTesting.md)
- [Order](docs/Order.md)
- [Pet](docs/Pet.md)

View File

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

View File

@ -1,6 +1,7 @@
#![allow(unused_imports)]
#![allow(clippy::too_many_arguments)]
extern crate serde_repr;
extern crate serde;
extern crate serde_json;
extern crate url;

View File

@ -12,6 +12,8 @@ pub mod enum_array_testing;
pub use self::enum_array_testing::EnumArrayTesting;
pub mod nullable_array;
pub use self::nullable_array::NullableArray;
pub mod numeric_enum_testing;
pub use self::numeric_enum_testing::NumericEnumTesting;
pub mod optional_testing;
pub use self::optional_testing::OptionalTesting;
pub mod order;

View File

@ -0,0 +1,42 @@
/*
* OpenAPI Petstore
*
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
use serde_repr::{Serialize_repr,Deserialize_repr};
/// NumericEnumTesting : 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 NumericEnumTesting {
Variant0 = 0,
Variant1 = 1,
Variant2 = 2,
Variant3 = 3,
}
impl ToString for NumericEnumTesting {
fn to_string(&self) -> String {
match self {
Self::Variant0 => String::from("0"),
Self::Variant1 => String::from("1"),
Self::Variant2 => String::from("2"),
Self::Variant3 => String::from("3"),
}
}
}
impl Default for NumericEnumTesting {
fn default() -> NumericEnumTesting {
Self::Variant0
}
}

View File

@ -10,6 +10,7 @@ docs/Category.md
docs/EnumArrayTesting.md
docs/FakeApi.md
docs/NullableArray.md
docs/NumericEnumTesting.md
docs/OptionalTesting.md
docs/Order.md
docs/Pet.md
@ -43,6 +44,7 @@ src/models/mod.rs
src/models/model_ref.rs
src/models/model_return.rs
src/models/nullable_array.rs
src/models/numeric_enum_testing.rs
src/models/optional_testing.rs
src/models/order.rs
src/models/pet.rs

View File

@ -10,6 +10,7 @@ edition = "2021"
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"] }
aws-sigv4 = "0.3.0"

View File

@ -60,6 +60,7 @@ Class | Method | HTTP request | Description
- [Category](docs/Category.md)
- [EnumArrayTesting](docs/EnumArrayTesting.md)
- [NullableArray](docs/NullableArray.md)
- [NumericEnumTesting](docs/NumericEnumTesting.md)
- [OptionalTesting](docs/OptionalTesting.md)
- [Order](docs/Order.md)
- [Pet](docs/Pet.md)

View File

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

View File

@ -1,6 +1,7 @@
#![allow(unused_imports)]
#![allow(clippy::too_many_arguments)]
extern crate serde_repr;
extern crate serde;
extern crate serde_json;
extern crate url;

View File

@ -12,6 +12,8 @@ pub mod enum_array_testing;
pub use self::enum_array_testing::EnumArrayTesting;
pub mod nullable_array;
pub use self::nullable_array::NullableArray;
pub mod numeric_enum_testing;
pub use self::numeric_enum_testing::NumericEnumTesting;
pub mod optional_testing;
pub use self::optional_testing::OptionalTesting;
pub mod order;

View File

@ -0,0 +1,42 @@
/*
* OpenAPI Petstore
*
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
use serde_repr::{Serialize_repr,Deserialize_repr};
/// NumericEnumTesting : 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 NumericEnumTesting {
Variant0 = 0,
Variant1 = 1,
Variant2 = 2,
Variant3 = 3,
}
impl ToString for NumericEnumTesting {
fn to_string(&self) -> String {
match self {
Self::Variant0 => String::from("0"),
Self::Variant1 => String::from("1"),
Self::Variant2 => String::from("2"),
Self::Variant3 => String::from("3"),
}
}
}
impl Default for NumericEnumTesting {
fn default() -> NumericEnumTesting {
Self::Variant0
}
}

View File

@ -10,6 +10,7 @@ docs/Category.md
docs/EnumArrayTesting.md
docs/FakeApi.md
docs/NullableArray.md
docs/NumericEnumTesting.md
docs/OptionalTesting.md
docs/Order.md
docs/Pet.md
@ -43,6 +44,7 @@ src/models/mod.rs
src/models/model_ref.rs
src/models/model_return.rs
src/models/nullable_array.rs
src/models/numeric_enum_testing.rs
src/models/optional_testing.rs
src/models/order.rs
src/models/pet.rs

View File

@ -10,6 +10,7 @@ edition = "2021"
serde = { version = "^1.0", features = ["derive"] }
serde_with = { version = "^3.8", default-features = false, features = ["base64", "std", "macros"] }
serde_json = "^1.0"
serde_repr = "^0.1"
url = "^2.5"
uuid = { version = "^1.8", features = ["serde", "v4"] }
reqwest = { version = "^0.12", features = ["json", "blocking", "multipart"] }

View File

@ -60,6 +60,7 @@ Class | Method | HTTP request | Description
- [Category](docs/Category.md)
- [EnumArrayTesting](docs/EnumArrayTesting.md)
- [NullableArray](docs/NullableArray.md)
- [NumericEnumTesting](docs/NumericEnumTesting.md)
- [OptionalTesting](docs/OptionalTesting.md)
- [Order](docs/Order.md)
- [Pet](docs/Pet.md)

View File

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

View File

@ -1,6 +1,7 @@
#![allow(unused_imports)]
#![allow(clippy::too_many_arguments)]
extern crate serde_repr;
extern crate serde;
extern crate serde_json;
extern crate url;

View File

@ -12,6 +12,8 @@ pub mod enum_array_testing;
pub use self::enum_array_testing::EnumArrayTesting;
pub mod nullable_array;
pub use self::nullable_array::NullableArray;
pub mod numeric_enum_testing;
pub use self::numeric_enum_testing::NumericEnumTesting;
pub mod optional_testing;
pub use self::optional_testing::OptionalTesting;
pub mod order;

View File

@ -0,0 +1,42 @@
/*
* OpenAPI Petstore
*
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
use serde_repr::{Serialize_repr,Deserialize_repr};
/// NumericEnumTesting : 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 NumericEnumTesting {
Variant0 = 0,
Variant1 = 1,
Variant2 = 2,
Variant3 = 3,
}
impl ToString for NumericEnumTesting {
fn to_string(&self) -> String {
match self {
Self::Variant0 => String::from("0"),
Self::Variant1 => String::from("1"),
Self::Variant2 => String::from("2"),
Self::Variant3 => String::from("3"),
}
}
}
impl Default for NumericEnumTesting {
fn default() -> NumericEnumTesting {
Self::Variant0
}
}