hono-takibi 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Hono Takibi
|
|
4
4
|
|
|
5
|
-

|
|
5
|
+

|
|
6
6
|
|
|
7
7
|
## Migrate Legacy APIs to Hono
|
|
8
8
|
|
|
@@ -168,7 +168,7 @@ paths:
|
|
|
168
168
|
required: false
|
|
169
169
|
schema:
|
|
170
170
|
type: integer
|
|
171
|
-
minimum:
|
|
171
|
+
minimum: 0
|
|
172
172
|
default: 1
|
|
173
173
|
description: The page number to retrieve. Must be a positive integer. Defaults to 1.
|
|
174
174
|
- in: query
|
|
@@ -176,7 +176,7 @@ paths:
|
|
|
176
176
|
required: false
|
|
177
177
|
schema:
|
|
178
178
|
type: integer
|
|
179
|
-
minimum:
|
|
179
|
+
minimum: 0
|
|
180
180
|
default: 10
|
|
181
181
|
description: The number of posts per page. Must be a positive integer. Defaults to 10.
|
|
182
182
|
responses:
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.escapeString = escapeString;
|
|
4
|
+
/**
|
|
5
|
+
* Escapes single quotes in a string
|
|
6
|
+
*
|
|
7
|
+
* @function escapeString
|
|
8
|
+
* @param str - The string to escape
|
|
9
|
+
* @returns The escaped string
|
|
10
|
+
*/
|
|
11
|
+
function escapeString(str) {
|
|
12
|
+
return str?.replace(/'/g, "\\'") ?? '';
|
|
13
|
+
}
|
|
@@ -5,6 +5,7 @@ const generate_create_route_1 = require("./generate-create-route");
|
|
|
5
5
|
const generate_request_parameter_1 = require("../../request/params/generate-request-parameter");
|
|
6
6
|
const generate_response_schema_1 = require("../../response/schemas/generate-response-schema");
|
|
7
7
|
const generate_route_name_1 = require("./generate-route-name");
|
|
8
|
+
const escape_1 = require("../../../core/text/escape");
|
|
8
9
|
/**
|
|
9
10
|
* Generates TypeScript code for a Hono route based on OpenAPI operation details
|
|
10
11
|
*
|
|
@@ -64,7 +65,7 @@ function generateRoute(path, method, operation) {
|
|
|
64
65
|
tagsCode: `tags:${tagList},`,
|
|
65
66
|
methodCode: `method:'${method}',`,
|
|
66
67
|
pathCode: `path:'${path}',`,
|
|
67
|
-
descriptionCode: description ? `description:'${description}',` : '',
|
|
68
|
+
descriptionCode: description ? `description:'${(0, escape_1.escapeString)(description)}',` : '',
|
|
68
69
|
securityCode: security ? `security:${JSON.stringify(security)},` : '',
|
|
69
70
|
requestParams: requestParams ? `${requestParams}` : '',
|
|
70
71
|
responsesCode: responses ? `responses:{${(0, generate_response_schema_1.generateResponseSchema)(responses)}}` : '',
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateResponseSchema = generateResponseSchema;
|
|
4
|
+
const escape_1 = require("../../../core/text/escape");
|
|
4
5
|
const generate_zod_property_schema_1 = require("../../zod/generate-zod-property-schema");
|
|
5
6
|
/**
|
|
6
7
|
* Generates a response schema for different status codes
|
|
@@ -67,16 +68,16 @@ function generateResponseSchema(responses) {
|
|
|
67
68
|
const response = responses[code];
|
|
68
69
|
// 2.1 no content (description only response)
|
|
69
70
|
if (!response.content)
|
|
70
|
-
return `${code}:{description:'${response.description}',},`;
|
|
71
|
+
return `${code}:{description:'${(0, escape_1.escapeString)(response.description)}',},`;
|
|
71
72
|
// 2.2 processing application/json content types
|
|
72
73
|
const jsonContent = response.content['application/json'];
|
|
73
74
|
if (!jsonContent)
|
|
74
|
-
return `${code}:{description:'${response.description}',},`;
|
|
75
|
+
return `${code}:{description:'${(0, escape_1.escapeString)(response.description)}',},`;
|
|
75
76
|
// 2.3 generate zod schema
|
|
76
77
|
const schema = jsonContent.schema;
|
|
77
78
|
const zodSchema = (0, generate_zod_property_schema_1.generatePropertySchema)(schema);
|
|
78
79
|
// 2.4 generating a response definition
|
|
79
|
-
return `${code}:{description:'${response.description}',content:{'application/json':{schema:${zodSchema},},},},`;
|
|
80
|
+
return `${code}:{description:'${(0, escape_1.escapeString)(response.description)}',content:{'application/json':{schema:${zodSchema},},},},`;
|
|
80
81
|
});
|
|
81
82
|
// 3.combine all response definitions
|
|
82
83
|
return responseEntries.join('');
|