Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
akhilailla committed Sep 18, 2024
1 parent d7fc645 commit 57c599f
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions packages/rulesets/generated/spectral/az-arm.js
Original file line number Diff line number Diff line change
Expand Up @@ -2667,7 +2667,7 @@ var Workspace;
})(Workspace || (Workspace = {}));

require("string.prototype.matchall");
function isListOperation(path) {
function isListOperationPath(path) {
if (path.includes(".")) {
const splitNamespace = path.split(".");
if (path.includes("/")) {
Expand All @@ -2692,7 +2692,7 @@ const queryParametersInCollectionGet = (pathItem, _opts, ctx) => {
const GET = "get";
const errors = [];
for (const uri of uris) {
if (pathItem[uri][GET] && isListOperation(uri)) {
if (pathItem[uri][GET] && isListOperationPath(uri)) {
const params = pathItem[uri][GET]["parameters"];
const queryParams = params === null || params === void 0 ? void 0 : params.filter((param) => param.in === "query" && param.name !== "api-version" && param.name !== "$filter");
queryParams === null || queryParams === void 0 ? void 0 : queryParams.forEach((param) => {
Expand Down Expand Up @@ -3161,7 +3161,7 @@ const xmsPageableForListCalls = (swaggerObj, _opts, paths) => {
}
const path = paths.path || [];
if (!isNull(path[1])) {
if (!isListOperation(path[1].toString())) {
if (!isListOperationPath(path[1].toString())) {
return;
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/rulesets/src/native/utilities/arm-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import { ISwaggerInventory, parseJsonRef } from "@microsoft.azure/openapi-validator-core"
import _ from "lodash"
import { nodes } from "./jsonpath"
import { isListOperation } from "./rules-helper"
import { isListOperationPath } from "./rules-helper"
import { SwaggerHelper } from "./swagger-helper"
import { SwaggerWalker } from "./swagger-walker"
import { Workspace } from "./swagger-workspace"
Expand Down Expand Up @@ -298,7 +298,7 @@ export class ArmHelper {
const resWithPutOrPatch = includeGet
? localResourceModels.filter((re) =>
re.operations.some(
(op) => (op.httpMethod === "get" && !isListOperation(op.apiPath)) || op.httpMethod === "put" || op.httpMethod == "patch",
(op) => (op.httpMethod === "get" && !isListOperationPath(op.apiPath)) || op.httpMethod === "put" || op.httpMethod == "patch",
),
)
: localResourceModels.filter((re) => re.operations.some((op) => op.httpMethod === "put" || op.httpMethod == "patch"))
Expand Down
2 changes: 1 addition & 1 deletion packages/rulesets/src/native/utilities/rules-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export function stringify(path: string[]) {
return JSONPath.toPathString(pathWithRoot)
}

export function isListOperation(path: string) {
export function isListOperationPath(path: string) {
if (path.includes(".")) {
// Get the portion of the api path to the right of the provider namespace by splitting the path by '.' and taking the last element
const splitNamespace = path.split(".")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isListOperation } from "../../native/utilities/rules-helper"
import { isListOperationPath } from "../../native/utilities/rules-helper"

export const queryParametersInCollectionGet = (pathItem: any, _opts: any, ctx: any) => {
if (pathItem === null || typeof pathItem !== "object") {
Expand All @@ -15,7 +15,7 @@ export const queryParametersInCollectionGet = (pathItem: any, _opts: any, ctx: a

for (const uri of uris) {
//check if GET op is defined & the GET op is a collection get/list call
if (pathItem[uri][GET] && isListOperation(uri)) {
if (pathItem[uri][GET] && isListOperationPath(uri)) {
const params = pathItem[uri][GET]["parameters"]
const queryParams = params?.filter(
(param: { in: string; name: string }) => param.in === "query" && param.name !== "api-version" && param.name !== "$filter",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { isNull } from "lodash"
import { isListOperation } from "../../native/utilities/rules-helper"
import { isListOperationPath } from "../../native/utilities/rules-helper"

const xmsPageableForListCalls = (swaggerObj: any, _opts: any, paths: any) => {
if (swaggerObj === null) {
Expand All @@ -11,7 +11,7 @@ const xmsPageableForListCalls = (swaggerObj: any, _opts: any, paths: any) => {
// 1 - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Music/Configurations
// 2 - get
if (!isNull(path[1])) {
if (!isListOperation(path[1].toString())) {
if (!isListOperationPath(path[1].toString())) {
return
}
}
Expand Down

0 comments on commit 57c599f

Please sign in to comment.