mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-03 00:43:46 +00:00
Fix enum types in structs (#3309)
I already contributed proper enum supports a few weeks ago, but somehow missed actually using them when they're used as a property. This PR fixes that. I also took the liberty of fixing a bunch of unused warnings. * Make sure we use the enum types in Rust * Fix unused warnings in Rust and regenerate samples * Use crate:: import path that works both with Rust 2015 and 2018 * Derive PartialEq and Eq in generated Rust structs and enums
This commit is contained in:
committed by
Benjamin Gill
parent
a4b1c269d8
commit
2e81e612fc
@@ -11,7 +11,7 @@
|
||||
/// ApiResponse : Describes the result of uploading an image resource
|
||||
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct ApiResponse {
|
||||
#[serde(rename = "code", skip_serializing_if = "Option::is_none")]
|
||||
pub code: Option<i32>,
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
/// Category : A category for a pet
|
||||
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct Category {
|
||||
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
|
||||
pub id: Option<i64>,
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
/// Order : An order for a pets from the pet store
|
||||
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct Order {
|
||||
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
|
||||
pub id: Option<i64>,
|
||||
@@ -23,7 +23,7 @@ pub struct Order {
|
||||
pub ship_date: Option<String>,
|
||||
/// Order Status
|
||||
#[serde(rename = "status", skip_serializing_if = "Option::is_none")]
|
||||
pub status: Option<String>,
|
||||
pub status: Option<Status>,
|
||||
#[serde(rename = "complete", skip_serializing_if = "Option::is_none")]
|
||||
pub complete: Option<bool>,
|
||||
}
|
||||
@@ -43,7 +43,7 @@ impl Order {
|
||||
}
|
||||
|
||||
/// Order Status
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum Status {
|
||||
#[serde(rename = "placed")]
|
||||
Placed,
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
/// Pet : A pet for sale in the pet store
|
||||
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct Pet {
|
||||
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
|
||||
pub id: Option<i64>,
|
||||
@@ -25,7 +25,7 @@ pub struct Pet {
|
||||
pub tags: Option<Vec<crate::models::Tag>>,
|
||||
/// pet status in the store
|
||||
#[serde(rename = "status", skip_serializing_if = "Option::is_none")]
|
||||
pub status: Option<String>,
|
||||
pub status: Option<Status>,
|
||||
}
|
||||
|
||||
impl Pet {
|
||||
@@ -43,7 +43,7 @@ impl Pet {
|
||||
}
|
||||
|
||||
/// pet status in the store
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum Status {
|
||||
#[serde(rename = "available")]
|
||||
Available,
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
/// Tag : A tag for a pet
|
||||
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct Tag {
|
||||
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
|
||||
pub id: Option<i64>,
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
/// User : A User who is purchasing from the pet store
|
||||
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct User {
|
||||
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
|
||||
pub id: Option<i64>,
|
||||
|
||||
Reference in New Issue
Block a user