Skip to content
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

Add ability for ARM report #422

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft

Add ability for ARM report #422

wants to merge 8 commits into from

Conversation

jianyexi
Copy link
Contributor

@jianyexi jianyexi commented Dec 9, 2022

Fixed #421

  1. parse namespace and resource type from the swagger paths
  2. add verbose message for passed rules.

after the PR, the message will contain 'details.providerNamespace' and 'details.resourceType' fields when the jsonpath contains a swagger path

{
  "pluginName": "spectral",
  "extensionName": "@microsoft.azure/openapi-validator",
  "level": "warning",
  "message": "The x-ms-long-running-operation-options should be specified explicitly to indicate the type of response header to track the async operation.",
  "code": "XmsLongRunningOperationOptions",
  "details": {
    "jsonpath": [
      "paths",
      "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}",
      "put"
    ],
    "providerNamespace": "Microsoft.App",
    "resourceType": "containerApps",
    "range": {
      "start": {
        "line": 148,
        "column": 12
      },
      "end": {
        "line": 210,
        "column": 43
      }
    }
  },
  "source": [
    {
      "document": "specification/app/resource-manager/Microsoft.App/preview/2022-11-01-preview/ContainerApps.json",
      "position": {
        "line": 148,
        "column": 7
      }
    }
  ]
}

And the verbose message would like

{
  "pluginName": "spectral",
  "extensionName": "@microsoft.azure/openapi-validator",
  "level": "verbose",
  "message": "[Verbose]this is a verbose message to indicate that this rule was passed for specific swagger schema successfully and no fix is needed, please ignore it.",
  "code": "DefinitionsPropertiesNamesCamelCase",
  "details": {
    "jsonpath": [
      "definitions",
      "Certificate",
      "properties",
      "properties",
      "properties",
      "expirationDate"
    ],
    "providerNamespace": "",
    "resourceType": "",
    "range": {
      "start": {
        "line": 912,
        "column": 29
      },
      "end": {
        "line": 916,
        "column": 30
      }
    }
  },
  "source": [],
  "uptime": "6.09"
}

@@ -174,3 +176,16 @@ export function isSchemaEqual(a: any, b: any): boolean {
}
return false;
}

export function createRuleFunctionWithPasses<I = unknown, O = unknown>(fn:(input:I, options:O, ctx: RulesetFunctionContext)=> IFunctionResult[]) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

createRuleFunctionWithPasses

createRuleFunctionForEmittingSuccessMessage

const messsages = fn(input,options,ctx)
if (messsages.length === 0) {
messsages.push({
message: `[Verbose]this is a verbose message to indicate that this rule was passed for specific swagger schema successfully and no fix is needed, please ignore it.`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a verbose message to indicate that this rule was passed for specific swagger schema successfully and no fix is needed, please ignore it.

How about this text for the verbose message - "ARM RPC rule passed for path {path}" ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The path is another field of the error object, I think we don't need to duplicate it in the message

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ability to build ARM summary report
2 participants