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
33 changes: 24 additions & 9 deletions .workleap.rules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,32 @@ rules:
match: '^[a-zA-Z0-9]+$'

schemas-properties-must-have-a-type:
description: "All schemas properties must have a type. 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"
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:
field: type
function: truthy
- function: truthy
- function: schema
functionOptions:
schema:
anyOf:
- required: ["type"]
- required: ["$ref"]

path-schema-properties-must-have-a-type:
description: "All path schema properties must have a type. 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"
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:
field: type
function: truthy
- function: truthy
- function: schema
functionOptions:
schema:
anyOf:
- required: ["type"]
- required: ["$ref"]

schema-object-must-have-a-type:
description: "All properties must have a type. Refer to: https://gsoftdev.atlassian.net/wiki/spaces/TEC/pages/3858235678/IDP+OpenAPI+Rulesets#schema-object-must-have-a-type"
Expand All @@ -53,13 +63,18 @@ rules:
function: truthy

items-must-have-a-type:
description: "All items must have a type. Refer to: https://gsoftdev.atlassian.net/wiki/spaces/TEC/pages/3858235678/IDP+OpenAPI+Rulesets#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:
field: type
function: truthy
- function: truthy
- function: schema
functionOptions:
schema:
anyOf:
- required: ["type"]
- required: ["$ref"]

schema-name-length-must-be-short:
description: "Schema name must not be too long to support client generation. Current limitation comes from Ruby packages which uses tar and has a limit of 100 characters. Refer to: https://gsoftdev.atlassian.net/wiki/spaces/TEC/pages/3858235678/IDP+OpenAPI+Rulesets#schema-name-length-must-be-short"
Expand Down
14 changes: 14 additions & 0 deletions TestSpecs/items-must-have-a-type-valid-ref.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
openapi: 3.0.1
info:
title: dummy
components:
schemas:
ExploreGoalsQueryResult:
type: object
properties:
id:
type: string
SubGoalsContainer:
type: array
items:
$ref: '#/components/schemas/ExploreGoalsQueryResult'
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
openapi: 3.0.1
info:
title: dummy
paths:
/test:
get:
operationId: getTest
responses:
'200':
description: Success
content:
application/json:
schema:
type: object
properties:
refProperty:
$ref: '#/components/schemas/ReferencedSchema'
components:
schemas:
ReferencedSchema:
type: object
properties:
id:
type: string
15 changes: 15 additions & 0 deletions TestSpecs/schemas-properties-must-have-a-type-valid-ref.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
openapi: 3.0.1
info:
title: dummy
components:
schemas:
ReferencedSchema:
type: object
properties:
id:
type: string
SampleObject:
type: object
properties:
refProperty:
$ref: '#/components/schemas/ReferencedSchema'
3 changes: 3 additions & 0 deletions test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ $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-invalid.yaml" },
@{ rule = "must-accept-content-types"; expectError = $false; filename = "must-accept-content-types-valid.yaml" },
@{ rule = "must-accept-content-types"; expectError = $true; filename = "must-accept-content-types-invalid.yaml" },
Expand All @@ -21,8 +22,10 @@ $testSpecs = @(
@{ 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-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-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" },
Expand Down