diff --git a/.workleap.rules.yaml b/.workleap.rules.yaml index b6f2f45..bc9a745 100644 --- a/.workleap.rules.yaml +++ b/.workleap.rules.yaml @@ -25,7 +25,8 @@ rules: functionOptions: match: '^[a-zA-Z0-9]+$' - schemas-properties-must-have-a-type-backend: + # For backward compatibility + schemas-properties-must-have-a-type: description: "All schemas properties must have a type or schema reference. Refer to: https://gsoftdev.atlassian.net/wiki/spaces/TEC/pages/3858235678/IDP+OpenAPI+Rulesets#schemas-properties-must-have-a-type-and-path-schema-properties-must-have-a-type" recommended: true severity: warn @@ -39,6 +40,13 @@ rules: - required: ["type"] - required: ["$ref"] + schemas-properties-must-have-a-type-backend: + description: "All schemas properties must have a type or schema reference. Refer to: https://gsoftdev.atlassian.net/wiki/spaces/TEC/pages/3858235678/IDP+OpenAPI+Rulesets#schemas-properties-must-have-a-type-and-path-schema-properties-must-have-a-type" + recommended: true + severity: warn + given: $..schemas.*.properties.* + then: *type-or-ref-check + schemas-properties-must-have-a-type-frontend: description: "All schemas properties must have a type, schema reference, or composition keyword (allOf/anyOf/oneOf). Refer to: https://gsoftdev.atlassian.net/wiki/spaces/TEC/pages/3858235678/IDP+OpenAPI+Rulesets#schemas-properties-must-have-a-type-and-path-schema-properties-must-have-a-type" recommended: true @@ -56,6 +64,14 @@ rules: - required: ["anyOf"] - required: ["oneOf"] + # For backward compatibility + path-schema-properties-must-have-a-type: + description: "All path schema properties must have a type or schema reference. Refer to: https://gsoftdev.atlassian.net/wiki/spaces/TEC/pages/3858235678/IDP+OpenAPI+Rulesets#schemas-properties-must-have-a-type-and-path-schema-properties-must-have-a-type" + recommended: true + severity: warn + given: $..schema.properties.* + then: *type-or-ref-check + path-schema-properties-must-have-a-type-backend: description: "All path schema properties must have a type or schema reference. Refer to: https://gsoftdev.atlassian.net/wiki/spaces/TEC/pages/3858235678/IDP+OpenAPI+Rulesets#schemas-properties-must-have-a-type-and-path-schema-properties-must-have-a-type" recommended: true @@ -70,6 +86,14 @@ rules: given: $..schema.properties.* then: *type-or-composition-check + # For backward compatibility + schema-object-must-have-a-type: + description: "All schema objects must have a type or schema reference. Refer to: https://gsoftdev.atlassian.net/wiki/spaces/TEC/pages/3858235678/IDP+OpenAPI+Rulesets#schema-object-must-have-a-type" + recommended: true + severity: warn + given: $.components.schemas.* + then: *type-or-ref-check + schema-object-must-have-a-type-backend: description: "All schema objects must have a type or schema reference. Refer to: https://gsoftdev.atlassian.net/wiki/spaces/TEC/pages/3858235678/IDP+OpenAPI+Rulesets#schema-object-must-have-a-type" recommended: true @@ -84,6 +108,14 @@ rules: given: $.components.schemas.* then: *type-or-composition-check + # For backward compatibility + items-must-have-a-type: + description: "All items must have a type or schema reference. Refer to: https://gsoftdev.atlassian.net/wiki/spaces/TEC/pages/3858235678/IDP+OpenAPI+Rulesets#items-must-have-a-type" + recommended: true + severity: warn + given: $.components.schemas..items + then: *type-or-ref-check + items-must-have-a-type-backend: description: "All items must have a type or schema reference. Refer to: https://gsoftdev.atlassian.net/wiki/spaces/TEC/pages/3858235678/IDP+OpenAPI+Rulesets#items-must-have-a-type" recommended: true diff --git a/test.ps1 b/test.ps1 index 37f3a8f..884bf0e 100644 --- a/test.ps1 +++ b/test.ps1 @@ -8,6 +8,10 @@ spectral --version $ruleset = Join-Path $PSScriptRoot ".workleap.rules.yaml" $testSpecs = @( + @{ rule = "items-must-have-a-type"; expectError = $false; filename = "items-must-have-a-type-valid.yaml" }, + @{ rule = "items-must-have-a-type"; expectError = $false; filename = "items-must-have-a-type-valid-ref.yaml" }, + @{ rule = "items-must-have-a-type"; expectError = $true; filename = "items-must-have-a-type-valid-composition.yaml" }, + @{ rule = "items-must-have-a-type"; expectError = $true; filename = "items-must-have-a-type-invalid.yaml" }, @{ rule = "items-must-have-a-type-backend"; expectError = $false; filename = "items-must-have-a-type-valid.yaml" }, @{ rule = "items-must-have-a-type-backend"; expectError = $false; filename = "items-must-have-a-type-valid-ref.yaml" }, @{ rule = "items-must-have-a-type-backend"; expectError = $true; filename = "items-must-have-a-type-valid-composition.yaml" }, @@ -26,6 +30,10 @@ $testSpecs = @( @{ rule = "must-support-client-credentials-oauth2"; expectError = $true; filename = "must-support-client-credentials-oauth2-invalid.yaml" }, @{ rule = "must-use-get-post-methods"; expectError = $false; filename = "must-use-get-post-methods-valid.yaml" }, @{ rule = "must-use-get-post-methods"; expectError = $true; filename = "must-use-get-post-methods-invalid.yaml" }, + @{ rule = "path-schema-properties-must-have-a-type"; expectError = $false; filename = "path-schema-properties-must-have-a-type-valid.yaml" }, + @{ rule = "path-schema-properties-must-have-a-type"; expectError = $false; filename = "path-schema-properties-must-have-a-type-valid-ref.yaml" }, + @{ rule = "path-schema-properties-must-have-a-type"; expectError = $true; filename = "path-schema-properties-must-have-a-type-valid-composition.yaml" }, + @{ rule = "path-schema-properties-must-have-a-type"; expectError = $true; filename = "path-schema-properties-must-have-a-type-invalid.yaml" }, @{ rule = "path-schema-properties-must-have-a-type-backend"; expectError = $false; filename = "path-schema-properties-must-have-a-type-valid.yaml" }, @{ rule = "path-schema-properties-must-have-a-type-backend"; expectError = $false; filename = "path-schema-properties-must-have-a-type-valid-ref.yaml" }, @{ rule = "path-schema-properties-must-have-a-type-backend"; expectError = $true; filename = "path-schema-properties-must-have-a-type-valid-composition.yaml" }, @@ -34,6 +42,10 @@ $testSpecs = @( @{ rule = "path-schema-properties-must-have-a-type-frontend"; expectError = $false; filename = "path-schema-properties-must-have-a-type-valid-ref.yaml" }, @{ rule = "path-schema-properties-must-have-a-type-frontend"; expectError = $false; filename = "path-schema-properties-must-have-a-type-valid-composition.yaml" }, @{ rule = "path-schema-properties-must-have-a-type-frontend"; expectError = $true; filename = "path-schema-properties-must-have-a-type-invalid.yaml" }, + @{ rule = "schemas-properties-must-have-a-type"; expectError = $false; filename = "schemas-properties-must-have-a-type-valid.yaml" }, + @{ rule = "schemas-properties-must-have-a-type"; expectError = $false; filename = "schemas-properties-must-have-a-type-valid-ref.yaml" }, + @{ rule = "schemas-properties-must-have-a-type"; expectError = $true; filename = "schemas-properties-must-have-a-type-valid-composition.yaml" }, + @{ rule = "schemas-properties-must-have-a-type"; expectError = $true; filename = "schemas-properties-must-have-a-type-invalid.yaml" }, @{ rule = "schemas-properties-must-have-a-type-backend"; expectError = $false; filename = "schemas-properties-must-have-a-type-valid.yaml" }, @{ rule = "schemas-properties-must-have-a-type-backend"; expectError = $false; filename = "schemas-properties-must-have-a-type-valid-ref.yaml" }, @{ rule = "schemas-properties-must-have-a-type-backend"; expectError = $true; filename = "schemas-properties-must-have-a-type-valid-composition.yaml" }, @@ -44,6 +56,10 @@ $testSpecs = @( @{ rule = "schemas-properties-must-have-a-type-frontend"; expectError = $true; filename = "schemas-properties-must-have-a-type-invalid.yaml" }, @{ rule = "schema-ids-must-have-alphanumeric-characters-only"; expectError = $false; filename = "schema-ids-must-have-alphanumeric-characters-only-valid.yaml" }, @{ rule = "schema-ids-must-have-alphanumeric-characters-only"; expectError = $true; filename = "schema-ids-must-have-alphanumeric-characters-only-invalid.yaml" }, + @{ rule = "schema-object-must-have-a-type"; expectError = $false; filename = "schema-object-must-have-a-type-valid.yaml" }, + @{ rule = "schema-object-must-have-a-type"; expectError = $false; filename = "schema-object-must-have-a-type-valid-ref.yaml" }, + @{ rule = "schema-object-must-have-a-type"; expectError = $true; filename = "schema-object-must-have-a-type-valid-composition.yaml" }, + @{ rule = "schema-object-must-have-a-type"; expectError = $true; filename = "schema-object-must-have-a-type-invalid.yaml" }, @{ rule = "schema-object-must-have-a-type-backend"; expectError = $false; filename = "schema-object-must-have-a-type-valid.yaml" }, @{ rule = "schema-object-must-have-a-type-backend"; expectError = $false; filename = "schema-object-must-have-a-type-valid-ref.yaml" }, @{ rule = "schema-object-must-have-a-type-backend"; expectError = $true; filename = "schema-object-must-have-a-type-valid-composition.yaml" },