From a5bcc3399c8965b925d7f17c4aa4a84f12e0bd7e Mon Sep 17 00:00:00 2001 From: shivay Date: Mon, 19 Jan 2026 11:51:28 +0530 Subject: [PATCH 1/4] fix: pathparam validation for request validator plugin and tests --- ...n-operation-parameter-schema.expected.json | 78 ++++++++ ...tor-plugin-operation-parameter-schema.yaml | 30 ++++ ...h-operation-parameter-schema.expected.json | 168 ++++++++++++++++++ ...lugin-path-operation-parameter-schema.yaml | 50 ++++++ ...plugin-path-parameter-schema.expected.json | 111 ++++++++++++ ...alidator-plugin-path-parameter-schema.yaml | 30 ++++ ...on-and-path-parameter-schema.expected.json | 89 ++++++++++ ...t-operation-and-path-parameter-schema.yaml | 34 ++++ openapi2kong/validator.go | 6 +- 9 files changed, 595 insertions(+), 1 deletion(-) create mode 100644 openapi2kong/oas3_testfiles/26-request-validator-plugin-operation-parameter-schema.expected.json create mode 100644 openapi2kong/oas3_testfiles/26-request-validator-plugin-operation-parameter-schema.yaml create mode 100644 openapi2kong/oas3_testfiles/26-request-validator-plugin-path-operation-parameter-schema.expected.json create mode 100644 openapi2kong/oas3_testfiles/26-request-validator-plugin-path-operation-parameter-schema.yaml create mode 100644 openapi2kong/oas3_testfiles/26-request-validator-plugin-path-parameter-schema.expected.json create mode 100644 openapi2kong/oas3_testfiles/26-request-validator-plugin-path-parameter-schema.yaml create mode 100644 openapi2kong/oas3_testfiles/26-request-validator-plugin-without-operation-and-path-parameter-schema.expected.json create mode 100644 openapi2kong/oas3_testfiles/26-request-validator-plugin-without-operation-and-path-parameter-schema.yaml diff --git a/openapi2kong/oas3_testfiles/26-request-validator-plugin-operation-parameter-schema.expected.json b/openapi2kong/oas3_testfiles/26-request-validator-plugin-operation-parameter-schema.expected.json new file mode 100644 index 0000000..5ba7f50 --- /dev/null +++ b/openapi2kong/oas3_testfiles/26-request-validator-plugin-operation-parameter-schema.expected.json @@ -0,0 +1,78 @@ +{ + "_format_version": "3.0", + "services": [ + { + "host": "localhost", + "id": "b69ec2b7-0b2b-5e52-8e37-7126b9237f56", + "name": "test-service", + "path": "/", + "plugins": [], + "port": 443, + "protocol": "https", + "routes": [ + { + "id": "04fe9734-c93d-59bc-8723-528a778996c3", + "methods": [ + "GET" + ], + "name": "test-service_sample-group-sample-service-sample-api-v1-get-result_get", + "paths": [ + "~/sample-group/sample-service/sample-api/v1/get-result$" + ], + "plugins": [ + { + "config": { + "parameter_schema": [ + { + "explode": false, + "in": "header", + "name": "env", + "required": true, + "schema": "{\"type\":\"string\"}", + "style": "simple" + } + ], + "version": "draft4" + }, + "enabled": true, + "id": "8384b338-2d12-5035-902c-a20fd9ddd6fb", + "name": "request-validator", + "tags": [ + "OAS3_import", + "OAS3file_26-request-validator-plugin-operation-parameter-schema.yaml" + ] + } + ], + "regex_priority": 200, + "strip_path": false, + "tags": [ + "OAS3_import", + "OAS3file_26-request-validator-plugin-operation-parameter-schema.yaml" + ] + }, + { + "id": "a9452a70-c0fe-5a3b-8446-c329ba5c55e2", + "methods": [ + "OPTIONS" + ], + "name": "test-service_sample-group-sample-service-sample-api-v1-get-result_options", + "paths": [ + "~/sample-group/sample-service/sample-api/v1/get-result$" + ], + "plugins": [], + "regex_priority": 200, + "strip_path": false, + "tags": [ + "OAS3_import", + "OAS3file_26-request-validator-plugin-operation-parameter-schema.yaml" + ] + } + ], + "tags": [ + "OAS3_import", + "OAS3file_26-request-validator-plugin-operation-parameter-schema.yaml" + ] + } + ], + "upstreams": [] +} diff --git a/openapi2kong/oas3_testfiles/26-request-validator-plugin-operation-parameter-schema.yaml b/openapi2kong/oas3_testfiles/26-request-validator-plugin-operation-parameter-schema.yaml new file mode 100644 index 0000000..dfbed2e --- /dev/null +++ b/openapi2kong/oas3_testfiles/26-request-validator-plugin-operation-parameter-schema.yaml @@ -0,0 +1,30 @@ +openapi: 3.0.0 + +info: + description: Test service + version: 1.0.0 + title: Test Service + +x-kong-plugin-request-validator: + enabled: true + +paths: + /sample-group/sample-service/sample-api/v1/get-result: + get: + parameters: + - in: header + name: env + required: true + schema: + type: string + enum: + - qa + summary: Get Results + description: Get Results. + responses: + "200": + description: The request has succeeded. + options: + responses: + "200": + description: Generic OPTIONS response diff --git a/openapi2kong/oas3_testfiles/26-request-validator-plugin-path-operation-parameter-schema.expected.json b/openapi2kong/oas3_testfiles/26-request-validator-plugin-path-operation-parameter-schema.expected.json new file mode 100644 index 0000000..f74fd0c --- /dev/null +++ b/openapi2kong/oas3_testfiles/26-request-validator-plugin-path-operation-parameter-schema.expected.json @@ -0,0 +1,168 @@ +{ + "_format_version": "3.0", + "services": [ + { + "host": "localhost", + "id": "b69ec2b7-0b2b-5e52-8e37-7126b9237f56", + "name": "test-service", + "path": "/", + "plugins": [], + "port": 443, + "protocol": "https", + "routes": [ + { + "id": "04fe9734-c93d-59bc-8723-528a778996c3", + "methods": [ + "GET" + ], + "name": "test-service_sample-group-sample-service-sample-api-v1-get-result_get", + "paths": [ + "~/sample-group/sample-service/sample-api/v1/get-result$" + ], + "plugins": [ + { + "config": { + "parameter_schema": [ + { + "explode": false, + "in": "header", + "name": "env", + "required": true, + "schema": "{\"type\":\"string\"}", + "style": "simple" + } + ], + "version": "draft4" + }, + "enabled": true, + "id": "8384b338-2d12-5035-902c-a20fd9ddd6fb", + "name": "request-validator", + "tags": [ + "OAS3_import", + "OAS3file_26-request-validator-plugin-path-operation-parameter-schema.yaml" + ] + } + ], + "regex_priority": 200, + "strip_path": false, + "tags": [ + "OAS3_import", + "OAS3file_26-request-validator-plugin-path-operation-parameter-schema.yaml" + ] + }, + { + "id": "a9452a70-c0fe-5a3b-8446-c329ba5c55e2", + "methods": [ + "OPTIONS" + ], + "name": "test-service_sample-group-sample-service-sample-api-v1-get-result_options", + "paths": [ + "~/sample-group/sample-service/sample-api/v1/get-result$" + ], + "plugins": [], + "regex_priority": 200, + "strip_path": false, + "tags": [ + "OAS3_import", + "OAS3file_26-request-validator-plugin-path-operation-parameter-schema.yaml" + ] + }, + { + "headers": { + "env": [ + "qa" + ] + }, + "id": "8377d503-1bba-522a-a206-f91323442674", + "methods": [ + "GET" + ], + "name": "test-service_sample-group-sample-service-sample-api-v2-get-result_get_0", + "paths": [ + "~/sample-group/sample-service/sample-api/v2/get-result$" + ], + "plugins": [ + { + "config": { + "parameter_schema": [ + { + "explode": false, + "in": "header", + "name": "env", + "required": true, + "schema": "{\"enum\":[\"qa\"],\"type\":\"string\"}", + "style": "simple" + } + ], + "version": "draft4" + }, + "enabled": true, + "id": "ddb9f3cc-b11a-58f2-87e0-e47d8eca0242", + "name": "request-validator", + "tags": [ + "OAS3_import", + "OAS3file_26-request-validator-plugin-path-operation-parameter-schema.yaml" + ] + } + ], + "regex_priority": 200, + "strip_path": false, + "tags": [ + "OAS3_import", + "OAS3file_26-request-validator-plugin-path-operation-parameter-schema.yaml" + ] + }, + { + "headers": { + "env": [ + "qa" + ] + }, + "id": "c7f298fd-0673-5232-838c-d51a17edb71e", + "methods": [ + "OPTIONS" + ], + "name": "test-service_sample-group-sample-service-sample-api-v2-get-result_options_0", + "paths": [ + "~/sample-group/sample-service/sample-api/v2/get-result$" + ], + "plugins": [ + { + "config": { + "parameter_schema": [ + { + "explode": false, + "in": "header", + "name": "env", + "required": true, + "schema": "{\"enum\":[\"qa\"],\"type\":\"string\"}", + "style": "simple" + } + ], + "version": "draft4" + }, + "enabled": true, + "id": "1da08580-9237-584f-8213-9d64c1a87782", + "name": "request-validator", + "tags": [ + "OAS3_import", + "OAS3file_26-request-validator-plugin-path-operation-parameter-schema.yaml" + ] + } + ], + "regex_priority": 200, + "strip_path": false, + "tags": [ + "OAS3_import", + "OAS3file_26-request-validator-plugin-path-operation-parameter-schema.yaml" + ] + } + ], + "tags": [ + "OAS3_import", + "OAS3file_26-request-validator-plugin-path-operation-parameter-schema.yaml" + ] + } + ], + "upstreams": [] +} diff --git a/openapi2kong/oas3_testfiles/26-request-validator-plugin-path-operation-parameter-schema.yaml b/openapi2kong/oas3_testfiles/26-request-validator-plugin-path-operation-parameter-schema.yaml new file mode 100644 index 0000000..befefae --- /dev/null +++ b/openapi2kong/oas3_testfiles/26-request-validator-plugin-path-operation-parameter-schema.yaml @@ -0,0 +1,50 @@ +openapi: 3.0.0 + +info: + description: Test service + version: 1.0.0 + title: Test Service + +x-kong-plugin-request-validator: + enabled: true + +paths: + /sample-group/sample-service/sample-api/v1/get-result: + get: + parameters: + - in: header + name: env + required: true + schema: + type: string + enum: + - qa + summary: Get Results + description: Get Results. + responses: + "200": + description: The request has succeeded. + options: + responses: + "200": + description: Generic OPTIONS response + + /sample-group/sample-service/sample-api/v2/get-result: + parameters: + - in: header + name: env + required: true + schema: + type: string + enum: + - qa + get: + summary: Get Results + description: Get Results. + responses: + "200": + description: The request has succeeded. + options: + responses: + "200": + description: Generic OPTIONS response diff --git a/openapi2kong/oas3_testfiles/26-request-validator-plugin-path-parameter-schema.expected.json b/openapi2kong/oas3_testfiles/26-request-validator-plugin-path-parameter-schema.expected.json new file mode 100644 index 0000000..d0a0452 --- /dev/null +++ b/openapi2kong/oas3_testfiles/26-request-validator-plugin-path-parameter-schema.expected.json @@ -0,0 +1,111 @@ +{ + "_format_version": "3.0", + "services": [ + { + "host": "localhost", + "id": "b69ec2b7-0b2b-5e52-8e37-7126b9237f56", + "name": "test-service", + "path": "/", + "plugins": [], + "port": 443, + "protocol": "https", + "routes": [ + { + "headers": { + "env": [ + "qa" + ] + }, + "id": "8377d503-1bba-522a-a206-f91323442674", + "methods": [ + "GET" + ], + "name": "test-service_sample-group-sample-service-sample-api-v2-get-result_get_0", + "paths": [ + "~/sample-group/sample-service/sample-api/v2/get-result$" + ], + "plugins": [ + { + "config": { + "parameter_schema": [ + { + "explode": false, + "in": "header", + "name": "env", + "required": true, + "schema": "{\"enum\":[\"qa\"],\"type\":\"string\"}", + "style": "simple" + } + ], + "version": "draft4" + }, + "enabled": true, + "id": "ddb9f3cc-b11a-58f2-87e0-e47d8eca0242", + "name": "request-validator", + "tags": [ + "OAS3_import", + "OAS3file_26-request-validator-plugin-path-parameter-schema.yaml" + ] + } + ], + "regex_priority": 200, + "strip_path": false, + "tags": [ + "OAS3_import", + "OAS3file_26-request-validator-plugin-path-parameter-schema.yaml" + ] + }, + { + "headers": { + "env": [ + "qa" + ] + }, + "id": "c7f298fd-0673-5232-838c-d51a17edb71e", + "methods": [ + "OPTIONS" + ], + "name": "test-service_sample-group-sample-service-sample-api-v2-get-result_options_0", + "paths": [ + "~/sample-group/sample-service/sample-api/v2/get-result$" + ], + "plugins": [ + { + "config": { + "parameter_schema": [ + { + "explode": false, + "in": "header", + "name": "env", + "required": true, + "schema": "{\"enum\":[\"qa\"],\"type\":\"string\"}", + "style": "simple" + } + ], + "version": "draft4" + }, + "enabled": true, + "id": "1da08580-9237-584f-8213-9d64c1a87782", + "name": "request-validator", + "tags": [ + "OAS3_import", + "OAS3file_26-request-validator-plugin-path-parameter-schema.yaml" + ] + } + ], + "regex_priority": 200, + "strip_path": false, + "tags": [ + "OAS3_import", + "OAS3file_26-request-validator-plugin-path-parameter-schema.yaml" + ] + } + ], + "tags": [ + "OAS3_import", + "OAS3file_26-request-validator-plugin-path-parameter-schema.yaml" + ] + } + ], + "upstreams": [] +} diff --git a/openapi2kong/oas3_testfiles/26-request-validator-plugin-path-parameter-schema.yaml b/openapi2kong/oas3_testfiles/26-request-validator-plugin-path-parameter-schema.yaml new file mode 100644 index 0000000..25583b3 --- /dev/null +++ b/openapi2kong/oas3_testfiles/26-request-validator-plugin-path-parameter-schema.yaml @@ -0,0 +1,30 @@ +openapi: 3.0.0 + +info: + description: Test service + version: 1.0.0 + title: Test Service + +x-kong-plugin-request-validator: + enabled: true + +paths: + /sample-group/sample-service/sample-api/v2/get-result: + parameters: + - in: header + name: env + required: true + schema: + type: string + enum: + - qa + get: + summary: Get Results + description: Get Results. + responses: + "200": + description: The request has succeeded. + options: + responses: + "200": + description: Generic OPTIONS response diff --git a/openapi2kong/oas3_testfiles/26-request-validator-plugin-without-operation-and-path-parameter-schema.expected.json b/openapi2kong/oas3_testfiles/26-request-validator-plugin-without-operation-and-path-parameter-schema.expected.json new file mode 100644 index 0000000..e95620e --- /dev/null +++ b/openapi2kong/oas3_testfiles/26-request-validator-plugin-without-operation-and-path-parameter-schema.expected.json @@ -0,0 +1,89 @@ +{ + "_format_version": "3.0", + "services": [ + { + "host": "localhost", + "id": "b69ec2b7-0b2b-5e52-8e37-7126b9237f56", + "name": "test-service", + "path": "/", + "plugins": [], + "port": 443, + "protocol": "https", + "routes": [ + { + "id": "04fe9734-c93d-59bc-8723-528a778996c3", + "methods": [ + "GET" + ], + "name": "test-service_sample-group-sample-service-sample-api-v1-get-result_get", + "paths": [ + "~/sample-group/sample-service/sample-api/v1/get-result$" + ], + "plugins": [], + "regex_priority": 200, + "strip_path": false, + "tags": [ + "OAS3_import", + "OAS3file_26-request-validator-plugin-without-operation-and-path-parameter-schema.yaml" + ] + }, + { + "id": "a9452a70-c0fe-5a3b-8446-c329ba5c55e2", + "methods": [ + "OPTIONS" + ], + "name": "test-service_sample-group-sample-service-sample-api-v1-get-result_options", + "paths": [ + "~/sample-group/sample-service/sample-api/v1/get-result$" + ], + "plugins": [], + "regex_priority": 200, + "strip_path": false, + "tags": [ + "OAS3_import", + "OAS3file_26-request-validator-plugin-without-operation-and-path-parameter-schema.yaml" + ] + }, + { + "id": "1a1698ae-e685-55b7-b154-33f4b43706b6", + "methods": [ + "GET" + ], + "name": "test-service_sample-group-sample-service-sample-api-v2-get-result_get", + "paths": [ + "~/sample-group/sample-service/sample-api/v2/get-result$" + ], + "plugins": [], + "regex_priority": 200, + "strip_path": false, + "tags": [ + "OAS3_import", + "OAS3file_26-request-validator-plugin-without-operation-and-path-parameter-schema.yaml" + ] + }, + { + "id": "87bb908e-dde6-5396-926e-98c7bc38683f", + "methods": [ + "OPTIONS" + ], + "name": "test-service_sample-group-sample-service-sample-api-v2-get-result_options", + "paths": [ + "~/sample-group/sample-service/sample-api/v2/get-result$" + ], + "plugins": [], + "regex_priority": 200, + "strip_path": false, + "tags": [ + "OAS3_import", + "OAS3file_26-request-validator-plugin-without-operation-and-path-parameter-schema.yaml" + ] + } + ], + "tags": [ + "OAS3_import", + "OAS3file_26-request-validator-plugin-without-operation-and-path-parameter-schema.yaml" + ] + } + ], + "upstreams": [] +} diff --git a/openapi2kong/oas3_testfiles/26-request-validator-plugin-without-operation-and-path-parameter-schema.yaml b/openapi2kong/oas3_testfiles/26-request-validator-plugin-without-operation-and-path-parameter-schema.yaml new file mode 100644 index 0000000..d47a736 --- /dev/null +++ b/openapi2kong/oas3_testfiles/26-request-validator-plugin-without-operation-and-path-parameter-schema.yaml @@ -0,0 +1,34 @@ +openapi: 3.0.0 + +info: + description: Test service + version: 1.0.0 + title: Test Service + +x-kong-plugin-request-validator: + enabled: true + +paths: + /sample-group/sample-service/sample-api/v1/get-result: + get: + summary: Get Results + description: Get Results. + responses: + "200": + description: The request has succeeded. + options: + responses: + "200": + description: Generic OPTIONS response + + /sample-group/sample-service/sample-api/v2/get-result: + get: + summary: Get Results + description: Get Results. + responses: + "200": + description: The request has succeeded. + options: + responses: + "200": + description: Generic OPTIONS response diff --git a/openapi2kong/validator.go b/openapi2kong/validator.go index de60d4f..d363ec3 100644 --- a/openapi2kong/validator.go +++ b/openapi2kong/validator.go @@ -61,7 +61,11 @@ func generateParameterSchema(operation *v3.Operation, path *v3.PathItem, } } - combinedParameters = append(combinedParameters, operationParameters...) + if operationParameters != nil { + combinedParameters = append(combinedParameters, operationParameters...) + } else { + combinedParameters = append(combinedParameters, pathParameters...) + } result := make([]map[string]interface{}, len(combinedParameters)) i := 0 From d2ab7c2c10eef957c3dcaf413595f4c363d3249b Mon Sep 17 00:00:00 2001 From: shivay Date: Wed, 21 Jan 2026 15:00:35 +0530 Subject: [PATCH 2/4] fix: review comments. --- ...on-and-path-parameter-schema.expected.json | 89 ------------------- ...t-operation-and-path-parameter-schema.yaml | 34 ------- 2 files changed, 123 deletions(-) delete mode 100644 openapi2kong/oas3_testfiles/26-request-validator-plugin-without-operation-and-path-parameter-schema.expected.json delete mode 100644 openapi2kong/oas3_testfiles/26-request-validator-plugin-without-operation-and-path-parameter-schema.yaml diff --git a/openapi2kong/oas3_testfiles/26-request-validator-plugin-without-operation-and-path-parameter-schema.expected.json b/openapi2kong/oas3_testfiles/26-request-validator-plugin-without-operation-and-path-parameter-schema.expected.json deleted file mode 100644 index e95620e..0000000 --- a/openapi2kong/oas3_testfiles/26-request-validator-plugin-without-operation-and-path-parameter-schema.expected.json +++ /dev/null @@ -1,89 +0,0 @@ -{ - "_format_version": "3.0", - "services": [ - { - "host": "localhost", - "id": "b69ec2b7-0b2b-5e52-8e37-7126b9237f56", - "name": "test-service", - "path": "/", - "plugins": [], - "port": 443, - "protocol": "https", - "routes": [ - { - "id": "04fe9734-c93d-59bc-8723-528a778996c3", - "methods": [ - "GET" - ], - "name": "test-service_sample-group-sample-service-sample-api-v1-get-result_get", - "paths": [ - "~/sample-group/sample-service/sample-api/v1/get-result$" - ], - "plugins": [], - "regex_priority": 200, - "strip_path": false, - "tags": [ - "OAS3_import", - "OAS3file_26-request-validator-plugin-without-operation-and-path-parameter-schema.yaml" - ] - }, - { - "id": "a9452a70-c0fe-5a3b-8446-c329ba5c55e2", - "methods": [ - "OPTIONS" - ], - "name": "test-service_sample-group-sample-service-sample-api-v1-get-result_options", - "paths": [ - "~/sample-group/sample-service/sample-api/v1/get-result$" - ], - "plugins": [], - "regex_priority": 200, - "strip_path": false, - "tags": [ - "OAS3_import", - "OAS3file_26-request-validator-plugin-without-operation-and-path-parameter-schema.yaml" - ] - }, - { - "id": "1a1698ae-e685-55b7-b154-33f4b43706b6", - "methods": [ - "GET" - ], - "name": "test-service_sample-group-sample-service-sample-api-v2-get-result_get", - "paths": [ - "~/sample-group/sample-service/sample-api/v2/get-result$" - ], - "plugins": [], - "regex_priority": 200, - "strip_path": false, - "tags": [ - "OAS3_import", - "OAS3file_26-request-validator-plugin-without-operation-and-path-parameter-schema.yaml" - ] - }, - { - "id": "87bb908e-dde6-5396-926e-98c7bc38683f", - "methods": [ - "OPTIONS" - ], - "name": "test-service_sample-group-sample-service-sample-api-v2-get-result_options", - "paths": [ - "~/sample-group/sample-service/sample-api/v2/get-result$" - ], - "plugins": [], - "regex_priority": 200, - "strip_path": false, - "tags": [ - "OAS3_import", - "OAS3file_26-request-validator-plugin-without-operation-and-path-parameter-schema.yaml" - ] - } - ], - "tags": [ - "OAS3_import", - "OAS3file_26-request-validator-plugin-without-operation-and-path-parameter-schema.yaml" - ] - } - ], - "upstreams": [] -} diff --git a/openapi2kong/oas3_testfiles/26-request-validator-plugin-without-operation-and-path-parameter-schema.yaml b/openapi2kong/oas3_testfiles/26-request-validator-plugin-without-operation-and-path-parameter-schema.yaml deleted file mode 100644 index d47a736..0000000 --- a/openapi2kong/oas3_testfiles/26-request-validator-plugin-without-operation-and-path-parameter-schema.yaml +++ /dev/null @@ -1,34 +0,0 @@ -openapi: 3.0.0 - -info: - description: Test service - version: 1.0.0 - title: Test Service - -x-kong-plugin-request-validator: - enabled: true - -paths: - /sample-group/sample-service/sample-api/v1/get-result: - get: - summary: Get Results - description: Get Results. - responses: - "200": - description: The request has succeeded. - options: - responses: - "200": - description: Generic OPTIONS response - - /sample-group/sample-service/sample-api/v2/get-result: - get: - summary: Get Results - description: Get Results. - responses: - "200": - description: The request has succeeded. - options: - responses: - "200": - description: Generic OPTIONS response From 5f31d575e75b9d93494dc5f711713ed7911aa48c Mon Sep 17 00:00:00 2001 From: shivay Date: Wed, 21 Jan 2026 21:56:26 +0530 Subject: [PATCH 3/4] fix: review comments. --- ...h-operation-parameter-schema.expected.json | 81 +++---------------- ...lugin-path-operation-parameter-schema.yaml | 28 ++----- 2 files changed, 20 insertions(+), 89 deletions(-) diff --git a/openapi2kong/oas3_testfiles/26-request-validator-plugin-path-operation-parameter-schema.expected.json b/openapi2kong/oas3_testfiles/26-request-validator-plugin-path-operation-parameter-schema.expected.json index f74fd0c..f7b08ef 100644 --- a/openapi2kong/oas3_testfiles/26-request-validator-plugin-path-operation-parameter-schema.expected.json +++ b/openapi2kong/oas3_testfiles/26-request-validator-plugin-path-operation-parameter-schema.expected.json @@ -10,76 +10,19 @@ "port": 443, "protocol": "https", "routes": [ - { - "id": "04fe9734-c93d-59bc-8723-528a778996c3", - "methods": [ - "GET" - ], - "name": "test-service_sample-group-sample-service-sample-api-v1-get-result_get", - "paths": [ - "~/sample-group/sample-service/sample-api/v1/get-result$" - ], - "plugins": [ - { - "config": { - "parameter_schema": [ - { - "explode": false, - "in": "header", - "name": "env", - "required": true, - "schema": "{\"type\":\"string\"}", - "style": "simple" - } - ], - "version": "draft4" - }, - "enabled": true, - "id": "8384b338-2d12-5035-902c-a20fd9ddd6fb", - "name": "request-validator", - "tags": [ - "OAS3_import", - "OAS3file_26-request-validator-plugin-path-operation-parameter-schema.yaml" - ] - } - ], - "regex_priority": 200, - "strip_path": false, - "tags": [ - "OAS3_import", - "OAS3file_26-request-validator-plugin-path-operation-parameter-schema.yaml" - ] - }, - { - "id": "a9452a70-c0fe-5a3b-8446-c329ba5c55e2", - "methods": [ - "OPTIONS" - ], - "name": "test-service_sample-group-sample-service-sample-api-v1-get-result_options", - "paths": [ - "~/sample-group/sample-service/sample-api/v1/get-result$" - ], - "plugins": [], - "regex_priority": 200, - "strip_path": false, - "tags": [ - "OAS3_import", - "OAS3file_26-request-validator-plugin-path-operation-parameter-schema.yaml" - ] - }, { "headers": { "env": [ - "qa" + "dev" ] }, - "id": "8377d503-1bba-522a-a206-f91323442674", + "id": "4c11d945-2325-5817-9249-2a1973c229af", "methods": [ "GET" ], - "name": "test-service_sample-group-sample-service-sample-api-v2-get-result_get_0", + "name": "test-service_sample-group-sample-service-sample-api-v1-get-result_get_0", "paths": [ - "~/sample-group/sample-service/sample-api/v2/get-result$" + "~/sample-group/sample-service/sample-api/v1/get-result$" ], "plugins": [ { @@ -90,14 +33,14 @@ "in": "header", "name": "env", "required": true, - "schema": "{\"enum\":[\"qa\"],\"type\":\"string\"}", + "schema": "{\"type\":\"string\"}", "style": "simple" } ], "version": "draft4" }, "enabled": true, - "id": "ddb9f3cc-b11a-58f2-87e0-e47d8eca0242", + "id": "8384b338-2d12-5035-902c-a20fd9ddd6fb", "name": "request-validator", "tags": [ "OAS3_import", @@ -115,16 +58,16 @@ { "headers": { "env": [ - "qa" + "dev" ] }, - "id": "c7f298fd-0673-5232-838c-d51a17edb71e", + "id": "13fe35c4-9665-5433-8d0b-a840713d32db", "methods": [ "OPTIONS" ], - "name": "test-service_sample-group-sample-service-sample-api-v2-get-result_options_0", + "name": "test-service_sample-group-sample-service-sample-api-v1-get-result_options_0", "paths": [ - "~/sample-group/sample-service/sample-api/v2/get-result$" + "~/sample-group/sample-service/sample-api/v1/get-result$" ], "plugins": [ { @@ -135,14 +78,14 @@ "in": "header", "name": "env", "required": true, - "schema": "{\"enum\":[\"qa\"],\"type\":\"string\"}", + "schema": "{\"enum\":[\"dev\"],\"type\":\"string\"}", "style": "simple" } ], "version": "draft4" }, "enabled": true, - "id": "1da08580-9237-584f-8213-9d64c1a87782", + "id": "eb7440df-3f27-5647-bab9-fec82845e2b9", "name": "request-validator", "tags": [ "OAS3_import", diff --git a/openapi2kong/oas3_testfiles/26-request-validator-plugin-path-operation-parameter-schema.yaml b/openapi2kong/oas3_testfiles/26-request-validator-plugin-path-operation-parameter-schema.yaml index befefae..f6153ce 100644 --- a/openapi2kong/oas3_testfiles/26-request-validator-plugin-path-operation-parameter-schema.yaml +++ b/openapi2kong/oas3_testfiles/26-request-validator-plugin-path-operation-parameter-schema.yaml @@ -10,6 +10,14 @@ x-kong-plugin-request-validator: paths: /sample-group/sample-service/sample-api/v1/get-result: + parameters: + - in: header + name: env + required: true + schema: + type: string + enum: + - dev get: parameters: - in: header @@ -28,23 +36,3 @@ paths: responses: "200": description: Generic OPTIONS response - - /sample-group/sample-service/sample-api/v2/get-result: - parameters: - - in: header - name: env - required: true - schema: - type: string - enum: - - qa - get: - summary: Get Results - description: Get Results. - responses: - "200": - description: The request has succeeded. - options: - responses: - "200": - description: Generic OPTIONS response From aa975b06ac206c6ff05900daeb65c49d0abd269c Mon Sep 17 00:00:00 2001 From: shivay Date: Thu, 22 Jan 2026 11:47:17 +0530 Subject: [PATCH 4/4] fix: review comments. --- ...dator-plugin-path-operation-parameter-schema.expected.json | 4 ++-- ...uest-validator-plugin-path-operation-parameter-schema.yaml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/openapi2kong/oas3_testfiles/26-request-validator-plugin-path-operation-parameter-schema.expected.json b/openapi2kong/oas3_testfiles/26-request-validator-plugin-path-operation-parameter-schema.expected.json index f7b08ef..36a5b95 100644 --- a/openapi2kong/oas3_testfiles/26-request-validator-plugin-path-operation-parameter-schema.expected.json +++ b/openapi2kong/oas3_testfiles/26-request-validator-plugin-path-operation-parameter-schema.expected.json @@ -13,7 +13,7 @@ { "headers": { "env": [ - "dev" + "qa" ] }, "id": "4c11d945-2325-5817-9249-2a1973c229af", @@ -33,7 +33,7 @@ "in": "header", "name": "env", "required": true, - "schema": "{\"type\":\"string\"}", + "schema": "{\"enum\":[\"qa\"],\"type\":\"string\"}", "style": "simple" } ], diff --git a/openapi2kong/oas3_testfiles/26-request-validator-plugin-path-operation-parameter-schema.yaml b/openapi2kong/oas3_testfiles/26-request-validator-plugin-path-operation-parameter-schema.yaml index f6153ce..eef3fce 100644 --- a/openapi2kong/oas3_testfiles/26-request-validator-plugin-path-operation-parameter-schema.yaml +++ b/openapi2kong/oas3_testfiles/26-request-validator-plugin-path-operation-parameter-schema.yaml @@ -25,8 +25,8 @@ paths: required: true schema: type: string - enum: - - qa + enum: + - qa summary: Get Results description: Get Results. responses: