-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Fix Enum Mismatch Issues in Search Service [DO NOT MERGE] #5665
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
Fix Enum Mismatch Issues in Search Service [DO NOT MERGE] #5665
Conversation
Automation for azure-sdk-for-jsUnable to detect any generation context from this PR. |
Automation for azure-sdk-for-pythonUnable to detect any generation context from this PR. |
Automation for azure-sdk-for-rubyUnable to detect any generation context from this PR. |
Automation for azure-sdk-for-goUnable to detect any generation context from this PR. |
Automation for azure-sdk-for-javaUnable to detect any generation context from this PR. |
|
Can one of the admins verify this patch? |
brjohnstmsft
left a comment
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.
@sarangan12 The original examples actually are valid for the Azure Search REST API; We just don't have the tools to express them in the Swagger and still get the codegen result that we want.
Is the intent of your change just to satisfy the validation rules? If so, I think there should be a better way. Soon we plan to use these examples in generated documentation, and it would be a shame if we have to make our examples less useful to just to satisfy validation rules that aren't yet sufficiently expressive.
|
@brjohnstmsft I am trying to understand the issue here. If the examples are correct. what is the meaning of 'Collection(Edm.String)'? If this is the actual value sent by the service, then why couldn't this be one of the actual enum value in the swagger? (instead of Edm.String) Could you please help me understand? |
|
@sarangan12 That particular property represents the data type of a field in Azure Search. Our service is OData-compliant, so it uses the EDM (Entity Data Model) type system.
Regarding the final reason, you'd think we'd just use We have plenty of other data types in our API that behave this way. For example, RegexFlags can be combined. In that case it just isn't practical to have every possible combination of flags in an enum. You could say that it would have been a better choice to model RegexFlags as an array of flags instead, and you'd be right, but we designed this part of the API a long time ago and are not willing to change it now as it is a breaking change that would create pain for our customers when upgrading to a new API version. Basically, the tools as they exist are not sufficiently flexible to accommodate the sometimes conflicting needs of precise specs and usable SDKs. |
|
@brjohnstmsft Thanks a lot for the explanation. Now, I understand the reasoning for the Collection &
Now, I did take a look at the way the enums are implemented and here are my findings (I will address your points after presenting my findings): Option 1 This definition will be translated to a enum type in C# SDK as seen here as: Now, in the places where this ‘CapabilityStatus’ is referenced, its data type will be ‘CapabilityStatus’ as seen here: Option 2 This definition will be translated to a static class with constants in C# SDK as seen here as: But, in the places where CapabilityGroup is referenced, the type will String and NOT CapabilityGroup as seen here as: As you can see, the type of ‘include’ is a string. So, you may use one of the constants defined in the static class (Eg: CapabilityGroup.SupportedEditions) or you may pass your own values. Option 3 After the optin, the enums can be simply defined with x-ms-enum/modelAsString. For example, refer the definition of ‘unit’ here as: In C# SDK, the ‘unit’ will be generated as a struct as here: In places where the ‘MetricUnit’ is referenced, the data type will be MetricUnit as here: Here you could use the values defined in the MetricUnit or pass in your own values. Option 4 & 5 (No Longer in use) Now, Let us come back to your points.
|
...osoft.Azure.Search.Service/preview/2017-11-11-preview/examples/SearchServiceCreateIndex.json
Show resolved
Hide resolved
|
@sarangan12 Thanks for the analysis. It looks like option 3 (opt-in-extensible-enums) is what we need. However, we are not ready to adopt it yet as the generated code doesn't quite match our requirements. We'll work with the AutoRest team after //build to make the necessary modifications. By the way, is |
|
@brjohnstmsft Thanks for the reply. I will also update @shahabhijeet to document |
|
@sarangan12 Sounds good, thanks! |
shahabhijeet
left a comment
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.
So search team will add opt-in flag in Readme to start using extensible enums.
If yes I am approving this PR.
|
@shahabhijeet This PR makes our examples less useful -- I would prefer that you not merge it. As discussed, we will opt-in to extensible enums after //build, and after we've made the feature in AutoRest do what we actually need. |
|
@brjohnstmsft Is this a good time to start our conversation back on the option 3? |
|
@sarangan12 Not yet. We have some bug fixes and incremental changes we need to ship. As soon as that's out, I'll be working on adapting our .NET SDK to the new source tree structure and build pipeline, then I'll look at this. |
|
@brjohnstmsft Is this a good time to start our conversation back on the option 3? |
|
@sarangan12 We don't have bandwidth right now to work on this, but might later in the year. I am tracking this and haven't forgotten about it. I'll follow up when it's time to revisit this. In the meantime, is this blocking anybody or causing any persistent issues with engineering systems infrastructure? |
|
@brjohnstmsft No blockers. Just wanted to remind you.... |
|
I'll close the PR for now since service team is not ready for it, and lots of conflicts already.. pls feel free to reopen it for discussion if ready. |
|
Just to close the loop, we are now working on this. |
Latest improvements:
MSFT employees can try out our new experience at OpenAPI Hub - one location for using our validation tools and finding your workflow.
Contribution checklist:
ARM API Review Checklist
Failure to comply may result in delays for manifest application. Note this does not apply to data plane APIs.
Please follow the link to find more details on API review process.