Skip to content

Commit

Permalink
add syntax fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
AndriiAndreiev committed Oct 8, 2024
1 parent 071bb2c commit 1affa07
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 67 deletions.
28 changes: 15 additions & 13 deletions packages/sdk-snippets/src/targets/csharp/dotnet6/webhooks/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,26 +89,27 @@ export const dotnet6: Client = {

if (security.length) {
push('// OAS Security variables', 2);
push('keys = new[]', 2);
push('{', 2);
security.forEach(data => {
push('new', 3);
push('{', 3);
if (data.type === 'http') {
if (data.type === 'http' && data.scheme === 'basic') {
// Only HTTP Basic auth has any special handling for supplying auth.
if (data.scheme === 'basic') {
pushVariable(`name = "${escapeForDoubleQuotes(data.name)}",`, {
type: 'security',
name: data.name,
indentationLevel: 4,
});
push('user = "user",', 4);
push('pass = "pass",', 4);
}
} else if (data.type === 'oauth') {
pushVariable(`name = "${escapeForDoubleQuotes(data.name)}",`, {
type: 'security',
name: data.name,
indentationLevel: 4,
});
push('user = "user",', 4);
push('pass = "pass"', 4);
} else if (data.type.includes('oauth')) {
pushVariable(`name = "${data.name}",`, {
type: 'security',
name: data.name,
indentationLevel: 4,
});
push('apiKey = "apiKey",', 4);
push('apiKey = "apiKey"', 4);
} else {
pushVariable(
`${escapeForObjectKey(data.name, true)} = "${escapeForDoubleQuotes(
Expand All @@ -121,8 +122,9 @@ export const dotnet6: Client = {
},
);
}
push(',', 3);
push('},', 3);
});
push('}', 2);
}

push('});', 1);
Expand Down
20 changes: 9 additions & 11 deletions packages/sdk-snippets/src/targets/node/express/webhooks/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,16 @@ export const express: Client = {
push('keys: [', 2);
security.forEach(data => {
push('{', 3);
if (data.type === 'http') {
if (data.type === 'http' && data.scheme === 'basic') {
// Only HTTP Basic auth has any special handling for supplying auth.
if (data.scheme === 'basic') {
pushVariable(`name: '${escapeForSingleQuotes(data.name)}',`, {
type: 'security',
name: data.name,
indentationLevel: 4,
});
push("user: 'user',", 4);
push("pass: 'pass',", 4);
}
} else if (data.type === 'oauth') {
pushVariable(`name: '${escapeForSingleQuotes(data.name)}',`, {
type: 'security',
name: data.name,
indentationLevel: 4,
});
push("user: 'user',", 4);
push("pass: 'pass',", 4);
} else if (data.type.includes('oauth')) {
pushVariable(`name: '${escapeForSingleQuotes(data.name)}',`, {
type: 'security',
name: data.name,
Expand Down
30 changes: 14 additions & 16 deletions packages/sdk-snippets/src/targets/php/laravel/webhooks/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,27 +76,25 @@ export const laravel: Client = {

if (security.length) {
push('// OAS Security variables', 2);
push('keys => array(', 2);
push("'keys' => [", 2);
security.forEach(data => {
push('[', 3);
if (data.type === 'http') {
if (data.type === 'http' && data.scheme === 'basic') {
// Only HTTP Basic auth has any special handling for supplying auth.
if (data.scheme === 'basic') {
pushVariable(`name => '${escapeForSingleQuotes(data.name)}',`, {
type: 'security',
name: data.name,
indentationLevel: 4,
});
push("user => 'user',", 4);
push("pass => 'pass',", 4);
}
} else if (data.type === 'oauth') {
pushVariable(`name => ${data.name}',`, {
pushVariable(`'name' => '${escapeForSingleQuotes(data.name)}',`, {
type: 'security',
name: data.name,
indentationLevel: 4,
});
push("'user' => 'user',", 4);
push("'pass' => 'pass',", 4);
} else if (data.type.includes('oauth')) {
pushVariable(`'name' => '${data.name}',`, {
type: 'security',
name: data.name,
indentationLevel: 4,
});
push("apiKey => 'apiKey',", 4);
push("'apiKey' => 'apiKey',", 4);
} else {
pushVariable(
`'${escapeForSingleQuotes(data.name)}' => '${escapeForSingleQuotes(
Expand All @@ -109,9 +107,9 @@ export const laravel: Client = {
},
);
}
push(']', 3);
push('],', 3);
});
push(')', 2);
push(']', 2);
}

push(']);', 1);
Expand Down
28 changes: 13 additions & 15 deletions packages/sdk-snippets/src/targets/python/flask/webhooks/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,24 +93,22 @@ export const flask: Client = {
push('"keys": [', 3);
security.forEach(data => {
push('{', 4);
if (data.type === 'http') {
if (data.type === 'http' && data.scheme === 'basic') {
// Only HTTP Basic auth has any special handling for supplying auth.
if (data.scheme === 'basic') {
pushVariable(`"name": "${escapeForDoubleQuotes(data.name)}",`, {
type: 'security',
name: data.name,
indentationLevel: 4,
});
push('"user": "user"', 4);
push('"pass": "pass"', 4);
}
} else if (data.type === 'oauth') {
pushVariable(`"name": "${escapeForDoubleQuotes(data.name)}",`, {
type: 'security',
name: data.name,
indentationLevel: 4,
indentationLevel: 5,
});
push('"user": "user",', 5);
push('"pass": "pass",', 5);
} else if (data.type.includes('oauth')) {
pushVariable(`"name": "${escapeForDoubleQuotes(data.name)}",`, {
type: 'security',
name: data.name,
indentationLevel: 5,
});
push('"apiKey": "apiKey",', 4);
push('"apiKey": "apiKey",', 5);
} else {
pushVariable(
`"${escapeForDoubleQuotes(data.name)}": "${escapeForDoubleQuotes(
Expand All @@ -119,11 +117,11 @@ export const flask: Client = {
{
type: 'security',
name: data.name,
indentationLevel: 4,
indentationLevel: 5,
},
);
}
push('}', 4);
push('},', 4);
});
push(']', 3);
}
Expand Down
22 changes: 10 additions & 12 deletions packages/sdk-snippets/src/targets/ruby/rails/webhooks/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,16 @@ export const rails: Client = {
push('keys: [', 3);
security.forEach(data => {
push('{', 4);
if (data.type === 'http') {
if (data.type === 'http' && data.scheme === 'basic') {
// Only HTTP Basic auth has any special handling for supplying auth.
if (data.scheme === 'basic') {
pushVariable(`name: '${escapeForSingleQuotes(data.name)}',`, {
type: 'security',
name: data.name,
indentationLevel: 5,
});
push("user: 'user',", 5);
push("pass: 'pass',", 5);
}
} else if (data.type === 'oauth') {
pushVariable(`name: '${escapeForSingleQuotes(data.name)}',`, {
type: 'security',
name: data.name,
indentationLevel: 5,
});
push("user: 'user',", 5);
push("pass: 'pass',", 5);
} else if (data.type.includes('oauth')) {
pushVariable(`name: '${escapeForSingleQuotes(data.name)}',`, {
type: 'security',
name: data.name,
Expand All @@ -121,7 +119,7 @@ export const rails: Client = {
},
);
}
push('}', 4);
push('},', 4);
});
push(']', 3);
}
Expand Down

0 comments on commit 1affa07

Please sign in to comment.