-
Notifications
You must be signed in to change notification settings - Fork 738
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
Filtering resource models returned only by post #2365
Changes from 8 commits
6ba6fff
42016bc
599bed2
d4d5343
16b14d6
c8a7b2b
d1dec80
af827e3
4cc9ab5
4cdde45
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,10 +57,18 @@ public static IEnumerable<string> GetResourceModels(ServiceDefinition serviceDef | |
.Where(modelName => !(IsBaseResourceModelName(modelName)) | ||
&& serviceDefinition.Definitions.ContainsKey(modelName) | ||
&& IsAllOfOnModelNames(modelName, serviceDefinition.Definitions, xmsAzureResourceModels)); | ||
|
||
// return the union | ||
return resourceModels.Union(modelsAllOfOnXmsAzureResources); | ||
|
||
var resourceCandidates = resourceModels.Union(modelsAllOfOnXmsAzureResources); | ||
|
||
// Now filter all the resource models that are returned from a POST operation only | ||
var postOpResourceModels = serviceDefinition.Paths.Values.SelectMany(pathObj => pathObj.Where(opObj => opObj.Key.EqualsIgnoreCase("post")) | ||
.SelectMany(opObj => opObj.Value.Responses?.Select(resp => resp.Value?.Schema?.Reference?.StripDefinitionPath())??Enumerable.Empty<string>())) | ||
.Where(model => !string.IsNullOrWhiteSpace(model)) | ||
.Except(putOperationsResponseModels) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. don't implement the "only" by relying on other sets and excepting them.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how about looking into the models returned by operations and selecting the ones that are only returned by posts? then removing those from the previous set? I would probably not call it "unfiltered" set, since it's already quite filtered, maybe "resourceCandidates". There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I literally called it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @veronicagg that is what I am precisely trying to do There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sounds good, how does the rule perform on the specs repo? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, this is not a rule per se, more like pre cursor step to running any arm related validation rules. |
||
.Except(getOperationsResponseModels); | ||
|
||
// if any model is returned only by a POST operation, disregard it | ||
return resourceCandidates.Except(postOpResourceModels); | ||
} | ||
|
||
public static bool IsODataProperty(string propName) => propName.ToLower().StartsWith("@"); | ||
|
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.
I don't see the "only" part reflected in the code but maybe I'm missing it.
Also, the indentation is misleading: the
.SelectMany
calls are perfectly aligned but are not operating on the same "level". I'd expect the secondSelectMany
to be on the same height as the innerWhere
, just breakpathObj => pathObj<HERE>.Where
and lines won't be that long.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.
d'oh (I went everywhere looking for a Homer emoji!)