Skip to content

Commit 50cafe9

Browse files
committed
linting
1 parent 2f05549 commit 50cafe9

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

packages/react-openapi/src/code-samples.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export const codeSampleGenerators: CodeSampleGenerator[] = [
7171
const bodyString = body ? `\n${body}` : '';
7272

7373
const httpRequest = `${method.toUpperCase()} ${decodeURI(processedPath)} HTTP/1.1
74-
Host: ${origin.replaceAll(/https*:\/\//g, '')}
74+
Host: ${origin.replace(/https*:\/\//g, '')}
7575
${headerString}${bodyString}`;
7676

7777
return httpRequest;
@@ -174,9 +174,9 @@ ${headerString}${bodyString}`;
174174
generate: ({ method, url: { origin, path }, headers, body }) => {
175175
const contentType = headers?.['Content-Type'];
176176
const needsJsonImport = body && isJSON(contentType) && typeof body === 'string';
177-
177+
178178
let code = '';
179-
179+
180180
// Import statements
181181
if (needsJsonImport) {
182182
code += 'import json\n';
@@ -428,9 +428,9 @@ const BodyGenerators = {
428428
},
429429
2
430430
)
431-
.replaceAll('"$$__TRUE__$$"', 'True')
432-
.replaceAll('"$$__FALSE__$$"', 'False')
433-
.replaceAll('"$$__NULL__$$"', 'None');
431+
.replace(/"\\$\\$__TRUE__\\$\\$"/g, 'True')
432+
.replace(/"\\$\\$__FALSE__\\$\\$"/g, 'False')
433+
.replace(/"\\$\\$__NULL__\\$\\$"/g, 'None');
434434
} else {
435435
// For everything else (including JSON strings)
436436
body = stringifyOpenAPI(
@@ -449,9 +449,9 @@ const BodyGenerators = {
449449
},
450450
2
451451
)
452-
.replaceAll('"$$__TRUE__$$"', 'True')
453-
.replaceAll('"$$__FALSE__$$"', 'False')
454-
.replaceAll('"$$__NULL__$$"', 'None');
452+
.replace(/"\\$\\$__TRUE__\\$\\$"/g, 'True')
453+
.replace(/"\\$\\$__FALSE__\\$\\$"/g, 'False')
454+
.replace(/"\\$\\$__NULL__\\$\\$"/g, 'None');
455455
}
456456

457457
return { body, code, headers };
@@ -554,9 +554,7 @@ function buildHeredoc(lines: string[]): string {
554554
function convertPathParametersToPlaceholders(urlPath: string): string {
555555
return urlPath.replace(/\{([^}]+)\}/g, (match, paramName) => {
556556
// Convert camelCase to UPPER_SNAKE_CASE
557-
const placeholder = paramName
558-
.replace(/([a-z])([A-Z])/g, '$1_$2')
559-
.toUpperCase();
557+
const placeholder = paramName.replace(/([a-z])([A-Z])/g, '$1_$2').toUpperCase();
560558
return `YOUR_${placeholder}`;
561559
});
562560
}
@@ -578,7 +576,10 @@ function processHeadersWithPlaceholders(headers?: Record<string, string>): Recor
578576
processedHeaders[key] = 'Basic YOUR_API_TOKEN';
579577
} else if (value.includes('YOUR_') || value.includes('TOKEN')) {
580578
// Already in correct format or generic token
581-
processedHeaders[key] = value.replace(/YOUR_SECRET_TOKEN|YOUR_TOKEN/g, 'YOUR_API_TOKEN');
579+
processedHeaders[key] = value.replace(
580+
/YOUR_SECRET_TOKEN|YOUR_TOKEN/g,
581+
'YOUR_API_TOKEN'
582+
);
582583
} else {
583584
// Regular headers - keep as-is
584585
processedHeaders[key] = value;

0 commit comments

Comments
 (0)