-
Notifications
You must be signed in to change notification settings - Fork 742
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
New rule: Noun in operationId must be different from Noun in Model definition #1950
Comments
This is going to be rather difficult to implement. Even if we validate that the "NOUN" in "NOUN_VERB" does not match with any of the defined models, we won't be able to clearly suggest a plural form for the model (the classic |
@dsgouda I agree, let's not try to get smart suggesting a specific name, let's just point out the conflict and suggest in the error text, that they could use the plural form of the NOUN to avoid the conflict. |
@vishrutshah suggested I comment here. The issue with the check right now is that you assume that there is actually a conflict when there may not be. For example this operation: In C# you get I think you get the point =) IMO this rule is too generator specific and you're making an assumption about the structure of the generated code which isn't even true. The only language that I know of where this actually conflicts is Node, and (IMO) the fix isn't to flag errors in the generator the fix is to make nodes type This avoids the awkward "add an s" (since then it's |
@dsgouda & @veronicagg Feel free to throw in your thoughts here... |
@matthchr |
@dsgouda No it's not - the behavior depends on language in AutoRest already. Look at JobOperations.cs for example. We do not have a model named job. It just generates it with the operations suffix as above by default. Again, as far as I know the behavior is like so: Please see this issue, which I filed a year ago pointing out the inconsistency. The point being -- since the code generators themselves aren't even consistent, I am not sure how you can give this warning consistently across all languages... and if you were to give a warning, since most code generators append Operations by default, you should probably suggest based on that rather than assuming that the generator doesn't append anything (since the majority do). edit Also looking through the filed issue for node I even suggested a linter rule (this linter rule), so I'm contradicting myself a bit here =P In any case, a discussion should be had about what the right rule is because I'm not 100% sure that it's the one you currently have... the issue with the one you have is while it's technically correct it's also super easy to hit (because of course every top level entity is going to have an associated operations class...) |
So, we do append |
@dsgouda @veronicagg I see that this rule is still around -- what are the plans related to it? |
This was slated to be removed might have fallen through the cracks. |
Issue opened here since all validation related code will be moved out of this repo. |
M1002: The NOUN in the OperationId "NOUN_VERB" MUST not match the name of the Model definition, to avoid a collision in the namespace, use the plural form of NOUN in the operationId.
Category: SDK Violation
Severity: Error
The text was updated successfully, but these errors were encountered: