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

Change disableForTypeSpec to disableForTypeSpecDataPlane #713

Merged
merged 5 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/azure-openapi-validator/autorest/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@microsoft.azure/openapi-validator",
"version": "2.2.2",
"version": "2.2.3",
"description": "Azure OpenAPI Validator",
"main": "./dist/index.js",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export async function spectralPluginFunc(initiator: IAutoRestPluginInitiator): P
rulesetPayload,
rulesetForManualSpecs,
rulesetForTypeSpecGeneratedSpecs,
openApiSpecFile
openApiSpecFile,
)
}

Expand All @@ -68,15 +68,18 @@ export async function spectralPluginFunc(initiator: IAutoRestPluginInitiator): P
async function getRulesets(
initiator: IAutoRestPluginInitiator,
resolvedOpenapiType: OpenApiTypes,
isStagingRun: boolean
isStagingRun: boolean,
): Promise<{
rulesetPayload: SpectralRulesetPayload
rulesetForManualSpecs: Ruleset
rulesetForTypeSpecGeneratedSpecs: Ruleset
}> {
const rulesetPayload: SpectralRulesetPayload = await getRulesetPayload(initiator, resolvedOpenapiType)
const namesOfRulesInStagingOnly: string[] = getNamesOfRulesInPayloadWithPropertySetToTrue(rulesetPayload, "stagingOnly")
const namesOfRulesDisabledForTypespec: string[] = getNamesOfRulesInPayloadWithPropertySetToTrue(rulesetPayload, "disableForTypeSpec")
const namesOfRulesDisabledForTypespecDataPlane: string[] =
resolvedOpenapiType === OpenApiTypes.dataplane
? getNamesOfRulesInPayloadWithPropertySetToTrue(rulesetPayload, "disableForTypeSpecDataPlane")
: []

// We need two of rulesetPayloads:
// - The original, to prepare it as argument for spectral Rulesets. See deletePropertiesNotValidForSpectralRules for more.
Expand All @@ -93,7 +96,7 @@ async function getRulesets(

const rulesetForTypeSpecGeneratedSpecs = new Ruleset(rulesetPayload, { severity: "recommended" })
ifNotStagingRunDisableRulesInStagingOnly(initiator, namesOfRulesInStagingOnly, isStagingRun, rulesetForTypeSpecGeneratedSpecs)
disableRulesInRuleset(rulesetForTypeSpecGeneratedSpecs, namesOfRulesDisabledForTypespec)
disableRulesInRuleset(rulesetForTypeSpecGeneratedSpecs, namesOfRulesDisabledForTypespecDataPlane)
printRuleNames(initiator, rulesetForTypeSpecGeneratedSpecs, resolvedOpenapiType, "TypeSpec-generated OpenAPI specs")

return {
Expand All @@ -108,7 +111,7 @@ async function validateOpenApiSpecFileUsingSpectral(
rulesetPayload: SpectralRulesetPayload,
rulesetForManualSpecs: Ruleset,
rulesetForTypeSpecGeneratedSpecs: Ruleset,
openApiSpecFile: string
openApiSpecFile: string,
) {
if (openApiSpecFile.includes("common-types/resource-management")) {
initiator.Message({
Expand Down
48 changes: 24 additions & 24 deletions packages/rulesets/generated/spectral/az-arm.js
Original file line number Diff line number Diff line change
Expand Up @@ -845,8 +845,8 @@ const ruleset$1 = {
description: "Operation should have a summary or description.",
message: "Operation should have a summary or description.",
severity: "warn",
disableForTypeSpec: false,
disableForTypeSpecReason: "Covered by TSP's '@azure-tools/typespec-azure-core/documentation-required' rule.",
disableForTypeSpecDataPlane: true,
disableForTypeSpecDataPlaneReason: "Covered by TSP's '@azure-tools/typespec-azure-core/documentation-required' rule.",
given: [
"$.paths[*][?( @property === 'get' && [email protected] && [email protected] )]",
"$.paths[*][?( @property === 'put' && [email protected] && [email protected] )]",
Expand All @@ -865,8 +865,8 @@ const ruleset$1 = {
description: "All schemas should have a description or title.",
message: "Schema should have a description or title.",
severity: "warn",
disableForTypeSpec: false,
disableForTypeSpecReason: "Covered by TSP's '@azure-tools/typespec-azure-core/documentation-required' rule.",
disableForTypeSpecDataPlane: true,
disableForTypeSpecDataPlaneReason: "Covered by TSP's '@azure-tools/typespec-azure-core/documentation-required' rule.",
formats: [oas2, oas3],
given: ["$.definitions[?([email protected] && [email protected])]", "$.components.schemas[?([email protected] && [email protected])]"],
then: {
Expand All @@ -877,8 +877,8 @@ const ruleset$1 = {
description: "All parameters should have a description.",
message: "Parameter should have a description.",
severity: "warn",
disableForTypeSpec: false,
disableForTypeSpecReason: "Covered by TSP's '@azure-tools/typespec-azure-core/documentation-required' rule.",
disableForTypeSpecDataPlane: true,
disableForTypeSpecDataPlaneReason: "Covered by TSP's '@azure-tools/typespec-azure-core/documentation-required' rule.",
given: ["$.paths[*].parameters.*", "$.paths.*[get,put,post,patch,delete,options,head].parameters.*"],
then: {
field: "description",
Expand Down Expand Up @@ -1193,8 +1193,8 @@ const ruleset$1 = {
description: "The value of the 'description' property must be descriptive. It cannot be spaces or empty description.",
message: "'{{property}}' parameter lacks 'description' property. Consider adding a 'description' element. Accurate description is essential for maintaining reference documentation.",
severity: "error",
disableForTypeSpec: false,
disableForTypeSpecReason: "Covered by TSP's '@azure-tools/typespec-azure-core/documentation-required' rule.",
disableForTypeSpecDataPlane: true,
disableForTypeSpecDataPlaneReason: "Covered by TSP's '@azure-tools/typespec-azure-core/documentation-required' rule.",
resolved: false,
formats: [oas2],
given: ["$.parameters.*"],
Expand Down Expand Up @@ -2993,8 +2993,8 @@ const ruleset = {
rpcGuidelineCode: "RPC-Async-V1-01, RPC-Put-V1-11",
description: "LRO and Synchronous PUT must have 200 & 201 return codes.",
severity: "error",
disableForTypeSpec: false,
disableForTypeSpecReason: "Covered by TSP's '@azure-tools/typespec-azure-resource-manager/arm-put-operation-response-codes' rule.",
disableForTypeSpecDataPlane: true,
disableForTypeSpecDataPlaneReason: "Covered by TSP's '@azure-tools/typespec-azure-resource-manager/arm-put-operation-response-codes' rule.",
message: "{{error}}",
resolved: true,
formats: [oas2],
Expand Down Expand Up @@ -3034,8 +3034,8 @@ const ruleset = {
description: "ProvisioningState must have terminal states: Succeeded, Failed and Canceled.",
message: "{{error}}",
severity: "error",
disableForTypeSpec: false,
disableForTypeSpecReason: "Covered by TSP's '@azure-tools/typespec-azure-resource-manager/arm-resource-provisioning-state' rule.",
disableForTypeSpecDataPlane: true,
disableForTypeSpecDataPlaneReason: "Covered by TSP's '@azure-tools/typespec-azure-resource-manager/arm-resource-provisioning-state' rule.",
resolved: false,
formats: [oas2],
given: ["$.definitions..provisioningState[?(@property === 'enum')]^", "$.definitions..ProvisioningState[?(@property === 'enum')]^"],
Expand All @@ -3048,8 +3048,8 @@ const ruleset = {
description: "Location header must be supported for all async operations that return 202.",
message: "A 202 response should include an Location response header.",
severity: "error",
disableForTypeSpec: false,
disableForTypeSpecReason: "Covered by TSP's '@azure-tools/typespec-azure-resource-manager/arm-location-header' rule.",
disableForTypeSpecDataPlane: true,
disableForTypeSpecDataPlaneReason: "Covered by TSP's '@azure-tools/typespec-azure-resource-manager/arm-location-header' rule.",
formats: [oas2],
given: "$.paths[*][*].responses[?(@property == '202')]",
then: {
Expand All @@ -3063,8 +3063,8 @@ const ruleset = {
rpcGuidelineCode: "RPC-Async-V1-11, RPC-Async-V1-14",
description: "Synchronous POST must have either 200 or 204 return codes and LRO POST must have 202 return code. LRO POST should also have a 200 return code only if the final response is intended to have a schema",
severity: "error",
disableForTypeSpec: false,
disableForTypeSpecReason: "Covered by TSP's '@azure-tools/typespec-azure-resource-manager/arm-post-operation-response-codes' rule.",
disableForTypeSpecDataPlane: true,
disableForTypeSpecDataPlaneReason: "Covered by TSP's '@azure-tools/typespec-azure-resource-manager/arm-post-operation-response-codes' rule.",
message: "{{error}}",
resolved: true,
formats: [oas2],
Expand All @@ -3090,8 +3090,8 @@ const ruleset = {
description: "This is a rule introduced to validate if provisioningState property is set to readOnly or not.",
message: "{{error}}",
severity: "error",
disableForTypeSpec: false,
disableForTypeSpecReason: "Covered by TSP's '@azure-tools/typespec-azure-resource-manager/arm-resource-provisioning-state' rule.",
disableForTypeSpecDataPlane: true,
disableForTypeSpecDataPlaneReason: "Covered by TSP's '@azure-tools/typespec-azure-resource-manager/arm-resource-provisioning-state' rule.",
resolved: true,
formats: [oas2],
given: ["$[paths,'x-ms-paths'].*.*.responses.*.schema"],
Expand Down Expand Up @@ -3119,8 +3119,8 @@ const ruleset = {
description: "Synchronous DELETE must have 200 & 204 return codes and LRO DELETE must have 202 & 204 return codes.",
severity: "error",
message: "{{error}}",
disableForTypeSpec: false,
disableForTypeSpecReason: "Covered by TSP's '@azure-tools/typespec-azure-resource-manager/arm-delete-operation-response-codes' rule.",
disableForTypeSpecDataPlane: true,
disableForTypeSpecDataPlaneReason: "Covered by TSP's '@azure-tools/typespec-azure-resource-manager/arm-delete-operation-response-codes' rule.",
resolved: true,
formats: [oas2],
given: ["$[paths,'x-ms-paths'].*[delete]"],
Expand Down Expand Up @@ -3157,8 +3157,8 @@ const ruleset = {
description: "Definitions must not have properties named additionalProperties except for user defined tags or predefined references.",
severity: "error",
message: "{{description}}",
disableForTypeSpec: false,
disableForTypeSpecReason: "Covered by TSP's '@azure-tools/typespec-azure-resource-manager/no-record' rule.",
disableForTypeSpecDataPlane: true,
disableForTypeSpecDataPlaneReason: "Covered by TSP's '@azure-tools/typespec-azure-resource-manager/no-record' rule.",
resolved: false,
formats: [oas2],
given: "$.definitions..[?(@property !== 'tags' && @property !== 'delegatedResources' && @property !== 'userAssignedIdentities' && @ && @.additionalProperties)]",
Expand Down Expand Up @@ -3574,8 +3574,8 @@ const ruleset = {
description: "This rule ensures that the authors explicitly define these restrictions as a regex on the resource name.",
message: "{{error}}",
severity: "error",
disableForTypeSpec: false,
disableForTypeSpecReason: "Covered by TSP's '@azure-tools/typespec-azure-resource-manager/arm-resource-name-pattern' rule.",
disableForTypeSpecDataPlane: true,
disableForTypeSpecDataPlaneReason: "Covered by TSP's '@azure-tools/typespec-azure-resource-manager/arm-resource-name-pattern' rule.",
resolved: true,
formats: [oas2],
given: "$[paths,'x-ms-paths'].*.^",
Expand Down
16 changes: 8 additions & 8 deletions packages/rulesets/generated/spectral/az-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -613,8 +613,8 @@ const ruleset = {
description: "Operation should have a summary or description.",
message: "Operation should have a summary or description.",
severity: "warn",
disableForTypeSpec: false,
disableForTypeSpecReason: "Covered by TSP's '@azure-tools/typespec-azure-core/documentation-required' rule.",
disableForTypeSpecDataPlane: true,
disableForTypeSpecDataPlaneReason: "Covered by TSP's '@azure-tools/typespec-azure-core/documentation-required' rule.",
given: [
"$.paths[*][?( @property === 'get' && [email protected] && [email protected] )]",
"$.paths[*][?( @property === 'put' && [email protected] && [email protected] )]",
Expand All @@ -633,8 +633,8 @@ const ruleset = {
description: "All schemas should have a description or title.",
message: "Schema should have a description or title.",
severity: "warn",
disableForTypeSpec: false,
disableForTypeSpecReason: "Covered by TSP's '@azure-tools/typespec-azure-core/documentation-required' rule.",
disableForTypeSpecDataPlane: true,
disableForTypeSpecDataPlaneReason: "Covered by TSP's '@azure-tools/typespec-azure-core/documentation-required' rule.",
formats: [oas2, oas3],
given: ["$.definitions[?([email protected] && [email protected])]", "$.components.schemas[?([email protected] && [email protected])]"],
then: {
Expand All @@ -645,8 +645,8 @@ const ruleset = {
description: "All parameters should have a description.",
message: "Parameter should have a description.",
severity: "warn",
disableForTypeSpec: false,
disableForTypeSpecReason: "Covered by TSP's '@azure-tools/typespec-azure-core/documentation-required' rule.",
disableForTypeSpecDataPlane: true,
disableForTypeSpecDataPlaneReason: "Covered by TSP's '@azure-tools/typespec-azure-core/documentation-required' rule.",
given: ["$.paths[*].parameters.*", "$.paths.*[get,put,post,patch,delete,options,head].parameters.*"],
then: {
field: "description",
Expand Down Expand Up @@ -961,8 +961,8 @@ const ruleset = {
description: "The value of the 'description' property must be descriptive. It cannot be spaces or empty description.",
message: "'{{property}}' parameter lacks 'description' property. Consider adding a 'description' element. Accurate description is essential for maintaining reference documentation.",
severity: "error",
disableForTypeSpec: false,
disableForTypeSpecReason: "Covered by TSP's '@azure-tools/typespec-azure-core/documentation-required' rule.",
disableForTypeSpecDataPlane: true,
disableForTypeSpecDataPlaneReason: "Covered by TSP's '@azure-tools/typespec-azure-core/documentation-required' rule.",
resolved: false,
formats: [oas2],
given: ["$.parameters.*"],
Expand Down
32 changes: 16 additions & 16 deletions packages/rulesets/generated/spectral/az-dataplane.js
Original file line number Diff line number Diff line change
Expand Up @@ -643,8 +643,8 @@ const ruleset$1 = {
description: "Operation should have a summary or description.",
message: "Operation should have a summary or description.",
severity: "warn",
disableForTypeSpec: false,
disableForTypeSpecReason: "Covered by TSP's '@azure-tools/typespec-azure-core/documentation-required' rule.",
disableForTypeSpecDataPlane: true,
disableForTypeSpecDataPlaneReason: "Covered by TSP's '@azure-tools/typespec-azure-core/documentation-required' rule.",
given: [
"$.paths[*][?( @property === 'get' && [email protected] && [email protected] )]",
"$.paths[*][?( @property === 'put' && [email protected] && [email protected] )]",
Expand All @@ -663,8 +663,8 @@ const ruleset$1 = {
description: "All schemas should have a description or title.",
message: "Schema should have a description or title.",
severity: "warn",
disableForTypeSpec: false,
disableForTypeSpecReason: "Covered by TSP's '@azure-tools/typespec-azure-core/documentation-required' rule.",
disableForTypeSpecDataPlane: true,
disableForTypeSpecDataPlaneReason: "Covered by TSP's '@azure-tools/typespec-azure-core/documentation-required' rule.",
formats: [oas2, oas3],
given: ["$.definitions[?([email protected] && [email protected])]", "$.components.schemas[?([email protected] && [email protected])]"],
then: {
Expand All @@ -675,8 +675,8 @@ const ruleset$1 = {
description: "All parameters should have a description.",
message: "Parameter should have a description.",
severity: "warn",
disableForTypeSpec: false,
disableForTypeSpecReason: "Covered by TSP's '@azure-tools/typespec-azure-core/documentation-required' rule.",
disableForTypeSpecDataPlane: true,
disableForTypeSpecDataPlaneReason: "Covered by TSP's '@azure-tools/typespec-azure-core/documentation-required' rule.",
given: ["$.paths[*].parameters.*", "$.paths.*[get,put,post,patch,delete,options,head].parameters.*"],
then: {
field: "description",
Expand Down Expand Up @@ -991,8 +991,8 @@ const ruleset$1 = {
description: "The value of the 'description' property must be descriptive. It cannot be spaces or empty description.",
message: "'{{property}}' parameter lacks 'description' property. Consider adding a 'description' element. Accurate description is essential for maintaining reference documentation.",
severity: "error",
disableForTypeSpec: false,
disableForTypeSpecReason: "Covered by TSP's '@azure-tools/typespec-azure-core/documentation-required' rule.",
disableForTypeSpecDataPlane: true,
disableForTypeSpecDataPlaneReason: "Covered by TSP's '@azure-tools/typespec-azure-core/documentation-required' rule.",
resolved: false,
formats: [oas2],
given: ["$.parameters.*"],
Expand Down Expand Up @@ -1950,8 +1950,8 @@ const ruleset = {
rules: {
AdditionalPropertiesAndProperties: {
description: "Don't specify additionalProperties as a sibling of properties.",
disableForTypeSpec: true,
disableForTypeSpecReason: "Covered by TSP's '@azure-tools/typespec-azure-core/bad-record-type' rule.",
disableForTypeSpecDataPlane: true,
disableForTypeSpecDataPlaneReason: "Covered by TSP's '@azure-tools/typespec-azure-core/bad-record-type' rule.",
severity: "warn",
formats: [oas2, oas3],
given: "$..[?(@object() && @.type === 'object' && @.properties)]",
Expand Down Expand Up @@ -2074,8 +2074,8 @@ const ruleset = {
Nullable: {
description: "Avoid the use of x-nullable.",
severity: "warn",
disableForTypeSpec: true,
disableForTypeSpecReason: "Covered by Azure Core '@azure-tools/typespec-azure-core/no-nullable' rule",
disableForTypeSpecDataPlane: true,
disableForTypeSpecDataPlaneReason: "Covered by Azure Core '@azure-tools/typespec-azure-core/no-nullable' rule",
formats: [oas2, oas3],
resolved: false,
given: "$..x-nullable",
Expand Down Expand Up @@ -2202,8 +2202,8 @@ const ruleset = {
description: "All schema properties should have a description.",
message: "Property should have a description.",
severity: "warn",
disableForTypeSpec: true,
disableForTypeSpecReason: "Covered by TSP's '@azure-tools/typespec-azure-core/documentation-required' rule.",
disableForTypeSpecDataPlane: true,
disableForTypeSpecDataPlaneReason: "Covered by TSP's '@azure-tools/typespec-azure-core/documentation-required' rule.",
resolved: false,
given: "$..properties[?(@object() && @.$ref == undefined)]",
then: {
Expand Down Expand Up @@ -2263,8 +2263,8 @@ const ruleset = {
description: "Schema names should be Pascal case.",
message: "Schema name should be Pascal case.",
severity: "warn",
disableForTypeSpec: true,
disableForTypeSpecReason: "Covered by TSP's '@azure-tools/typespec-azure-core/casing-style' rule.",
disableForTypeSpecDataPlane: true,
disableForTypeSpecDataPlaneReason: "Covered by TSP's '@azure-tools/typespec-azure-core/casing-style' rule.",
formats: [oas2],
given: "$.definitions.*~",
then: {
Expand Down
Loading