Allow integer enums to have correct integer serialization#104
Draft
clux wants to merge 2 commits into
Draft
Conversation
Signed-off-by: clux <sszynrae@gmail.com>
Signed-off-by: clux <sszynrae@gmail.com>
Member
Author
|
Well, the test actually works even without repr (surprisingly), but turns out the enum isn't actually used in the schema because kopium just infers #[derive(Serialize, Deserialize, Clone, Debug)]
pub struct HTTPRouteRulesFiltersRequestRedirect {
...
#[serde(default, skip_serializing_if = "Option::is_none", rename = "statusCode")]
pub status_code: Option<i64>,
}
#[derive(Serialize, Deserialize, Clone, Debug)]
pub enum HTTPRouteRulesFiltersRequestRedirectStatusCode {
#[serde(rename = "301")]
r#_301 = 301,
#[serde(rename = "302")]
r#_302 = 302,
} |
Member
Author
|
I think we actually just look at the type in the schema: statusCode:
default: 302
description: "StatusCode is the HTTP status
code to be used in response. \n Support: Core
\n Note that values may be added to this enum,
implementations must ensure that unknown values
will not cause a crash. \n Unknown values
here must result in the implementation setting
the Accepted Condition for the Route to `status:
False`, with a Reason of `UnsupportedValue`."
enum:
- 301
- 302
type: integerand see, "oh, yeah, integer" and then separately recurse down to find enum structs (which then generates the struct - which isn't used). I think this is a reflection of #101 that enums are not parsed at the right level. I'll try to have another look at this tomorrow. |
Member
Author
|
Was hoping to have time to fix this properly, but don't want to block the release for it anymore. Doing this properly needs a bigger refactor of the analyzer for enums, and utimately there's a lot of great improvements in main already. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
serde_repr#[serde(rename)]attrs onserde_reprenumsLast thing I want to fix before next release.