From 18ad495c1e03764c958744087a8266b91629b8e5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 23 Oct 2025 16:37:25 +0000 Subject: [PATCH 1/3] Initial plan From a0f1dd036accc904aedb3b1ad8987ee8adc77fca Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 23 Oct 2025 16:50:41 +0000 Subject: [PATCH 2/3] Fix items-must-have-a-type rule to accept $ref as valid type specification Co-authored-by: salliegsoft <115026913+salliegsoft@users.noreply.github.com> --- .workleap.rules.yaml | 11 ++++++++--- TestSpecs/items-must-have-a-type-valid-ref.yaml | 14 ++++++++++++++ test.ps1 | 1 + 3 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 TestSpecs/items-must-have-a-type-valid-ref.yaml diff --git a/.workleap.rules.yaml b/.workleap.rules.yaml index a5c6c42..640eb98 100644 --- a/.workleap.rules.yaml +++ b/.workleap.rules.yaml @@ -53,13 +53,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" diff --git a/TestSpecs/items-must-have-a-type-valid-ref.yaml b/TestSpecs/items-must-have-a-type-valid-ref.yaml new file mode 100644 index 0000000..db0e03e --- /dev/null +++ b/TestSpecs/items-must-have-a-type-valid-ref.yaml @@ -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' diff --git a/test.ps1 b/test.ps1 index 47aa760..c60c839 100644 --- a/test.ps1 +++ b/test.ps1 @@ -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" }, From 55311cde6f7da28aa1d7a297152584e4eb6c0889 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 23 Oct 2025 18:19:02 +0000 Subject: [PATCH 3/3] Apply same fix to schemas-properties and path-schema-properties rules Co-authored-by: salliegsoft <115026913+salliegsoft@users.noreply.github.com> --- .workleap.rules.yaml | 22 ++++++++++++----- ...properties-must-have-a-type-valid-ref.yaml | 24 +++++++++++++++++++ ...properties-must-have-a-type-valid-ref.yaml | 15 ++++++++++++ test.ps1 | 2 ++ 4 files changed, 57 insertions(+), 6 deletions(-) create mode 100644 TestSpecs/path-schema-properties-must-have-a-type-valid-ref.yaml create mode 100644 TestSpecs/schemas-properties-must-have-a-type-valid-ref.yaml diff --git a/.workleap.rules.yaml b/.workleap.rules.yaml index 640eb98..0dd2885 100644 --- a/.workleap.rules.yaml +++ b/.workleap.rules.yaml @@ -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" diff --git a/TestSpecs/path-schema-properties-must-have-a-type-valid-ref.yaml b/TestSpecs/path-schema-properties-must-have-a-type-valid-ref.yaml new file mode 100644 index 0000000..acfb289 --- /dev/null +++ b/TestSpecs/path-schema-properties-must-have-a-type-valid-ref.yaml @@ -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 diff --git a/TestSpecs/schemas-properties-must-have-a-type-valid-ref.yaml b/TestSpecs/schemas-properties-must-have-a-type-valid-ref.yaml new file mode 100644 index 0000000..47e1305 --- /dev/null +++ b/TestSpecs/schemas-properties-must-have-a-type-valid-ref.yaml @@ -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' diff --git a/test.ps1 b/test.ps1 index c60c839..acaea50 100644 --- a/test.ps1 +++ b/test.ps1 @@ -22,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" },