Skip to content

Commit

Permalink
fix(oas): make regex names inso compatible (#96)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tieske authored Oct 6, 2023
1 parent cd3a7f2 commit 1c363f5
Show file tree
Hide file tree
Showing 10 changed files with 391 additions and 17 deletions.
4 changes: 2 additions & 2 deletions openapi2kong/oas3_testfiles/01-names-inferred.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@
]
},
{
"id": "47527799-6eee-56a4-9f70-fd4e0b1a5867",
"id": "0879ed2e-2aa4-57ce-8359-733a266f3ab9",
"methods": [
"POST"
],
"name": "Simple_API_overview-application~-post",
"name": "Simple_API_overview-application-~-post",
"paths": [
"~/application/$"
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
"methods": [
"POST"
],
"name": "Simple_API_overview-application~-post",
"name": "Simple_API_overview-application-~-post",
"paths": [
"~/application/$"
],
Expand Down
8 changes: 4 additions & 4 deletions openapi2kong/oas3_testfiles/02-names-set.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@
]
},
{
"id": "6c573ebb-44d2-5e36-be1a-6aa5e6fc8868",
"id": "de13eea4-754a-5219-9dad-ee16f9632d63",
"methods": [
"PUT"
],
"name": "oas-spec-name-path-name-my-put-operation",
"name": "oas-spec-name-my-put-operation",
"paths": [
"~/app1$"
],
Expand Down Expand Up @@ -96,11 +96,11 @@
]
},
{
"id": "b9b808a1-29e6-596e-8980-f5218aee5440",
"id": "de13eea4-754a-5219-9dad-ee16f9632d63",
"methods": [
"PUT"
],
"name": "oas-spec-name-app2-my-put-operation",
"name": "oas-spec-name-my-put-operation",
"paths": [
"~/app2$"
],
Expand Down
4 changes: 2 additions & 2 deletions openapi2kong/oas3_testfiles/02-names-set.expected_noid.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"methods": [
"PUT"
],
"name": "oas-spec-name-path-name-my-put-operation",
"name": "oas-spec-name-my-put-operation",
"paths": [
"~/app1$"
],
Expand Down Expand Up @@ -93,7 +93,7 @@
"methods": [
"PUT"
],
"name": "oas-spec-name-app2-my-put-operation",
"name": "oas-spec-name-my-put-operation",
"paths": [
"~/app2$"
],
Expand Down
208 changes: 208 additions & 0 deletions openapi2kong/oas3_testfiles/02a-names-inso-compat.expected.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
{
"_format_version": "3.0",
"services": [
{
"host": "somewhere",
"id": "30e5c201-0b51-5880-a95d-014814c44d57",
"name": "documentname",
"path": "/",
"plugins": [],
"port": 80,
"protocol": "http",
"routes": [
{
"id": "0b8e9904-c8d8-504e-902c-773f7a39a466",
"methods": [
"PUT"
],
"name": "documentname-put",
"paths": [
"~/$"
],
"plugins": [],
"regex_priority": 200,
"strip_path": false,
"tags": [
"OAS3_import",
"OAS3file_02a-names-inso-compat.yaml"
]
},
{
"id": "fe2a90f4-707a-555c-a7d4-209102271d67",
"methods": [
"GET"
],
"name": "documentname-Ops2",
"paths": [
"~/named/path$"
],
"plugins": [],
"regex_priority": 200,
"strip_path": false,
"tags": [
"OAS3_import",
"OAS3file_02a-names-inso-compat.yaml"
]
},
{
"id": "afe41500-ce49-5eba-96d4-8eae0488da45",
"methods": [
"POST"
],
"name": "documentname-x-kong-ops",
"paths": [
"~/named/path$"
],
"plugins": [],
"regex_priority": 200,
"strip_path": false,
"tags": [
"OAS3_import",
"OAS3file_02a-names-inso-compat.yaml"
]
},
{
"id": "182d482c-e725-58b3-8f99-02d2e156d4cd",
"methods": [
"PUT"
],
"name": "documentname-x-kong-path-put",
"paths": [
"~/named/path$"
],
"plugins": [],
"regex_priority": 200,
"strip_path": false,
"tags": [
"OAS3_import",
"OAS3file_02a-names-inso-compat.yaml"
]
},
{
"id": "2fc8f8e6-c18c-5426-844d-03c19c1b2821",
"methods": [
"GET"
],
"name": "documentname-Ops1",
"paths": [
"~/plain/path$"
],
"plugins": [],
"regex_priority": 200,
"strip_path": false,
"tags": [
"OAS3_import",
"OAS3file_02a-names-inso-compat.yaml"
]
},
{
"id": "afe41500-ce49-5eba-96d4-8eae0488da45",
"methods": [
"POST"
],
"name": "documentname-x-kong-ops",
"paths": [
"~/plain/path$"
],
"plugins": [],
"regex_priority": 200,
"strip_path": false,
"tags": [
"OAS3_import",
"OAS3file_02a-names-inso-compat.yaml"
]
},
{
"id": "3672d50d-732d-5088-901d-0398f438f1b9",
"methods": [
"PUT"
],
"name": "documentname-plain-path-put",
"paths": [
"~/plain/path$"
],
"plugins": [],
"regex_priority": 200,
"strip_path": false,
"tags": [
"OAS3_import",
"OAS3file_02a-names-inso-compat.yaml"
]
},
{
"id": "a7c25823-da0f-569d-8c6d-a6a1237d81bc",
"methods": [
"GET"
],
"name": "documentname-Ops3",
"paths": [
"~/regex/path/(?<userid>[^#?/]+)$"
],
"plugins": [],
"regex_priority": 100,
"strip_path": false,
"tags": [
"OAS3_import",
"OAS3file_02a-names-inso-compat.yaml"
]
},
{
"id": "afe41500-ce49-5eba-96d4-8eae0488da45",
"methods": [
"POST"
],
"name": "documentname-x-kong-ops",
"paths": [
"~/regex/path/(?<userid>[^#?/]+)$"
],
"plugins": [],
"regex_priority": 100,
"strip_path": false,
"tags": [
"OAS3_import",
"OAS3file_02a-names-inso-compat.yaml"
]
},
{
"id": "6a9f90dd-78ef-5fab-928b-06a2ebf0d8b4",
"methods": [
"PUT"
],
"name": "documentname-regex-path-userid-put",
"paths": [
"~/regex/path/(?<userid>[^#?/]+)$"
],
"plugins": [],
"regex_priority": 100,
"strip_path": false,
"tags": [
"OAS3_import",
"OAS3file_02a-names-inso-compat.yaml"
]
},
{
"id": "8648ed96-027e-5d7f-b7d2-22d7709d1f93",
"methods": [
"PUT"
],
"name": "documentname-weird-p-a_th-put",
"paths": [
"~/weird/p-a_th$"
],
"plugins": [],
"regex_priority": 200,
"strip_path": false,
"tags": [
"OAS3_import",
"OAS3file_02a-names-inso-compat.yaml"
]
}
],
"tags": [
"OAS3_import",
"OAS3file_02a-names-inso-compat.yaml"
]
}
],
"upstreams": []
}
103 changes: 103 additions & 0 deletions openapi2kong/oas3_testfiles/02a-names-inso-compat.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# top-name
# - path
# - x-kong-name set
# - no x-kong-name (defaults to path)
# - no x-kong-name + regex (defaults to path)
# - Operation
# - operationId set
# - x-kong-name set
# - neither set (defaults to method)


openapi: 3.0.0

info:
description: Learn service
version: 1.0.0
title: Learn Service
contact: {}

servers:
- url: http://somewhere

x-kong-name: documentname

paths:
/:
put:
responses:
'200':
description: description

/weird/p-a_th:
put:
responses:
'200':
description: description

/plain/path:
get:
operationId: Ops1
responses:
'200':
description: description
put:
responses:
'200':
description: description
post:
x-kong-name: "x-kong-ops"
responses:
'200':
description: description

/named/path:
x-kong-name: "x-kong-path"
get:
operationId: Ops2
responses:
'200':
description: description
put:
responses:
'200':
description: description
post:
x-kong-name: "x-kong-ops"
responses:
'200':
description: description

/regex/path/{userid}:
get:
operationId: Ops3
parameters:
- name: userid
in: path
description: Id of the Track to delete
required: true
schema: {}
responses:
'200':
description: description
put:
parameters:
- name: userid
in: path
description: Id of the Track to delete
required: true
schema: {}
responses:
'200':
description: description
post:
x-kong-name: "x-kong-ops"
parameters:
- name: userid
in: path
description: Id of the Track to delete
required: true
schema: {}
responses:
'200':
description: description
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,4 @@
}
],
"upstreams": []
}
}
Loading

0 comments on commit 1c363f5

Please sign in to comment.