From 1ba49ebb36c8fc1494dfe641ba39e48fac9c20c5 Mon Sep 17 00:00:00 2001 From: David Itkin Date: Fri, 6 Sep 2024 11:14:57 -0400 Subject: [PATCH 1/5] fix for oapi-generator inplace response schema problems *200 and []200. Need to use docs/openapi.yaml --- .../attack-paths.attack-paths.id.acceptance.yaml | 7 +------ packages/go/openapi/src/paths/auth.self.yaml | 7 +------ ...ta-quality.platform.id.data-quality-stats.yaml | 12 +----------- .../api.response.authenticated-requester.yaml | 6 ++++++ ....response.data-quality-platform-aggregate.yaml | 15 +++++++++++++++ .../openapi/src/schemas/api.response.finding.yaml | 6 ++++++ 6 files changed, 30 insertions(+), 23 deletions(-) create mode 100644 packages/go/openapi/src/schemas/api.response.authenticated-requester.yaml create mode 100644 packages/go/openapi/src/schemas/api.response.data-quality-platform-aggregate.yaml create mode 100644 packages/go/openapi/src/schemas/api.response.finding.yaml diff --git a/packages/go/openapi/src/paths/attack-paths.attack-paths.id.acceptance.yaml b/packages/go/openapi/src/paths/attack-paths.attack-paths.id.acceptance.yaml index 13b9648435..da8757639a 100644 --- a/packages/go/openapi/src/paths/attack-paths.attack-paths.id.acceptance.yaml +++ b/packages/go/openapi/src/paths/attack-paths.attack-paths.id.acceptance.yaml @@ -51,12 +51,7 @@ put: content: application/json: schema: - type: object - properties: - data: - oneOf: - - $ref: './../schemas/model.list-finding.yaml' - - $ref: './../schemas/model.relationship-finding.yaml' + $ref: './../schemas/api.response.finding.yaml' 400: $ref: './../responses/bad-request.yaml' 401: diff --git a/packages/go/openapi/src/paths/auth.self.yaml b/packages/go/openapi/src/paths/auth.self.yaml index 2a5b66f35c..9eb2a7ab5c 100644 --- a/packages/go/openapi/src/paths/auth.self.yaml +++ b/packages/go/openapi/src/paths/auth.self.yaml @@ -33,11 +33,6 @@ get: content: application/json: schema: - type: object - properties: - data: - oneOf: - - $ref: './../schemas/model.user.yaml' - - $ref: './../schemas/model.client.yaml' + $ref: './../schemas/api.response.authenticated-requester.yaml' 429: $ref: './../responses/too-many-requests.yaml' diff --git a/packages/go/openapi/src/paths/data-quality.platform.id.data-quality-stats.yaml b/packages/go/openapi/src/paths/data-quality.platform.id.data-quality-stats.yaml index 6754423863..41aaa4df62 100644 --- a/packages/go/openapi/src/paths/data-quality.platform.id.data-quality-stats.yaml +++ b/packages/go/openapi/src/paths/data-quality.platform.id.data-quality-stats.yaml @@ -61,17 +61,7 @@ get: content: application/json: schema: - allOf: - - $ref: './../schemas/api.response.pagination.yaml' - - $ref: './../schemas/api.response.time-window.yaml' - - type: object - properties: - data: - type: array - items: - oneOf: - - $ref: './../schemas/model.ad-data-quality-aggregation.yaml' - - $ref: './../schemas/model.azure-data-quality-aggregation.yaml' + $ref: './../schemas/api.response.data-quality-platform-aggregate.yaml' 400: $ref: './../responses/bad-request.yaml' 401: diff --git a/packages/go/openapi/src/schemas/api.response.authenticated-requester.yaml b/packages/go/openapi/src/schemas/api.response.authenticated-requester.yaml new file mode 100644 index 0000000000..bb2b166f7d --- /dev/null +++ b/packages/go/openapi/src/schemas/api.response.authenticated-requester.yaml @@ -0,0 +1,6 @@ +type: object +properties: + data: + oneOf: + - $ref: './../schemas/model.user.yaml' + - $ref: './../schemas/model.client.yaml' diff --git a/packages/go/openapi/src/schemas/api.response.data-quality-platform-aggregate.yaml b/packages/go/openapi/src/schemas/api.response.data-quality-platform-aggregate.yaml new file mode 100644 index 0000000000..13f43a41f5 --- /dev/null +++ b/packages/go/openapi/src/schemas/api.response.data-quality-platform-aggregate.yaml @@ -0,0 +1,15 @@ +type: object +properties: + data: + allOf: + - $ref: './../schemas/api.response.pagination.yaml' + - $ref: './../schemas/api.response.time-window.yaml' + - type: object + properties: + data: + type: array + items: + oneOf: + - $ref: './../schemas/model.ad-data-quality-aggregation.yaml' + - $ref: './../schemas/model.azure-data-quality-aggregation.yaml' + diff --git a/packages/go/openapi/src/schemas/api.response.finding.yaml b/packages/go/openapi/src/schemas/api.response.finding.yaml new file mode 100644 index 0000000000..4a72b945cb --- /dev/null +++ b/packages/go/openapi/src/schemas/api.response.finding.yaml @@ -0,0 +1,6 @@ +type: object +properties: + data: + oneOf: + - $ref: './../schemas/model.list-finding.yaml' + - $ref: './../schemas/model.relationship-finding.yaml' From f7d09dd42c1b46be343557ac05b9ef97f1e16964 Mon Sep 17 00:00:00 2001 From: David Itkin Date: Mon, 16 Sep 2024 12:04:44 -0400 Subject: [PATCH 2/5] Fix readOnly in model.saved-queries-permissions.yaml. --- .../openapi/src/schemas/model.saved-queries-permissions.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/go/openapi/src/schemas/model.saved-queries-permissions.yaml b/packages/go/openapi/src/schemas/model.saved-queries-permissions.yaml index d9590ac2da..874c5f8715 100644 --- a/packages/go/openapi/src/schemas/model.saved-queries-permissions.yaml +++ b/packages/go/openapi/src/schemas/model.saved-queries-permissions.yaml @@ -20,11 +20,11 @@ allOf: - type: object properties: shared_to_user_id: + readOnly: true allOf: - $ref: './null.uuid.yaml' - - readOnly: true query_id: type: integer format: int64 public: - type: boolean \ No newline at end of file + type: boolean From 383f71573d974c053fb2f0617c5556ea7591c0f9 Mon Sep 17 00:00:00 2001 From: David Itkin Date: Mon, 16 Sep 2024 12:06:01 -0400 Subject: [PATCH 3/5] Previous fix to api.response.data-quality-platform-aggregate is now backwards compatible. --- ...ponse.data-quality-platform-aggregate.yaml | 25 ++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/packages/go/openapi/src/schemas/api.response.data-quality-platform-aggregate.yaml b/packages/go/openapi/src/schemas/api.response.data-quality-platform-aggregate.yaml index 13f43a41f5..c44cdfa81f 100644 --- a/packages/go/openapi/src/schemas/api.response.data-quality-platform-aggregate.yaml +++ b/packages/go/openapi/src/schemas/api.response.data-quality-platform-aggregate.yaml @@ -1,15 +1,12 @@ -type: object -properties: - data: - allOf: - - $ref: './../schemas/api.response.pagination.yaml' - - $ref: './../schemas/api.response.time-window.yaml' - - type: object - properties: - data: - type: array - items: - oneOf: - - $ref: './../schemas/model.ad-data-quality-aggregation.yaml' - - $ref: './../schemas/model.azure-data-quality-aggregation.yaml' +allOf: + - $ref: './../schemas/api.response.pagination.yaml' + - $ref: './../schemas/api.response.time-window.yaml' + - type: object + properties: + data: + type: array + items: + oneOf: + - $ref: './../schemas/model.ad-data-quality-aggregation.yaml' + - $ref: './../schemas/model.azure-data-quality-aggregation.yaml' From 96c81c958e4149cdf6a1e73d37d5e31c0f84e3da Mon Sep 17 00:00:00 2001 From: David Itkin Date: Mon, 16 Sep 2024 12:07:38 -0400 Subject: [PATCH 4/5] regenerated doc/openapi.json to include fixes to src spec. --- packages/go/openapi/doc/openapi.json | 117 ++++++++++++++------------- 1 file changed, 62 insertions(+), 55 deletions(-) diff --git a/packages/go/openapi/doc/openapi.json b/packages/go/openapi/doc/openapi.json index 48e02bf4de..92373ac882 100644 --- a/packages/go/openapi/doc/openapi.json +++ b/packages/go/openapi/doc/openapi.json @@ -205,19 +205,7 @@ "content": { "application/json": { "schema": { - "type": "object", - "properties": { - "data": { - "oneOf": [ - { - "$ref": "#/components/schemas/model.user" - }, - { - "$ref": "#/components/schemas/model.client" - } - ] - } - } + "$ref": "#/components/schemas/api.response.authenticated-requester" } } } @@ -9373,32 +9361,7 @@ "content": { "application/json": { "schema": { - "allOf": [ - { - "$ref": "#/components/schemas/api.response.pagination" - }, - { - "$ref": "#/components/schemas/api.response.time-window" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "oneOf": [ - { - "$ref": "#/components/schemas/model.ad-data-quality-aggregation" - }, - { - "$ref": "#/components/schemas/model.azure-data-quality-aggregation" - } - ] - } - } - } - } - ] + "$ref": "#/components/schemas/api.response.data-quality-platform-aggregate" } } } @@ -12574,19 +12537,7 @@ "content": { "application/json": { "schema": { - "type": "object", - "properties": { - "data": { - "oneOf": [ - { - "$ref": "#/components/schemas/model.list-finding" - }, - { - "$ref": "#/components/schemas/model.relationship-finding" - } - ] - } - } + "$ref": "#/components/schemas/api.response.finding" } } } @@ -13817,6 +13768,21 @@ } ] }, + "api.response.authenticated-requester": { + "type": "object", + "properties": { + "data": { + "oneOf": [ + { + "$ref": "#/components/schemas/model.user" + }, + { + "$ref": "#/components/schemas/model.client" + } + ] + } + } + }, "model.saml-provider": { "allOf": [ { @@ -14786,12 +14752,10 @@ "type": "object", "properties": { "shared_to_user_id": { + "readOnly": true, "allOf": [ { "$ref": "#/components/schemas/null.uuid" - }, - { - "readOnly": true } ] }, @@ -15076,6 +15040,34 @@ } ] }, + "api.response.data-quality-platform-aggregate": { + "allOf": [ + { + "$ref": "#/components/schemas/api.response.pagination" + }, + { + "$ref": "#/components/schemas/api.response.time-window" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "oneOf": [ + { + "$ref": "#/components/schemas/model.ad-data-quality-aggregation" + }, + { + "$ref": "#/components/schemas/model.azure-data-quality-aggregation" + } + ] + } + } + } + } + ] + }, "enum.datapipe-status": { "type": "string", "enum": [ @@ -15477,6 +15469,21 @@ } ] }, + "api.response.finding": { + "type": "object", + "properties": { + "data": { + "oneOf": [ + { + "$ref": "#/components/schemas/model.list-finding" + }, + { + "$ref": "#/components/schemas/model.relationship-finding" + } + ] + } + } + }, "model.risk-posture-stat": { "allOf": [ { From e95c836ddafe4333aa9a77b78c53384363a0ff10 Mon Sep 17 00:00:00 2001 From: David Itkin Date: Sun, 8 Sep 2024 16:59:28 -0400 Subject: [PATCH 5/5] x-go-name for deprecated parameters to avoid name collision in generated go code. Also finding which is not deprecated --- packages/go/openapi/doc/openapi.json | 6 ++++++ .../openapi/src/paths/attack-paths.domains.id.details.yaml | 4 ++++ .../go/openapi/src/paths/risk-posture.posture-stats.yaml | 2 ++ 3 files changed, 12 insertions(+) diff --git a/packages/go/openapi/doc/openapi.json b/packages/go/openapi/doc/openapi.json index 92373ac882..03167223e9 100644 --- a/packages/go/openapi/doc/openapi.json +++ b/packages/go/openapi/doc/openapi.json @@ -12174,6 +12174,7 @@ "parameters": [ { "name": "finding", + "x-go-name": "FindingDeprecated", "in": "query", "schema": { "$ref": "#/components/schemas/api.params.predicate.filter.string" @@ -12190,6 +12191,7 @@ { "name": "FromPrincipal", "deprecated": true, + "x-go-name": "FromPrincipalDeprecated", "in": "query", "schema": { "$ref": "#/components/schemas/api.params.predicate.filter.string" @@ -12198,6 +12200,7 @@ { "name": "ToPrincipal", "deprecated": true, + "x-go-name": "ToPrincipalDeprecated", "in": "query", "schema": { "$ref": "#/components/schemas/api.params.predicate.filter.string" @@ -12234,6 +12237,7 @@ { "name": "AcceptedUntil", "deprecated": true, + "x-go-name": "AcceptedUntilDeprecated", "in": "query", "schema": { "$ref": "#/components/schemas/api.params.predicate.filter.time" @@ -12589,6 +12593,7 @@ { "name": "from", "deprecated": true, + "x-go-name": "fromDeprecated", "description": "Lower bound for created_at; to return posture stats starting at a specific date/time", "in": "query", "schema": { @@ -12599,6 +12604,7 @@ { "name": "to", "deprecated": true, + "x-go-name": "toDeprecated", "description": "Upper bound for created_at; to return posture stats upto a specific date/time", "in": "query", "schema": { diff --git a/packages/go/openapi/src/paths/attack-paths.domains.id.details.yaml b/packages/go/openapi/src/paths/attack-paths.domains.id.details.yaml index ad37da2c61..8cfb405bbd 100644 --- a/packages/go/openapi/src/paths/attack-paths.domains.id.details.yaml +++ b/packages/go/openapi/src/paths/attack-paths.domains.id.details.yaml @@ -31,6 +31,7 @@ get: - Enterprise parameters: - name: finding + x-go-name: "FindingDeprecated" in: query schema: $ref: './../schemas/api.params.predicate.filter.string.yaml' @@ -44,11 +45,13 @@ get: $ref: './../schemas/api.params.query.sort-by.yaml' - name: FromPrincipal deprecated: true + x-go-name: "FromPrincipalDeprecated" in: query schema: $ref: './../schemas/api.params.predicate.filter.string.yaml' - name: ToPrincipal deprecated: true + x-go-name: "ToPrincipalDeprecated" in: query schema: $ref: './../schemas/api.params.predicate.filter.string.yaml' @@ -70,6 +73,7 @@ get: $ref: './../schemas/api.params.predicate.filter.string.yaml' - name: AcceptedUntil deprecated: true + x-go-name: "AcceptedUntilDeprecated" in: query schema: $ref: './../schemas/api.params.predicate.filter.time.yaml' diff --git a/packages/go/openapi/src/paths/risk-posture.posture-stats.yaml b/packages/go/openapi/src/paths/risk-posture.posture-stats.yaml index 4ecda1bbfa..f2a0f76035 100644 --- a/packages/go/openapi/src/paths/risk-posture.posture-stats.yaml +++ b/packages/go/openapi/src/paths/risk-posture.posture-stats.yaml @@ -32,6 +32,7 @@ get: $ref: './../schemas/api.params.query.sort-by.yaml' - name: from deprecated: true + x-go-name: "fromDeprecated" description: Lower bound for created_at; to return posture stats starting at a specific date/time in: query @@ -40,6 +41,7 @@ get: format: date-time - name: to deprecated: true + x-go-name: "toDeprecated" description: Upper bound for created_at; to return posture stats upto a specific date/time in: query