mirror of
https://github.com/Kong/insomnia.git
synced 2026-10-25 08:09:06 -04:00
makes all route paths regexes in o2k (with ending markers) (#3066)
* adds jest to openapi-2-kong so tests can run * removes special case since everything is a regex * updates tests now that everything is a regex
This commit is contained in:
1 parent
29fed74346
commit
770be1b924
13 files changed
+4500
-39
No files matched your search
+4463
File diff suppressed because it is too large.
Load diff
@@ -26,6 +26,7 @@
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.9.0",
|
||||
"@babel/plugin-proposal-optional-chaining": "^7.9.0",
|
||||
"jest": "^26.6.3",
|
||||
"webpack": "^4.42.1",
|
||||
"webpack-cli": "^3.3.11"
|
||||
},
|
||||
|
||||
@@ -10,14 +10,14 @@
|
||||
"strip_path": false,
|
||||
"tags": ["OAS3_import", "OAS3file_api-with-examples.yaml"],
|
||||
"name": "Simple_API_overview-path-get",
|
||||
"paths": ["/"]
|
||||
"paths": ["/$"]
|
||||
},
|
||||
{
|
||||
"methods": ["GET"],
|
||||
"strip_path": false,
|
||||
"tags": ["OAS3_import", "OAS3file_api-with-examples.yaml"],
|
||||
"name": "Simple_API_overview-path_1-get",
|
||||
"paths": ["/v2"]
|
||||
"paths": ["/v2$"]
|
||||
}
|
||||
],
|
||||
"tags": ["OAS3_import", "OAS3file_api-with-examples.yaml"]
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"strip_path": false,
|
||||
"tags": ["OAS3_import", "OAS3file_callback-example.yaml"],
|
||||
"name": "Callback_Example-path-post",
|
||||
"paths": ["/streams"]
|
||||
"paths": ["/streams$"]
|
||||
}
|
||||
],
|
||||
"tags": ["OAS3_import", "OAS3file_callback-example.yaml"]
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"strip_path": false,
|
||||
"tags": ["OAS3_import", "OAS3file_httpbin.yaml"],
|
||||
"name": "httpbin-path_3-get",
|
||||
"paths": ["/get"]
|
||||
"paths": ["/get$"]
|
||||
},
|
||||
{
|
||||
"methods": ["GET"],
|
||||
@@ -39,7 +39,7 @@
|
||||
"strip_path": false,
|
||||
"tags": ["OAS3_import", "OAS3file_httpbin.yaml"],
|
||||
"name": "httpbin-path_19-get",
|
||||
"paths": ["/html"]
|
||||
"paths": ["/html$"]
|
||||
},
|
||||
{
|
||||
"methods": ["DELETE"],
|
||||
@@ -81,7 +81,7 @@
|
||||
"strip_path": false,
|
||||
"tags": ["OAS3_import", "OAS3file_httpbin.yaml"],
|
||||
"name": "httpbin-path_7-get",
|
||||
"paths": ["/user-agent"]
|
||||
"paths": ["/user-agent$"]
|
||||
},
|
||||
{
|
||||
"methods": ["GET"],
|
||||
@@ -96,7 +96,7 @@
|
||||
"strip_path": false,
|
||||
"tags": ["OAS3_import", "OAS3file_httpbin.yaml"],
|
||||
"name": "httpbin-path_8-get",
|
||||
"paths": ["/headers"]
|
||||
"paths": ["/headers$"]
|
||||
},
|
||||
{
|
||||
"methods": ["GET"],
|
||||
@@ -104,35 +104,35 @@
|
||||
"tags": ["OAS3_import", "OAS3file_httpbin.yaml"],
|
||||
"name": "httpbin-path_23-get",
|
||||
"plugins": [{"name": "correlation-id"}],
|
||||
"paths": ["/cookies"]
|
||||
"paths": ["/cookies$"]
|
||||
},
|
||||
{
|
||||
"methods": ["GET"],
|
||||
"strip_path": false,
|
||||
"tags": ["OAS3_import", "OAS3file_httpbin.yaml"],
|
||||
"name": "httpbin-path_6-get",
|
||||
"paths": ["/ip"]
|
||||
"paths": ["/ip$"]
|
||||
},
|
||||
{
|
||||
"methods": ["GET"],
|
||||
"strip_path": false,
|
||||
"tags": ["OAS3_import", "OAS3file_httpbin.yaml"],
|
||||
"name": "httpbin-path_18-get",
|
||||
"paths": ["/xml"]
|
||||
"paths": ["/xml$"]
|
||||
},
|
||||
{
|
||||
"methods": ["GET"],
|
||||
"strip_path": false,
|
||||
"tags": ["OAS3_import", "OAS3file_httpbin.yaml"],
|
||||
"name": "httpbin-path_25-get",
|
||||
"paths": ["/cookies\/delete"]
|
||||
"paths": ["/cookies\/delete$"]
|
||||
},
|
||||
{
|
||||
"methods": ["GET"],
|
||||
"strip_path": false,
|
||||
"tags": ["OAS3_import", "OAS3file_httpbin.yaml"],
|
||||
"name": "httpbin-path_21-get",
|
||||
"paths": ["/image"]
|
||||
"paths": ["/image$"]
|
||||
},
|
||||
{
|
||||
"methods": ["GET"],
|
||||
@@ -146,21 +146,21 @@
|
||||
"strip_path": false,
|
||||
"tags": ["OAS3_import", "OAS3file_httpbin.yaml"],
|
||||
"name": "httpbin-path_5-post",
|
||||
"paths": ["/post"]
|
||||
"paths": ["/post$"]
|
||||
},
|
||||
{
|
||||
"methods": ["GET"],
|
||||
"strip_path": false,
|
||||
"tags": ["OAS3_import", "OAS3file_httpbin.yaml"],
|
||||
"name": "httpbin-path_22-get",
|
||||
"paths": ["/cache"]
|
||||
"paths": ["/cache$"]
|
||||
},
|
||||
{
|
||||
"methods": ["DELETE"],
|
||||
"strip_path": false,
|
||||
"tags": ["OAS3_import", "OAS3file_httpbin.yaml"],
|
||||
"name": "httpbin-path_4-delete",
|
||||
"paths": ["/delete"]
|
||||
"paths": ["/delete$"]
|
||||
},
|
||||
{
|
||||
"methods": ["GET"],
|
||||
@@ -194,21 +194,21 @@
|
||||
"tags": ["OAS3_import", "OAS3file_httpbin.yaml"],
|
||||
"name": "httpbin-path_12-get",
|
||||
"plugins": [{"config": {"hide_credentials": true}, "name": "basic-auth"}],
|
||||
"paths": ["/bearer"]
|
||||
"paths": ["/bearer$"]
|
||||
},
|
||||
{
|
||||
"methods": ["GET"],
|
||||
"strip_path": false,
|
||||
"tags": ["OAS3_import", "OAS3file_httpbin.yaml"],
|
||||
"name": "httpbin-path-get",
|
||||
"paths": ["/"]
|
||||
"paths": ["/$"]
|
||||
},
|
||||
{
|
||||
"methods": ["GET"],
|
||||
"strip_path": false,
|
||||
"tags": ["OAS3_import", "OAS3file_httpbin.yaml"],
|
||||
"name": "httpbin-path_24-get",
|
||||
"paths": ["/cookies/set"]
|
||||
"paths": ["/cookies/set$"]
|
||||
}
|
||||
],
|
||||
"tags": ["OAS3_import", "OAS3file_httpbin.yaml"]
|
||||
|
||||
@@ -141,7 +141,7 @@ components:
|
||||
name:
|
||||
type: string
|
||||
tag:
|
||||
type: string
|
||||
type: string
|
||||
|
||||
Error:
|
||||
required:
|
||||
|
||||
@@ -10,14 +10,14 @@
|
||||
"strip_path": false,
|
||||
"tags": ["OAS3_import", "OAS3file_petstore-expanded.yaml"],
|
||||
"name": "Swagger_Petstore-path-get",
|
||||
"paths": ["/pets"]
|
||||
"paths": ["/pets$"]
|
||||
},
|
||||
{
|
||||
"methods": ["POST"],
|
||||
"strip_path": false,
|
||||
"tags": ["OAS3_import", "OAS3file_petstore-expanded.yaml"],
|
||||
"name": "Swagger_Petstore-path_1-post",
|
||||
"paths": ["/pets"]
|
||||
"paths": ["/pets$"]
|
||||
},
|
||||
{
|
||||
"methods": ["GET"],
|
||||
|
||||
@@ -10,14 +10,14 @@
|
||||
"strip_path": false,
|
||||
"tags": ["OAS3_import", "OAS3file_petstore.yaml"],
|
||||
"name": "Swagger_Petstore-path-get",
|
||||
"paths": ["/pets"]
|
||||
"paths": ["/pets$"]
|
||||
},
|
||||
{
|
||||
"methods": ["POST"],
|
||||
"strip_path": false,
|
||||
"tags": ["OAS3_import", "OAS3file_petstore.yaml"],
|
||||
"name": "Swagger_Petstore-path_1-post",
|
||||
"paths": ["/pets"]
|
||||
"paths": ["/pets$"]
|
||||
},
|
||||
{
|
||||
"methods": ["GET"],
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
"plugins": [
|
||||
{"config": {"auth_methods": ["client_credentials"]}, "name": "openid-connect"}
|
||||
],
|
||||
"paths": ["/only/oath2"]
|
||||
"paths": ["/only/oath2$"]
|
||||
},
|
||||
{
|
||||
"methods": ["GET"],
|
||||
@@ -21,7 +21,7 @@
|
||||
"tags": ["OAS3_import", "OAS3file_security.yaml"],
|
||||
"name": "Security_Example-path_1-get",
|
||||
"plugins": [{"config": {"key_names": ["api_key_by_me"]}, "name": "key-auth"}],
|
||||
"paths": ["/only/key"]
|
||||
"paths": ["/only/key$"]
|
||||
},
|
||||
{
|
||||
"methods": ["GET"],
|
||||
@@ -31,7 +31,7 @@
|
||||
"plugins": [
|
||||
{"config": {"auth_methods": ["client_credentials"]}, "name": "openid-connect"}
|
||||
],
|
||||
"paths": ["/and/based/auth"]
|
||||
"paths": ["/and/based/auth$"]
|
||||
},
|
||||
{
|
||||
"methods": ["GET"],
|
||||
@@ -39,7 +39,7 @@
|
||||
"tags": ["OAS3_import", "OAS3file_security.yaml"],
|
||||
"name": "Security_Example-path_5-get",
|
||||
"plugins": [{"config": {"key_names": ["api_key_by_me"]}, "name": "key-auth"}],
|
||||
"paths": ["/or/based/auth"]
|
||||
"paths": ["/or/based/auth$"]
|
||||
},
|
||||
{
|
||||
"methods": ["GET"],
|
||||
@@ -55,7 +55,7 @@
|
||||
"name": "openid-connect"
|
||||
}
|
||||
],
|
||||
"paths": ["/only/oidc"]
|
||||
"paths": ["/only/oidc$"]
|
||||
},
|
||||
{
|
||||
"methods": ["GET"],
|
||||
@@ -63,7 +63,7 @@
|
||||
"tags": ["OAS3_import", "OAS3file_security.yaml"],
|
||||
"name": "Security_Example-path-get",
|
||||
"plugins": [{"name": "basic-auth"}],
|
||||
"paths": ["/only/basic"]
|
||||
"paths": ["/only/basic$"]
|
||||
}
|
||||
],
|
||||
"tags": ["OAS3_import", "OAS3file_security.yaml"]
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"strip_path": false,
|
||||
"tags": ["OAS3_import", "OAS3file_uspto.yaml"],
|
||||
"name": "USPTO_Data_Set_API-path-get",
|
||||
"paths": ["/"]
|
||||
"paths": ["/$"]
|
||||
},
|
||||
{
|
||||
"methods": ["GET"],
|
||||
|
||||
@@ -191,7 +191,7 @@ describe('common', () => {
|
||||
});
|
||||
|
||||
it('does not convert to regex if no variables present', () => {
|
||||
expect(pathVariablesToRegex('/foo/bar/baz')).toBe('/foo/bar/baz');
|
||||
expect(pathVariablesToRegex('/foo/bar/baz')).toBe('/foo/bar/baz$');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -64,15 +64,12 @@ export function generateSlug(str: string, options: SlugifyOptions = {}): string
|
||||
return slugify(str, options);
|
||||
}
|
||||
|
||||
/** characters in curly brances not immediately followed by `://`, e.g. `{foo}` will match but `{foo}://` will not. */
|
||||
const pathVariableSearchValue = /{([^}]+)}(?!:\/\/)/g;
|
||||
|
||||
export function pathVariablesToRegex(p: string): string {
|
||||
const result = p.replace(pathVariableSearchValue, '(?<$1>\\S+)');
|
||||
if (result === p) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// If anything was replaced, it's a regex, so add a line-ending match
|
||||
// add a line ending because it is a regex
|
||||
return result + '$';
|
||||
}
|
||||
|
||||
|
||||
@@ -38,21 +38,21 @@ describe('services', () => {
|
||||
name: 'My_API-Cat_stuff-post',
|
||||
strip_path: false,
|
||||
methods: ['POST'],
|
||||
paths: ['/cats'],
|
||||
paths: ['/cats$'],
|
||||
tags: ['Tag'],
|
||||
},
|
||||
{
|
||||
name: 'My_API-Dog_stuff-get',
|
||||
strip_path: false,
|
||||
methods: ['GET'],
|
||||
paths: ['/dogs'],
|
||||
paths: ['/dogs$'],
|
||||
tags: ['Tag'],
|
||||
},
|
||||
{
|
||||
name: 'My_API-Dog_stuff-post',
|
||||
strip_path: false,
|
||||
methods: ['POST'],
|
||||
paths: ['/dogs'],
|
||||
paths: ['/dogs$'],
|
||||
tags: ['Tag'],
|
||||
},
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user