From fd5a7f5f17456ebc207a9127e427574f563834aa Mon Sep 17 00:00:00 2001 From: Andrii Andreiev <129078694+AndriiAndreiev@users.noreply.github.com> Date: Thu, 10 Oct 2024 18:50:20 +0300 Subject: [PATCH] update tests, fixtures & snapshots --- .../__snapshots__/targets.test.ts.snap | 170 +++++++++--------- .../targets/csharp/dotnet6/webhooks/client.ts | 2 +- .../webhooks/fixtures/empty-default.cs | 8 +- .../webhooks/fixtures/quirky-escaping.cs | 22 ++- .../fixtures/security-and-server-variables.cs | 15 +- .../webhooks/fixtures/security-types.cs | 27 ++- .../webhooks/fixtures/security-variables.cs | 15 +- .../webhooks/fixtures/empty-default.js | 6 +- .../webhooks/fixtures/quirky-escaping.js | 18 +- .../fixtures/security-and-server-variables.js | 12 +- .../webhooks/fixtures/security-types.js | 22 ++- .../webhooks/fixtures/security-variables.js | 12 +- .../targets/php/laravel/webhooks/client.ts | 4 +- .../webhooks/fixtures/empty-default.php | 6 +- .../webhooks/fixtures/quirky-escaping.php | 18 +- .../security-and-server-variables.php | 12 +- .../webhooks/fixtures/security-types.php | 22 ++- .../webhooks/fixtures/security-variables.php | 12 +- .../targets/python/flask/webhooks/client.ts | 4 +- .../flask/webhooks/fixtures/empty-default.py | 6 +- .../webhooks/fixtures/quirky-escaping.py | 18 +- .../fixtures/security-and-server-variables.py | 12 +- .../flask/webhooks/fixtures/security-types.py | 22 ++- .../webhooks/fixtures/security-variables.py | 12 +- .../rails/webhooks/fixtures/empty-default.rb | 6 +- .../webhooks/fixtures/quirky-escaping.rb | 18 +- .../fixtures/security-and-server-variables.rb | 12 +- .../rails/webhooks/fixtures/security-types.rb | 22 ++- .../webhooks/fixtures/security-variables.rb | 12 +- 29 files changed, 397 insertions(+), 150 deletions(-) diff --git a/packages/sdk-snippets/src/targets/__snapshots__/targets.test.ts.snap b/packages/sdk-snippets/src/targets/__snapshots__/targets.test.ts.snap index 5347f3d252..c0ad1ea977 100644 --- a/packages/sdk-snippets/src/targets/__snapshots__/targets.test.ts.snap +++ b/packages/sdk-snippets/src/targets/__snapshots__/targets.test.ts.snap @@ -440,7 +440,7 @@ exports[`webhooks > C# snippet generation > dotnet6 > request should match fixtu { "sections": { "payload": { - "end": 37, + "end": 43, "start": 27, }, "verification": { @@ -451,7 +451,7 @@ exports[`webhooks > C# snippet generation > dotnet6 > request should match fixtu "variables": { "security": { "petstore_auth": { - "line": 36, + "line": 40, }, }, "server": { @@ -467,7 +467,7 @@ exports[`webhooks > C# snippet generation > dotnet6 > request should match fixtu { "sections": { "payload": { - "end": 42, + "end": 58, "start": 27, }, "verification": { @@ -478,13 +478,13 @@ exports[`webhooks > C# snippet generation > dotnet6 > request should match fixtu "variables": { "security": { "\\"petstore\\" auth": { - "line": 39, + "line": 43, }, "basic-auth": { - "line": 40, + "line": 47, }, "normal_security_var": { - "line": 41, + "line": 53, }, }, "server": { @@ -509,7 +509,7 @@ exports[`webhooks > C# snippet generation > dotnet6 > request should match fixtu { "sections": { "payload": { - "end": 39, + "end": 50, "start": 27, }, "verification": { @@ -520,10 +520,10 @@ exports[`webhooks > C# snippet generation > dotnet6 > request should match fixtu "variables": { "security": { "basic_auth": { - "line": 38, + "line": 45, }, "petstore_auth": { - "line": 37, + "line": 41, }, }, "server": { @@ -542,7 +542,7 @@ exports[`webhooks > C# snippet generation > dotnet6 > request should match fixtu { "sections": { "payload": { - "end": 37, + "end": 56, "start": 27, }, "verification": { @@ -553,16 +553,16 @@ exports[`webhooks > C# snippet generation > dotnet6 > request should match fixtu "variables": { "security": { "api_key": { - "line": 33, + "line": 38, }, "http_basic": { - "line": 34, + "line": 42, }, "http_bearer": { - "line": 35, + "line": 49, }, "oauth2": { - "line": 36, + "line": 53, }, }, }, @@ -573,7 +573,7 @@ exports[`webhooks > C# snippet generation > dotnet6 > request should match fixtu { "sections": { "payload": { - "end": 35, + "end": 46, "start": 27, }, "verification": { @@ -584,10 +584,10 @@ exports[`webhooks > C# snippet generation > dotnet6 > request should match fixtu "variables": { "security": { "basic_auth": { - "line": 34, + "line": 41, }, "petstore_auth": { - "line": 33, + "line": 37, }, }, }, @@ -1059,7 +1059,7 @@ exports[`webhooks > Node.js snippet generation > express > request should match { "sections": { "payload": { - "end": 28, + "end": 32, "start": 20, }, "verification": { @@ -1070,7 +1070,7 @@ exports[`webhooks > Node.js snippet generation > express > request should match "variables": { "security": { "petstore_auth": { - "line": 27, + "line": 29, }, }, "server": { @@ -1086,7 +1086,7 @@ exports[`webhooks > Node.js snippet generation > express > request should match { "sections": { "payload": { - "end": 33, + "end": 45, "start": 20, }, "verification": { @@ -1097,13 +1097,13 @@ exports[`webhooks > Node.js snippet generation > express > request should match "variables": { "security": { "\\"petstore\\" auth": { - "line": 30, + "line": 32, }, "basic-auth": { - "line": 31, + "line": 35, }, "normal_security_var": { - "line": 32, + "line": 40, }, }, "server": { @@ -1128,7 +1128,7 @@ exports[`webhooks > Node.js snippet generation > express > request should match { "sections": { "payload": { - "end": 30, + "end": 38, "start": 20, }, "verification": { @@ -1139,10 +1139,10 @@ exports[`webhooks > Node.js snippet generation > express > request should match "variables": { "security": { "basic_auth": { - "line": 29, + "line": 33, }, "petstore_auth": { - "line": 28, + "line": 30, }, }, "server": { @@ -1161,7 +1161,7 @@ exports[`webhooks > Node.js snippet generation > express > request should match { "sections": { "payload": { - "end": 28, + "end": 42, "start": 20, }, "verification": { @@ -1172,16 +1172,16 @@ exports[`webhooks > Node.js snippet generation > express > request should match "variables": { "security": { "api_key": { - "line": 24, + "line": 27, }, "http_basic": { - "line": 25, + "line": 30, }, "http_bearer": { - "line": 26, + "line": 36, }, "oauth2": { - "line": 27, + "line": 39, }, }, }, @@ -1192,7 +1192,7 @@ exports[`webhooks > Node.js snippet generation > express > request should match { "sections": { "payload": { - "end": 26, + "end": 34, "start": 20, }, "verification": { @@ -1203,10 +1203,10 @@ exports[`webhooks > Node.js snippet generation > express > request should match "variables": { "security": { "basic_auth": { - "line": 25, + "line": 29, }, "petstore_auth": { - "line": 24, + "line": 26, }, }, }, @@ -1258,7 +1258,7 @@ exports[`webhooks > PHP snippet generation > laravel > request should match fixt { "sections": { "payload": { - "end": 28, + "end": 32, "start": 20, }, "verification": { @@ -1269,7 +1269,7 @@ exports[`webhooks > PHP snippet generation > laravel > request should match fixt "variables": { "security": { "petstore_auth": { - "line": 27, + "line": 29, }, }, "server": { @@ -1285,7 +1285,7 @@ exports[`webhooks > PHP snippet generation > laravel > request should match fixt { "sections": { "payload": { - "end": 33, + "end": 45, "start": 20, }, "verification": { @@ -1296,13 +1296,13 @@ exports[`webhooks > PHP snippet generation > laravel > request should match fixt "variables": { "security": { "\\"petstore\\" auth": { - "line": 30, + "line": 32, }, "basic-auth": { - "line": 31, + "line": 35, }, "normal_security_var": { - "line": 32, + "line": 40, }, }, "server": { @@ -1327,7 +1327,7 @@ exports[`webhooks > PHP snippet generation > laravel > request should match fixt { "sections": { "payload": { - "end": 30, + "end": 38, "start": 20, }, "verification": { @@ -1338,10 +1338,10 @@ exports[`webhooks > PHP snippet generation > laravel > request should match fixt "variables": { "security": { "basic_auth": { - "line": 29, + "line": 33, }, "petstore_auth": { - "line": 28, + "line": 30, }, }, "server": { @@ -1360,7 +1360,7 @@ exports[`webhooks > PHP snippet generation > laravel > request should match fixt { "sections": { "payload": { - "end": 28, + "end": 42, "start": 20, }, "verification": { @@ -1371,16 +1371,16 @@ exports[`webhooks > PHP snippet generation > laravel > request should match fixt "variables": { "security": { "api_key": { - "line": 24, + "line": 27, }, "http_basic": { - "line": 25, + "line": 30, }, "http_bearer": { - "line": 26, + "line": 36, }, "oauth2": { - "line": 27, + "line": 39, }, }, }, @@ -1391,7 +1391,7 @@ exports[`webhooks > PHP snippet generation > laravel > request should match fixt { "sections": { "payload": { - "end": 26, + "end": 34, "start": 20, }, "verification": { @@ -1402,10 +1402,10 @@ exports[`webhooks > PHP snippet generation > laravel > request should match fixt "variables": { "security": { "basic_auth": { - "line": 25, + "line": 29, }, "petstore_auth": { - "line": 24, + "line": 26, }, }, }, @@ -1877,7 +1877,7 @@ exports[`webhooks > Python snippet generation > flask > request should match fix { "sections": { "payload": { - "end": 43, + "end": 47, "start": 31, }, "verification": { @@ -1888,7 +1888,7 @@ exports[`webhooks > Python snippet generation > flask > request should match fix "variables": { "security": { "petstore_auth": { - "line": 39, + "line": 41, }, }, "server": { @@ -1904,7 +1904,7 @@ exports[`webhooks > Python snippet generation > flask > request should match fix { "sections": { "payload": { - "end": 48, + "end": 60, "start": 31, }, "verification": { @@ -1915,13 +1915,13 @@ exports[`webhooks > Python snippet generation > flask > request should match fix "variables": { "security": { "\\"petstore\\" auth": { - "line": 42, + "line": 44, }, "basic-auth": { - "line": 43, + "line": 47, }, "normal_security_var": { - "line": 44, + "line": 52, }, }, "server": { @@ -1946,7 +1946,7 @@ exports[`webhooks > Python snippet generation > flask > request should match fix { "sections": { "payload": { - "end": 45, + "end": 53, "start": 31, }, "verification": { @@ -1957,10 +1957,10 @@ exports[`webhooks > Python snippet generation > flask > request should match fix "variables": { "security": { "basic_auth": { - "line": 41, + "line": 45, }, "petstore_auth": { - "line": 40, + "line": 42, }, }, "server": { @@ -1979,7 +1979,7 @@ exports[`webhooks > Python snippet generation > flask > request should match fix { "sections": { "payload": { - "end": 43, + "end": 57, "start": 31, }, "verification": { @@ -1990,16 +1990,16 @@ exports[`webhooks > Python snippet generation > flask > request should match fix "variables": { "security": { "api_key": { - "line": 36, + "line": 39, }, "http_basic": { - "line": 37, + "line": 42, }, "http_bearer": { - "line": 38, + "line": 48, }, "oauth2": { - "line": 39, + "line": 51, }, }, }, @@ -2010,7 +2010,7 @@ exports[`webhooks > Python snippet generation > flask > request should match fix { "sections": { "payload": { - "end": 41, + "end": 49, "start": 31, }, "verification": { @@ -2021,10 +2021,10 @@ exports[`webhooks > Python snippet generation > flask > request should match fix "variables": { "security": { "basic_auth": { - "line": 37, + "line": 41, }, "petstore_auth": { - "line": 36, + "line": 38, }, }, }, @@ -2496,7 +2496,7 @@ exports[`webhooks > Ruby snippet generation > rails > request should match fixtu { "sections": { "payload": { - "end": 34, + "end": 38, "start": 26, }, "verification": { @@ -2507,7 +2507,7 @@ exports[`webhooks > Ruby snippet generation > rails > request should match fixtu "variables": { "security": { "petstore_auth": { - "line": 33, + "line": 35, }, }, "server": { @@ -2523,7 +2523,7 @@ exports[`webhooks > Ruby snippet generation > rails > request should match fixtu { "sections": { "payload": { - "end": 39, + "end": 51, "start": 26, }, "verification": { @@ -2534,13 +2534,13 @@ exports[`webhooks > Ruby snippet generation > rails > request should match fixtu "variables": { "security": { "\\"petstore\\" auth": { - "line": 36, + "line": 38, }, "basic-auth": { - "line": 37, + "line": 41, }, "normal_security_var": { - "line": 38, + "line": 46, }, }, "server": { @@ -2565,7 +2565,7 @@ exports[`webhooks > Ruby snippet generation > rails > request should match fixtu { "sections": { "payload": { - "end": 36, + "end": 44, "start": 26, }, "verification": { @@ -2576,10 +2576,10 @@ exports[`webhooks > Ruby snippet generation > rails > request should match fixtu "variables": { "security": { "basic_auth": { - "line": 35, + "line": 39, }, "petstore_auth": { - "line": 34, + "line": 36, }, }, "server": { @@ -2598,7 +2598,7 @@ exports[`webhooks > Ruby snippet generation > rails > request should match fixtu { "sections": { "payload": { - "end": 34, + "end": 48, "start": 26, }, "verification": { @@ -2609,16 +2609,16 @@ exports[`webhooks > Ruby snippet generation > rails > request should match fixtu "variables": { "security": { "api_key": { - "line": 30, + "line": 33, }, "http_basic": { - "line": 31, + "line": 36, }, "http_bearer": { - "line": 32, + "line": 42, }, "oauth2": { - "line": 33, + "line": 45, }, }, }, @@ -2629,7 +2629,7 @@ exports[`webhooks > Ruby snippet generation > rails > request should match fixtu { "sections": { "payload": { - "end": 32, + "end": 40, "start": 26, }, "verification": { @@ -2640,10 +2640,10 @@ exports[`webhooks > Ruby snippet generation > rails > request should match fixtu "variables": { "security": { "basic_auth": { - "line": 31, + "line": 35, }, "petstore_auth": { - "line": 30, + "line": 32, }, }, }, diff --git a/packages/sdk-snippets/src/targets/csharp/dotnet6/webhooks/client.ts b/packages/sdk-snippets/src/targets/csharp/dotnet6/webhooks/client.ts index 090160906e..ccd97885b8 100644 --- a/packages/sdk-snippets/src/targets/csharp/dotnet6/webhooks/client.ts +++ b/packages/sdk-snippets/src/targets/csharp/dotnet6/webhooks/client.ts @@ -122,7 +122,7 @@ export const dotnet6: Client = { } } else { pushVariable( - `${escapeForObjectKey(data.name)} = "${escapeForDoubleQuotes( + `${escapeForObjectKey(data.name, true)} = "${escapeForDoubleQuotes( data.default || data.default === '' ? data.default : data.name, )}",`, variableOptions, diff --git a/packages/sdk-snippets/src/targets/csharp/dotnet6/webhooks/fixtures/empty-default.cs b/packages/sdk-snippets/src/targets/csharp/dotnet6/webhooks/fixtures/empty-default.cs index d95b536f37..eaaeff85fe 100644 --- a/packages/sdk-snippets/src/targets/csharp/dotnet6/webhooks/fixtures/empty-default.cs +++ b/packages/sdk-snippets/src/targets/csharp/dotnet6/webhooks/fixtures/empty-default.cs @@ -33,7 +33,13 @@ await context.Response.WriteAsJsonAsync(new name = "", // OAS Security variables - petstore_auth = "", + keys = new[] + { + new + { + petstore_auth = "", + }, + } }); }); diff --git a/packages/sdk-snippets/src/targets/csharp/dotnet6/webhooks/fixtures/quirky-escaping.cs b/packages/sdk-snippets/src/targets/csharp/dotnet6/webhooks/fixtures/quirky-escaping.cs index 0775981821..1ced362fc8 100644 --- a/packages/sdk-snippets/src/targets/csharp/dotnet6/webhooks/fixtures/quirky-escaping.cs +++ b/packages/sdk-snippets/src/targets/csharp/dotnet6/webhooks/fixtures/quirky-escaping.cs @@ -36,9 +36,25 @@ await context.Response.WriteAsJsonAsync(new normal_server_var = "", // OAS Security variables - "\"petstore\" auth" = "default \"key\"\\", - "basic-auth" = new { user = "user", pass = "pass" }, - normal_security_var = new { user = "user", pass = "pass" }, + keys = new[] + { + new + { + "\"petstore\" auth" = "default \"key\"\\", + }, + new + { + name = "basic-auth", + user = "user", + pass = "pass", + }, + new + { + name = "normal_security_var", + user = "user", + pass = "pass", + }, + } }); }); diff --git a/packages/sdk-snippets/src/targets/csharp/dotnet6/webhooks/fixtures/security-and-server-variables.cs b/packages/sdk-snippets/src/targets/csharp/dotnet6/webhooks/fixtures/security-and-server-variables.cs index e0b2bc16b2..f3ec31b4c4 100644 --- a/packages/sdk-snippets/src/targets/csharp/dotnet6/webhooks/fixtures/security-and-server-variables.cs +++ b/packages/sdk-snippets/src/targets/csharp/dotnet6/webhooks/fixtures/security-and-server-variables.cs @@ -34,8 +34,19 @@ await context.Response.WriteAsJsonAsync(new port = "", // OAS Security variables - petstore_auth = "default-key", - basic_auth = new { user = "user", pass = "pass" }, + keys = new[] + { + new + { + petstore_auth = "default-key", + }, + new + { + name = "basic_auth", + user = "user", + pass = "pass", + }, + } }); }); diff --git a/packages/sdk-snippets/src/targets/csharp/dotnet6/webhooks/fixtures/security-types.cs b/packages/sdk-snippets/src/targets/csharp/dotnet6/webhooks/fixtures/security-types.cs index ab5cd12446..bb8c597c74 100644 --- a/packages/sdk-snippets/src/targets/csharp/dotnet6/webhooks/fixtures/security-types.cs +++ b/packages/sdk-snippets/src/targets/csharp/dotnet6/webhooks/fixtures/security-types.cs @@ -30,10 +30,29 @@ await context.Response.WriteAsJsonAsync(new await context.Response.WriteAsJsonAsync(new { // OAS Security variables - api_key = "default-api_key-key", - http_basic = new { user = "user", pass = "pass" }, - http_bearer = "default-http_bearer-key", - oauth2 = "default-oauth2-key", + keys = new[] + { + new + { + name = "api_key", + apiKey = "default-api_key-key", + }, + new + { + name = "http_basic", + user = "user", + pass = "pass", + }, + new + { + name = "http_bearer", + bearer = "default-http_bearer-key", + }, + new + { + oauth2 = "default-oauth2-key", + }, + } }); }); diff --git a/packages/sdk-snippets/src/targets/csharp/dotnet6/webhooks/fixtures/security-variables.cs b/packages/sdk-snippets/src/targets/csharp/dotnet6/webhooks/fixtures/security-variables.cs index 074d7219b5..b4ed2a1106 100644 --- a/packages/sdk-snippets/src/targets/csharp/dotnet6/webhooks/fixtures/security-variables.cs +++ b/packages/sdk-snippets/src/targets/csharp/dotnet6/webhooks/fixtures/security-variables.cs @@ -30,8 +30,19 @@ await context.Response.WriteAsJsonAsync(new await context.Response.WriteAsJsonAsync(new { // OAS Security variables - petstore_auth = "default-key", - basic_auth = new { user = "user", pass = "pass" }, + keys = new[] + { + new + { + petstore_auth = "default-key", + }, + new + { + name = "basic_auth", + user = "user", + pass = "pass", + }, + } }); }); diff --git a/packages/sdk-snippets/src/targets/node/express/webhooks/fixtures/empty-default.js b/packages/sdk-snippets/src/targets/node/express/webhooks/fixtures/empty-default.js index 32956df487..8fc8273c31 100644 --- a/packages/sdk-snippets/src/targets/node/express/webhooks/fixtures/empty-default.js +++ b/packages/sdk-snippets/src/targets/node/express/webhooks/fixtures/empty-default.js @@ -24,7 +24,11 @@ app.post('/webhook', express.json({ type: 'application/json' }), async (req, res name: '', // OAS Security variables - petstore_auth: '', + keys: [ + { + petstore_auth: '', + }, + ] }); }); diff --git a/packages/sdk-snippets/src/targets/node/express/webhooks/fixtures/quirky-escaping.js b/packages/sdk-snippets/src/targets/node/express/webhooks/fixtures/quirky-escaping.js index 1ebe06a12d..c19485a698 100644 --- a/packages/sdk-snippets/src/targets/node/express/webhooks/fixtures/quirky-escaping.js +++ b/packages/sdk-snippets/src/targets/node/express/webhooks/fixtures/quirky-escaping.js @@ -27,9 +27,21 @@ app.post('/webhook', express.json({ type: 'application/json' }), async (req, res normal_server_var: '', // OAS Security variables - '"petstore" auth': 'default "key"\\', - 'basic-auth': { user: 'user', pass: 'pass' }, - normal_security_var: { user: 'user', pass: 'pass' }, + keys: [ + { + '"petstore" auth': 'default "key"\\', + }, + { + name: 'basic-auth', + user: 'user', + pass: 'pass', + }, + { + name: 'normal_security_var', + user: 'user', + pass: 'pass', + }, + ] }); }); diff --git a/packages/sdk-snippets/src/targets/node/express/webhooks/fixtures/security-and-server-variables.js b/packages/sdk-snippets/src/targets/node/express/webhooks/fixtures/security-and-server-variables.js index 8f59d7f984..aa08f7a379 100644 --- a/packages/sdk-snippets/src/targets/node/express/webhooks/fixtures/security-and-server-variables.js +++ b/packages/sdk-snippets/src/targets/node/express/webhooks/fixtures/security-and-server-variables.js @@ -25,8 +25,16 @@ app.post('/webhook', express.json({ type: 'application/json' }), async (req, res port: '', // OAS Security variables - petstore_auth: 'default-key', - basic_auth: { user: 'user', pass: 'pass' }, + keys: [ + { + petstore_auth: 'default-key', + }, + { + name: 'basic_auth', + user: 'user', + pass: 'pass', + }, + ] }); }); diff --git a/packages/sdk-snippets/src/targets/node/express/webhooks/fixtures/security-types.js b/packages/sdk-snippets/src/targets/node/express/webhooks/fixtures/security-types.js index 4ed74cc58a..8fd8bfb96e 100644 --- a/packages/sdk-snippets/src/targets/node/express/webhooks/fixtures/security-types.js +++ b/packages/sdk-snippets/src/targets/node/express/webhooks/fixtures/security-types.js @@ -21,10 +21,24 @@ app.post('/webhook', express.json({ type: 'application/json' }), async (req, res // const user = await db.find({ email: req.body.email }) return res.json({ // OAS Security variables - api_key: 'default-api_key-key', - http_basic: { user: 'user', pass: 'pass' }, - http_bearer: 'default-http_bearer-key', - oauth2: 'default-oauth2-key', + keys: [ + { + name: 'api_key', + apiKey: 'default-api_key-key', + }, + { + name: 'http_basic', + user: 'user', + pass: 'pass', + }, + { + name: 'http_bearer', + bearer: 'default-http_bearer-key', + }, + { + oauth2: 'default-oauth2-key', + }, + ] }); }); diff --git a/packages/sdk-snippets/src/targets/node/express/webhooks/fixtures/security-variables.js b/packages/sdk-snippets/src/targets/node/express/webhooks/fixtures/security-variables.js index ee4f848bad..766e52322a 100644 --- a/packages/sdk-snippets/src/targets/node/express/webhooks/fixtures/security-variables.js +++ b/packages/sdk-snippets/src/targets/node/express/webhooks/fixtures/security-variables.js @@ -21,8 +21,16 @@ app.post('/webhook', express.json({ type: 'application/json' }), async (req, res // const user = await db.find({ email: req.body.email }) return res.json({ // OAS Security variables - petstore_auth: 'default-key', - basic_auth: { user: 'user', pass: 'pass' }, + keys: [ + { + petstore_auth: 'default-key', + }, + { + name: 'basic_auth', + user: 'user', + pass: 'pass', + }, + ] }); }); diff --git a/packages/sdk-snippets/src/targets/php/laravel/webhooks/client.ts b/packages/sdk-snippets/src/targets/php/laravel/webhooks/client.ts index 25b2c54e69..298df54629 100644 --- a/packages/sdk-snippets/src/targets/php/laravel/webhooks/client.ts +++ b/packages/sdk-snippets/src/targets/php/laravel/webhooks/client.ts @@ -2,7 +2,7 @@ import type { VariableOptions } from '../../../../helpers/code-builder'; import type { Client } from '../../../targets'; import { CodeBuilder } from '../../../../helpers/code-builder'; -import { escapeForObjectKey, escapeForSingleQuotes } from '../../../../helpers/escape'; +import { escapeForSingleQuotes } from '../../../../helpers/escape'; export const laravel: Client = { info: { @@ -109,7 +109,7 @@ export const laravel: Client = { } } else { pushVariable( - `'${escapeForObjectKey(data.name)}': '${escapeForSingleQuotes( + `'${escapeForSingleQuotes(data.name)}' => '${escapeForSingleQuotes( data.default || data.default === '' ? data.default : data.name, )}',`, variableOptions, diff --git a/packages/sdk-snippets/src/targets/php/laravel/webhooks/fixtures/empty-default.php b/packages/sdk-snippets/src/targets/php/laravel/webhooks/fixtures/empty-default.php index c94d1be7cd..341dc7a21e 100644 --- a/packages/sdk-snippets/src/targets/php/laravel/webhooks/fixtures/empty-default.php +++ b/packages/sdk-snippets/src/targets/php/laravel/webhooks/fixtures/empty-default.php @@ -24,6 +24,10 @@ 'name' => '', // OAS Security variables - 'petstore_auth' => '', + 'keys' => [ + [ + 'petstore_auth' => '', + ], + ] ]); }); diff --git a/packages/sdk-snippets/src/targets/php/laravel/webhooks/fixtures/quirky-escaping.php b/packages/sdk-snippets/src/targets/php/laravel/webhooks/fixtures/quirky-escaping.php index 15dcabb384..fe5c521b07 100644 --- a/packages/sdk-snippets/src/targets/php/laravel/webhooks/fixtures/quirky-escaping.php +++ b/packages/sdk-snippets/src/targets/php/laravel/webhooks/fixtures/quirky-escaping.php @@ -27,8 +27,20 @@ 'normal_server_var' => '', // OAS Security variables - '"petstore" auth' => 'default "key"\\', - 'basic-auth' => ['user' => 'user', 'pass' => 'pass'], - 'normal_security_var' => ['user' => 'user', 'pass' => 'pass'], + 'keys' => [ + [ + '"petstore" auth' => 'default "key"\\', + ], + [ + 'name' => 'basic-auth', + 'user' => 'user', + 'pass' => 'pass', + ], + [ + 'name' => 'normal_security_var', + 'user' => 'user', + 'pass' => 'pass', + ], + ] ]); }); diff --git a/packages/sdk-snippets/src/targets/php/laravel/webhooks/fixtures/security-and-server-variables.php b/packages/sdk-snippets/src/targets/php/laravel/webhooks/fixtures/security-and-server-variables.php index 9b8dc9f759..66a3b69f99 100644 --- a/packages/sdk-snippets/src/targets/php/laravel/webhooks/fixtures/security-and-server-variables.php +++ b/packages/sdk-snippets/src/targets/php/laravel/webhooks/fixtures/security-and-server-variables.php @@ -25,7 +25,15 @@ 'port' => '', // OAS Security variables - 'petstore_auth' => 'default-key', - 'basic_auth' => ['user' => 'user', 'pass' => 'pass'], + 'keys' => [ + [ + 'petstore_auth' => 'default-key', + ], + [ + 'name' => 'basic_auth', + 'user' => 'user', + 'pass' => 'pass', + ], + ] ]); }); diff --git a/packages/sdk-snippets/src/targets/php/laravel/webhooks/fixtures/security-types.php b/packages/sdk-snippets/src/targets/php/laravel/webhooks/fixtures/security-types.php index 01e4375ded..5f4524d710 100644 --- a/packages/sdk-snippets/src/targets/php/laravel/webhooks/fixtures/security-types.php +++ b/packages/sdk-snippets/src/targets/php/laravel/webhooks/fixtures/security-types.php @@ -21,9 +21,23 @@ // $user = DB::table('users')->where('email', $request->input('email'))->limit(1)->get(); return response()->json([ // OAS Security variables - 'api_key' => 'default-api_key-key', - 'http_basic' => ['user' => 'user', 'pass' => 'pass'], - 'http_bearer' => 'default-http_bearer-key', - 'oauth2' => 'default-oauth2-key', + 'keys' => [ + [ + 'name' => 'api_key', + 'apiKey' => 'default-api_key-key', + ], + [ + 'name' => 'http_basic', + 'user' => 'user', + 'pass' => 'pass', + ], + [ + 'name' => 'http_bearer', + 'bearer' => 'default-http_bearer-key', + ], + [ + 'oauth2' => 'default-oauth2-key', + ], + ] ]); }); diff --git a/packages/sdk-snippets/src/targets/php/laravel/webhooks/fixtures/security-variables.php b/packages/sdk-snippets/src/targets/php/laravel/webhooks/fixtures/security-variables.php index 829ff919d5..8020bd8fa6 100644 --- a/packages/sdk-snippets/src/targets/php/laravel/webhooks/fixtures/security-variables.php +++ b/packages/sdk-snippets/src/targets/php/laravel/webhooks/fixtures/security-variables.php @@ -21,7 +21,15 @@ // $user = DB::table('users')->where('email', $request->input('email'))->limit(1)->get(); return response()->json([ // OAS Security variables - 'petstore_auth' => 'default-key', - 'basic_auth' => ['user' => 'user', 'pass' => 'pass'], + 'keys' => [ + [ + 'petstore_auth' => 'default-key', + ], + [ + 'name' => 'basic_auth', + 'user' => 'user', + 'pass' => 'pass', + ], + ] ]); }); diff --git a/packages/sdk-snippets/src/targets/python/flask/webhooks/client.ts b/packages/sdk-snippets/src/targets/python/flask/webhooks/client.ts index 7fcd498a2e..20961bae88 100644 --- a/packages/sdk-snippets/src/targets/python/flask/webhooks/client.ts +++ b/packages/sdk-snippets/src/targets/python/flask/webhooks/client.ts @@ -2,7 +2,7 @@ import type { VariableOptions } from '../../../../helpers/code-builder'; import type { Client } from '../../../targets'; import { CodeBuilder } from '../../../../helpers/code-builder'; -import { escapeForDoubleQuotes, escapeForObjectKey } from '../../../../helpers/escape'; +import { escapeForDoubleQuotes } from '../../../../helpers/escape'; export const flask: Client = { info: { @@ -121,7 +121,7 @@ export const flask: Client = { } } else { pushVariable( - `"${escapeForObjectKey(data.name)}": "${escapeForDoubleQuotes( + `"${escapeForDoubleQuotes(data.name)}": "${escapeForDoubleQuotes( data.default || data.default === '' ? data.default : data.name, )}",`, variableOptions, diff --git a/packages/sdk-snippets/src/targets/python/flask/webhooks/fixtures/empty-default.py b/packages/sdk-snippets/src/targets/python/flask/webhooks/fixtures/empty-default.py index ab23fab22d..363b5248df 100644 --- a/packages/sdk-snippets/src/targets/python/flask/webhooks/fixtures/empty-default.py +++ b/packages/sdk-snippets/src/targets/python/flask/webhooks/fixtures/empty-default.py @@ -36,7 +36,11 @@ def webhook(): "name": "", # OAS Security variables - "petstore_auth": "", + "keys": [ + { + "petstore_auth": "", + }, + ] }, 200, {"Content-Type": "application/json; charset=utf-8"}, diff --git a/packages/sdk-snippets/src/targets/python/flask/webhooks/fixtures/quirky-escaping.py b/packages/sdk-snippets/src/targets/python/flask/webhooks/fixtures/quirky-escaping.py index 24dccaaa5e..9342298fc7 100644 --- a/packages/sdk-snippets/src/targets/python/flask/webhooks/fixtures/quirky-escaping.py +++ b/packages/sdk-snippets/src/targets/python/flask/webhooks/fixtures/quirky-escaping.py @@ -39,9 +39,21 @@ def webhook(): "normal_server_var": "", # OAS Security variables - "\"petstore\" auth": "default \"key\"\\", - "basic-auth": {"user": "user", "pass": "pass"}, - "normal_security_var": {"user": "user", "pass": "pass"}, + "keys": [ + { + "\"petstore\" auth": "default \"key\"\\", + }, + { + "name": "basic-auth", + "user": "user", + "pass": "pass", + }, + { + "name": "normal_security_var", + "user": "user", + "pass": "pass", + }, + ] }, 200, {"Content-Type": "application/json; charset=utf-8"}, diff --git a/packages/sdk-snippets/src/targets/python/flask/webhooks/fixtures/security-and-server-variables.py b/packages/sdk-snippets/src/targets/python/flask/webhooks/fixtures/security-and-server-variables.py index 336ffa0d45..4e7409d6e1 100644 --- a/packages/sdk-snippets/src/targets/python/flask/webhooks/fixtures/security-and-server-variables.py +++ b/packages/sdk-snippets/src/targets/python/flask/webhooks/fixtures/security-and-server-variables.py @@ -37,8 +37,16 @@ def webhook(): "port": "", # OAS Security variables - "petstore_auth": "default-key", - "basic_auth": {"user": "user", "pass": "pass"}, + "keys": [ + { + "petstore_auth": "default-key", + }, + { + "name": "basic_auth", + "user": "user", + "pass": "pass", + }, + ] }, 200, {"Content-Type": "application/json; charset=utf-8"}, diff --git a/packages/sdk-snippets/src/targets/python/flask/webhooks/fixtures/security-types.py b/packages/sdk-snippets/src/targets/python/flask/webhooks/fixtures/security-types.py index d5d5e8c1fd..fc395ac0cd 100644 --- a/packages/sdk-snippets/src/targets/python/flask/webhooks/fixtures/security-types.py +++ b/packages/sdk-snippets/src/targets/python/flask/webhooks/fixtures/security-types.py @@ -33,10 +33,24 @@ def webhook(): return ( { # OAS Security variables - "api_key": "default-api_key-key", - "http_basic": {"user": "user", "pass": "pass"}, - "http_bearer": "default-http_bearer-key", - "oauth2": "default-oauth2-key", + "keys": [ + { + "name": "api_key", + "apiKey": "default-api_key-key", + }, + { + "name": "http_basic", + "user": "user", + "pass": "pass", + }, + { + "name": "http_bearer", + "bearer": "default-http_bearer-key", + }, + { + "oauth2": "default-oauth2-key", + }, + ] }, 200, {"Content-Type": "application/json; charset=utf-8"}, diff --git a/packages/sdk-snippets/src/targets/python/flask/webhooks/fixtures/security-variables.py b/packages/sdk-snippets/src/targets/python/flask/webhooks/fixtures/security-variables.py index ef4fba2bf3..30200d42f0 100644 --- a/packages/sdk-snippets/src/targets/python/flask/webhooks/fixtures/security-variables.py +++ b/packages/sdk-snippets/src/targets/python/flask/webhooks/fixtures/security-variables.py @@ -33,8 +33,16 @@ def webhook(): return ( { # OAS Security variables - "petstore_auth": "default-key", - "basic_auth": {"user": "user", "pass": "pass"}, + "keys": [ + { + "petstore_auth": "default-key", + }, + { + "name": "basic_auth", + "user": "user", + "pass": "pass", + }, + ] }, 200, {"Content-Type": "application/json; charset=utf-8"}, diff --git a/packages/sdk-snippets/src/targets/ruby/rails/webhooks/fixtures/empty-default.rb b/packages/sdk-snippets/src/targets/ruby/rails/webhooks/fixtures/empty-default.rb index d6bada5be7..b67f961471 100644 --- a/packages/sdk-snippets/src/targets/ruby/rails/webhooks/fixtures/empty-default.rb +++ b/packages/sdk-snippets/src/targets/ruby/rails/webhooks/fixtures/empty-default.rb @@ -30,7 +30,11 @@ def webhook name: '', # OAS Security variables - petstore_auth: '', + keys: [ + { + petstore_auth: '', + }, + ] } end end diff --git a/packages/sdk-snippets/src/targets/ruby/rails/webhooks/fixtures/quirky-escaping.rb b/packages/sdk-snippets/src/targets/ruby/rails/webhooks/fixtures/quirky-escaping.rb index 56cd83a7c6..f6afe82262 100644 --- a/packages/sdk-snippets/src/targets/ruby/rails/webhooks/fixtures/quirky-escaping.rb +++ b/packages/sdk-snippets/src/targets/ruby/rails/webhooks/fixtures/quirky-escaping.rb @@ -33,9 +33,21 @@ def webhook normal_server_var: '', # OAS Security variables - '"petstore" auth': 'default "key"\\', - 'basic-auth': { user: 'user', pass: 'pass' }, - normal_security_var: { user: 'user', pass: 'pass' }, + keys: [ + { + '"petstore" auth': 'default "key"\\', + }, + { + name: 'basic-auth', + user: 'user', + pass: 'pass', + }, + { + name: 'normal_security_var', + user: 'user', + pass: 'pass', + }, + ] } end end diff --git a/packages/sdk-snippets/src/targets/ruby/rails/webhooks/fixtures/security-and-server-variables.rb b/packages/sdk-snippets/src/targets/ruby/rails/webhooks/fixtures/security-and-server-variables.rb index eba5c22696..7b4cb0723c 100644 --- a/packages/sdk-snippets/src/targets/ruby/rails/webhooks/fixtures/security-and-server-variables.rb +++ b/packages/sdk-snippets/src/targets/ruby/rails/webhooks/fixtures/security-and-server-variables.rb @@ -31,8 +31,16 @@ def webhook port: '', # OAS Security variables - petstore_auth: 'default-key', - basic_auth: { user: 'user', pass: 'pass' }, + keys: [ + { + petstore_auth: 'default-key', + }, + { + name: 'basic_auth', + user: 'user', + pass: 'pass', + }, + ] } end end diff --git a/packages/sdk-snippets/src/targets/ruby/rails/webhooks/fixtures/security-types.rb b/packages/sdk-snippets/src/targets/ruby/rails/webhooks/fixtures/security-types.rb index e2e27f2889..3be3633a5e 100644 --- a/packages/sdk-snippets/src/targets/ruby/rails/webhooks/fixtures/security-types.rb +++ b/packages/sdk-snippets/src/targets/ruby/rails/webhooks/fixtures/security-types.rb @@ -27,10 +27,24 @@ def webhook # current_user ||= User.find(session[:user_id]) if session[:user_id] render json: { # OAS Security variables - api_key: 'default-api_key-key', - http_basic: { user: 'user', pass: 'pass' }, - http_bearer: 'default-http_bearer-key', - oauth2: 'default-oauth2-key', + keys: [ + { + name: 'api_key', + apiKey: 'default-api_key-key', + }, + { + name: 'http_basic', + user: 'user', + pass: 'pass', + }, + { + name: 'http_bearer', + bearer: 'default-http_bearer-key', + }, + { + oauth2: 'default-oauth2-key', + }, + ] } end end diff --git a/packages/sdk-snippets/src/targets/ruby/rails/webhooks/fixtures/security-variables.rb b/packages/sdk-snippets/src/targets/ruby/rails/webhooks/fixtures/security-variables.rb index 600971f3a7..6cc35bf16d 100644 --- a/packages/sdk-snippets/src/targets/ruby/rails/webhooks/fixtures/security-variables.rb +++ b/packages/sdk-snippets/src/targets/ruby/rails/webhooks/fixtures/security-variables.rb @@ -27,8 +27,16 @@ def webhook # current_user ||= User.find(session[:user_id]) if session[:user_id] render json: { # OAS Security variables - petstore_auth: 'default-key', - basic_auth: { user: 'user', pass: 'pass' }, + keys: [ + { + petstore_auth: 'default-key', + }, + { + name: 'basic_auth', + user: 'user', + pass: 'pass', + }, + ] } end end