-
Notifications
You must be signed in to change notification settings - Fork 203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modify Enum conversions to be case-insensitive/case-correcting #3880
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3880 +/- ##
==========================================
+ Coverage 53.53% 53.70% +0.16%
==========================================
Files 1523 1525 +2
Lines 550082 552819 +2737
==========================================
+ Hits 294510 296878 +2368
- Misses 210035 210392 +357
- Partials 45537 45549 +12 ☔ View full report in Codecov by Sentry. |
v2/api/apimanagement/v1api20220801/api_version_set_types_gen.go
Outdated
Show resolved
Hide resolved
v2/api/apimanagement/v1api20220801/api_version_set_types_gen.go
Outdated
Show resolved
Hide resolved
v2/api/apimanagement/v1api20230501preview/storage/api_types_gen.go
Outdated
Show resolved
Hide resolved
22c04f4
to
c00fb31
Compare
c00fb31
to
b233fab
Compare
d3f7467
to
aa111dd
Compare
|
||
// ToEnum does a case-insensitive conversion of a string to an enum using a provided conversion map. | ||
// If the required value is not found, a literal cast will be used to return the enum. | ||
func ToEnum[T ~string](str string, enumMap map[string]T) T { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very cool
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. Full credit though - you gave me the method signature. 😁
@@ -298,6 +298,11 @@ type FakeResource_APIVersion_Spec string | |||
|
|||
const FakeResource_APIVersion_Spec_20200601 = FakeResource_APIVersion_Spec("2020-06-01") | |||
|
|||
// Mapping from string to FakeResource_APIVersion_Spec | |||
var fakeResource_APIVersion_Spec_Values = map[string]FakeResource_APIVersion_Spec{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any idea why this apiversion in the test isn't getting excluded?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the type isn't called exactly APIVersion
- I'm guessing because the name isn't being simplified in the same way as the main pipeline.
What this PR does / why we need it:
In some cases information returned about a resource is is inconsistent with the letter casing specified in the OpenAPI specs for a resource - for example, the specs might specify
Succeeded
but the service returnssucceeded
.This PR modifies enum conversion to work in a case-insensitive way, which will case-correct values to conform with the OpenAPI specs.
Special notes for your reviewer:
The conversion from
status
tospec
used by asoctl will also pick up this fix.Closes #3805
How does this PR make you feel: