Skip to content
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
34 changes: 33 additions & 1 deletion .workleap.rules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
16 changes: 16 additions & 0 deletions test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
Expand All @@ -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" },
Expand All @@ -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" },
Expand All @@ -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" },
Expand Down