swaggular 0.2.2 → 0.2.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "swaggular",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "bin": {
@@ -1,48 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getParseArgs = getParseArgs;
4
- function getParseArgs(argv) {
5
- const args = {};
6
- const positional = [];
7
- for (let i = 0; i < argv.length; i++) {
8
- const arg = argv[i];
9
- if (arg.startsWith("--") && arg.includes("=")) {
10
- const [k, v] = arg.slice(2).split("=");
11
- args[k] = v;
12
- continue;
13
- }
14
- if (arg.startsWith("--")) {
15
- const k = arg.slice(2);
16
- const next = argv[i + 1];
17
- if (!next || next.startsWith("-")) {
18
- args[k] = true;
19
- }
20
- else {
21
- args[k] = next;
22
- i++;
23
- }
24
- continue;
25
- }
26
- if (arg.startsWith("-") && arg.length > 2) {
27
- arg
28
- .slice(1)
29
- .split("")
30
- .forEach((k) => (args[k] = true));
31
- continue;
32
- }
33
- if (arg.startsWith("-")) {
34
- const k = arg.slice(1);
35
- const next = argv[i + 1];
36
- if (!next || next.startsWith("-")) {
37
- args[k] = true;
38
- }
39
- else {
40
- args[k] = next;
41
- i++;
42
- }
43
- continue;
44
- }
45
- positional.push(arg);
46
- }
47
- return { args, positional };
48
- }
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toVariables = toVariables;
4
- function toVariables(parsed) {
5
- const variables = {};
6
- if (parsed.args.mode) {
7
- variables.groupingMode = parsed.args.mode;
8
- }
9
- if (parsed.args.segmentsToIgnore) {
10
- if (typeof parsed.args.segmentsToIgnore === "string") {
11
- variables.segmentsToIgnore = parsed.args.segmentsToIgnore.split(",");
12
- }
13
- }
14
- if (parsed.args.ignoreVariables) {
15
- variables.ignoreVariables =
16
- parsed.args.ignoreVariables === "true" ||
17
- parsed.args.ignoreVariables === true;
18
- }
19
- return {
20
- groupingMode: variables.groupingMode || "path",
21
- segmentsToIgnore: variables.segmentsToIgnore || ["api"],
22
- ignoreVariables: variables.ignoreVariables || true,
23
- };
24
- }
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildComments = buildComments;
4
- function buildComments(param) {
5
- const comments = [];
6
- if (param.format !== undefined) {
7
- comments.push(`format: ${param.format}`);
8
- }
9
- if (param.minLength !== undefined) {
10
- comments.push(`minLength: ${param.minLength}`);
11
- }
12
- if (param.maxLength !== undefined) {
13
- comments.push(`maxLength: ${param.maxLength}`);
14
- }
15
- if (param.minimum !== undefined) {
16
- comments.push(`minimum: ${param.minimum}`);
17
- }
18
- if (param.maximum !== undefined) {
19
- comments.push(`maximum: ${param.maximum}`);
20
- }
21
- if (comments.length > 0) {
22
- return ` /**\n * ${comments.join("\n * ")}\n */`;
23
- }
24
- return "";
25
- }
@@ -1 +0,0 @@
1
- "use strict";
@@ -1,40 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateInterfaceComments = generateInterfaceComments;
4
- exports.generateServiceComments = generateServiceComments;
5
- function generateInterfaceComments(param) {
6
- const comments = [];
7
- if (param.format !== undefined) {
8
- comments.push(`format: ${param.format}`);
9
- }
10
- if (param.minLength !== undefined) {
11
- comments.push(`minLength: ${param.minLength}`);
12
- }
13
- if (param.maxLength !== undefined) {
14
- comments.push(`maxLength: ${param.maxLength}`);
15
- }
16
- if (param.minimum !== undefined) {
17
- comments.push(`minimum: ${param.minimum}`);
18
- }
19
- if (param.maximum !== undefined) {
20
- comments.push(`maximum: ${param.maximum}`);
21
- }
22
- if (comments.length > 0) {
23
- return ` /**\n * ${comments.join("\n * ")}\n */`;
24
- }
25
- return "";
26
- }
27
- function generateServiceComments(summary, responseType, parameters) {
28
- const summarySplited = [];
29
- for (let i = 0; i < summary.length; i += 100) {
30
- summarySplited.push(summary.slice(i, i + 100));
31
- }
32
- const comments = summarySplited;
33
- if (parameters && parameters.length > 0) {
34
- comments.push(`${parameters.map((p) => `\t\t @param ${p.name} : ${p.type}`).join("\n")}`);
35
- }
36
- if (responseType) {
37
- comments.push(`\t\t @returns Observable<${responseType}>`);
38
- }
39
- return `/**\n${comments.map((c) => `\t\t* ${c}\n`).join("")}\n */`;
40
- }
@@ -1,219 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parametersToIProperties = parametersToIProperties;
4
- exports.propertiesToIProperties = propertiesToIProperties;
5
- exports.generateInterfaces = generateInterfaces;
6
- exports.generateWithParameters = generateWithParameters;
7
- exports.computeParametersName = computeParametersName;
8
- exports.generateComponentsSchemas = generateComponentsSchemas;
9
- exports.generateInterfacesFiles = generateInterfacesFiles;
10
- exports.generateContent = generateContent;
11
- const interface_data_store_1 = require("../stores/interface-data-store");
12
- const swagger_store_1 = require("../stores/swagger-store");
13
- const extends_from_types_1 = require("../templates/types/extends-from-types");
14
- const generic_types_1 = require("../templates/types/generic-types");
15
- const build_types_1 = require("../utils/build-types");
16
- const object_utils_1 = require("../utils/object-utils");
17
- const path_utils_1 = require("../utils/path-utils");
18
- const string_utils_1 = require("../utils/string-utils");
19
- const type_guard_1 = require("../utils/type-guard");
20
- const generate_comments_1 = require("./generate-comments");
21
- function parametersToIProperties(parameters) {
22
- const properties = [];
23
- for (const param of parameters) {
24
- if ((0, type_guard_1.isReference)(param)) {
25
- const ref = param.$ref.split("/").pop();
26
- properties.push({
27
- name: (0, string_utils_1.lowerFirst)(ref),
28
- type: ref,
29
- optional: false,
30
- comments: "",
31
- });
32
- continue;
33
- }
34
- if (param.in !== "query")
35
- continue;
36
- const tsType = (0, build_types_1.switchTypeJson)(param.schema);
37
- properties.push({
38
- name: (0, string_utils_1.lowerFirst)(param.name),
39
- type: tsType,
40
- optional: !param.required,
41
- comments: (0, generate_comments_1.generateInterfaceComments)(param.schema),
42
- });
43
- }
44
- return properties;
45
- }
46
- function propertiesToIProperties(properties) {
47
- const interfaceDataProperties = [];
48
- for (const [name, property] of Object.entries(properties)) {
49
- if ((0, type_guard_1.isReference)(property)) {
50
- const ref = property.$ref.split("/").pop();
51
- interfaceDataProperties.push({
52
- name,
53
- type: ref,
54
- optional: false,
55
- comments: "",
56
- });
57
- continue;
58
- }
59
- interfaceDataProperties.push({
60
- name,
61
- type: (0, build_types_1.switchTypeJson)(property),
62
- optional: property.nullable ?? false,
63
- comments: (0, generate_comments_1.generateInterfaceComments)(property),
64
- });
65
- }
66
- return interfaceDataProperties;
67
- }
68
- function generateInterfaces() {
69
- generateComponentsSchemas();
70
- generateWithParameters();
71
- }
72
- function generateWithParameters() {
73
- const paths = swagger_store_1.swaggerStore.getPaths();
74
- const groupedPaths = swagger_store_1.swaggerStore.getPathsGroupedByScope();
75
- if (!paths || !groupedPaths)
76
- return;
77
- const interfacesData = [];
78
- for (const groupedPath of Object.values(groupedPaths)) {
79
- for (const innerPath of groupedPath.paths) {
80
- const pathInfo = paths[innerPath];
81
- if (!pathInfo)
82
- continue;
83
- const methods = (0, object_utils_1.removeFalsyValues)({
84
- get: pathInfo.get,
85
- post: pathInfo.post,
86
- put: pathInfo.put,
87
- delete: pathInfo.delete,
88
- patch: pathInfo.patch,
89
- });
90
- for (const [httpMethod, pathData] of Object.entries(methods)) {
91
- if (!pathData?.parameters)
92
- continue;
93
- const parameters = pathData.parameters;
94
- const properties = parametersToIProperties(parameters);
95
- if (properties.length === 0)
96
- continue;
97
- const interfaceName = computeParametersName(httpMethod, innerPath, groupedPath);
98
- const interData = {
99
- name: interfaceName,
100
- type: "interface",
101
- imports: properties
102
- .filter((p) => !(0, type_guard_1.isNativeType)(p.type))
103
- .map((p) => p.type),
104
- properties,
105
- };
106
- const generic = (0, generic_types_1.isGenericType)(interData);
107
- if (generic)
108
- continue;
109
- const interDataWithExtendsFrom = (0, extends_from_types_1.computeExtendsFromType)(interData);
110
- interfacesData.push(interDataWithExtendsFrom);
111
- }
112
- }
113
- }
114
- interface_data_store_1.interfaceDataStore.addInterfaces(interfacesData);
115
- }
116
- function computeParametersName(method, innerPath, groupedPath) {
117
- const dict = {
118
- get: "",
119
- post: "Create",
120
- put: "Update",
121
- delete: "Delete",
122
- patch: "Patch",
123
- };
124
- const name = dict[method];
125
- const extra = (0, string_utils_1.kebabToPascalCase)((0, path_utils_1.removeVariablesFromPath)((0, path_utils_1.getExtraSegments)(innerPath, (0, path_utils_1.createBaseUrl)(groupedPath.baseSegments)).join("")));
126
- return name + groupedPath.groupName + (0, string_utils_1.upFirst)(extra) + "Params";
127
- }
128
- function generateComponentsSchemas() {
129
- const schemas = swagger_store_1.swaggerStore.getSchemas();
130
- if (!schemas)
131
- return;
132
- const interfaces = [];
133
- for (const [key, value] of Object.entries(schemas)) {
134
- if ((0, type_guard_1.isReference)(value))
135
- continue;
136
- if (!value.properties) {
137
- if (value.enum) {
138
- const interData = {
139
- name: key,
140
- type: "enum",
141
- imports: [],
142
- properties: value.enum.map((e) => {
143
- return {
144
- name: e,
145
- type: e,
146
- optional: false,
147
- comments: "",
148
- };
149
- }),
150
- };
151
- interfaces.push(interData);
152
- }
153
- continue;
154
- }
155
- const properties = propertiesToIProperties(value.properties);
156
- const interData = {
157
- name: key,
158
- type: "interface",
159
- imports: properties
160
- .filter((p) => !(0, type_guard_1.isNativeType)(p.type))
161
- .map((p) => p.type),
162
- properties,
163
- };
164
- const generic = (0, generic_types_1.isGenericType)(interData);
165
- if (generic) {
166
- continue;
167
- }
168
- const interDataWithExtendsFrom = (0, extends_from_types_1.computeExtendsFromType)(interData);
169
- interfaces.push(interDataWithExtendsFrom);
170
- }
171
- interface_data_store_1.interfaceDataStore.addInterfaces(interfaces);
172
- }
173
- function generateInterfacesFiles(locations) {
174
- const interfacesData = [
175
- ...generic_types_1.genericTypesData,
176
- ...extends_from_types_1.extendsFromTypes,
177
- ...Array.from(Object.values(interface_data_store_1.interfaceDataStore.generatedInterfaces)),
178
- ];
179
- const filesContent = [];
180
- for (const [key, value] of Object.entries(interfacesData)) {
181
- const location = [
182
- value.type === "enum" ? "enums" : "dtos",
183
- ...(locations?.[key] ?? []),
184
- ];
185
- const content = generateContent(value, location.length);
186
- const extraName = value.type === "enum" ? "enum" : "dto";
187
- filesContent.push({
188
- location: location,
189
- content,
190
- extension: "ts",
191
- name: (0, string_utils_1.toKebabCase)(value.name) + `.${extraName}`,
192
- });
193
- }
194
- return filesContent;
195
- }
196
- generateContent;
197
- function generateContent(interfaceData, deep = 0) {
198
- const imports = [...interfaceData.imports];
199
- const importsTemplate = imports.length > 0
200
- ? `import { ${imports.join(", ")} } from "${"../".repeat(deep)}models";`
201
- : "";
202
- if (interfaceData.type === "interface") {
203
- const content = `${importsTemplate}\n\nexport interface ${interfaceData.name} ${interfaceData.extendsFrom && interfaceData.extendsFrom.length > 0 ? `extends ${interfaceData.extendsFrom.join(", ")}` : ""} {
204
- ${interfaceData.properties
205
- .map((p) => `${p.comments}\n\t${(0, string_utils_1.lowerFirst)(p.name)}${p.optional ? "?" : ""}: ${p.type};`)
206
- .join("\n")}
207
- }`;
208
- return content;
209
- }
210
- if (interfaceData.type === "enum") {
211
- const content = `export enum ${interfaceData.name} {
212
- ${interfaceData.properties
213
- .map((p) => `${p.comments}\n\t${p.name} = '${p.type}',`)
214
- .join("\n")}
215
- }`;
216
- return content;
217
- }
218
- return "";
219
- }
@@ -1,302 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateServices = generateServices;
4
- exports.generateServiceFiles = generateServiceFiles;
5
- exports.buildMethods = buildMethods;
6
- exports.buildMethod = buildMethod;
7
- exports.computeName = computeName;
8
- const services_store_1 = require("../stores/services-store");
9
- const swagger_store_1 = require("../stores/swagger-store");
10
- const angular_template_1 = require("../templates/services/angular-template");
11
- const build_types_1 = require("../utils/build-types");
12
- const path_utils_1 = require("../utils/path-utils");
13
- const string_utils_1 = require("../utils/string-utils");
14
- const type_guard_1 = require("../utils/type-guard");
15
- const generate_interface_1 = require("./generate-interface");
16
- const generate_comments_1 = require("./generate-comments");
17
- /**
18
- * Pick the paths grouped by scope and generate services for them.
19
- * Each group will generate one service data.
20
- * Each service data will contain the methods for the paths.
21
- *
22
- * The name will be the group name concatenated with Service
23
- *
24
- * The imports will be the types used in the methods. Including
25
- * the response type and the parameters types.
26
- *
27
- * The base url will be the base url of the group compound by the
28
- * base segments of the group.
29
- *
30
- * Each method will be generated based on a path
31
- *
32
- * The method name will be computed based on the path.
33
- * It has to follow some stantardized rules.
34
- *
35
- * The method parameters will be computed based on the path parameters
36
- * The method path will be computed based on the path, but it will be
37
- * computed as `${this.baseUrl}/something/else/{id}`
38
- * The method response type will be computed based on the path response
39
- * The method parameters will be computed based on the path parameters
40
- * The method parameter name will be computed based on the path parameter name if
41
- * the parameters has the property "in" set to "path". If the parameter has the property
42
- * "in" set to "query", it will be computed as "parameters" and query parameters should be grouped
43
- * in the same object. Check computeParametersName() method in generate-interface.ts to
44
- * understand how the name is computed.
45
- *
46
- * The method parameter in property will be computed based on the path parameter "in" property
47
- * The method parameter type will be computed based on the path parameter type property.
48
- * Check computeParametersName() method in generate-interface.ts to
49
- * understand how the name is computed.
50
- * The method parameter required will be computed based on the path parameter required property
51
- * @returns ServiceData[]
52
- */
53
- function generateServices() {
54
- const servicesData = [];
55
- const groupedPaths = swagger_store_1.swaggerStore.getPathsGroupedByScope();
56
- const paths = swagger_store_1.swaggerStore.getPaths();
57
- if (!groupedPaths || !paths)
58
- return;
59
- for (const [key, value] of Object.entries(groupedPaths)) {
60
- const methods = buildMethods(value);
61
- const importsSet = new Set();
62
- methods.forEach((method) => {
63
- const allTypes = [
64
- method.responseType,
65
- ...method.parameters.map((p) => p.type),
66
- ];
67
- allTypes.forEach((t) => {
68
- const identifiers = t.match(/[a-zA-Z_][a-zA-Z0-9_]*/g) || [];
69
- identifiers.forEach((id) => {
70
- if (!(0, type_guard_1.isNativeType)(id) && id !== "void") {
71
- importsSet.add(id);
72
- }
73
- });
74
- });
75
- });
76
- const serviceData = {
77
- name: key + "Service",
78
- imports: Array.from(importsSet),
79
- baseUrl: value.baseUrl,
80
- methods: methods,
81
- };
82
- servicesData.push(serviceData);
83
- }
84
- services_store_1.serviceStore.addServices(servicesData);
85
- }
86
- function generateServiceFiles(locations) {
87
- const services = Object.values(services_store_1.serviceStore.services);
88
- const filesContent = [];
89
- for (const service of services) {
90
- const methodsString = service.methods
91
- .map((method) => generateMethodString(method))
92
- .join("\n\n");
93
- const templateParams = {
94
- name: service.name.replace("Service", ""),
95
- baseUrl: service.baseUrl,
96
- methods: methodsString,
97
- imports: service.imports.join(", "),
98
- hasHttpParamsHandler: service.methods.some((m) => m.parameters.some((p) => p.in === "query")),
99
- };
100
- // If imports are empty, we might want to clean up the template later,
101
- // but for now we follow the existing template structure.
102
- filesContent.push({
103
- location: ["services", ...(locations?.[service.name] ?? [])],
104
- name: (0, string_utils_1.toKebabCase)(service.name.replace("Service", "")) + ".service",
105
- content: (0, angular_template_1.angularServiceTemplate)(templateParams),
106
- extension: "ts",
107
- });
108
- }
109
- return filesContent;
110
- }
111
- function generateMethodString(method) {
112
- const paramsSignature = method.parameters
113
- .map((p) => `${p.name}${p.required ? "" : "?"}: ${p.type}`)
114
- .join(", ");
115
- const httpMethod = method.method.toLowerCase();
116
- const responseType = method.responseType;
117
- // Convert {id} to ${id} in path
118
- let path = method.path.replace(/{([^}]+)}/g, "${$1}");
119
- if (!path.startsWith("`")) {
120
- // Remove the first $
121
- path = `\`${path.slice(1)}\``;
122
- }
123
- let body = "";
124
- const queryParam = method.parameters.find((p) => p.in === "query");
125
- if (queryParam) {
126
- body += ` const params = HttpHelper.toHttpParams(${queryParam.name} ?? {});\n`;
127
- }
128
- const options = [];
129
- if (queryParam)
130
- options.push("params");
131
- if (responseType === "Blob" || responseType === "File") {
132
- options.push("responseType: 'blob'");
133
- }
134
- if (httpMethod === "delete" &&
135
- method.parameters.some((p) => p.in === "body")) {
136
- options.push("body: " + method.parameters.find((p) => p.in === "body")?.name);
137
- }
138
- const optionsString = options.length > 0 ? `, { ${options.join(", ")} }` : "";
139
- if (httpMethod === "get" || httpMethod === "delete") {
140
- body += ` return this.http.${httpMethod}<${responseType}>(${path}${optionsString});`;
141
- }
142
- else {
143
- // post, put, patch
144
- const dataParam = method.parameters.find((p) => p.in === "body")?.name || "null";
145
- body += ` return this.http.${httpMethod}<${responseType}>(${path}, ${dataParam}${optionsString});`;
146
- }
147
- return `${method.comments}\n public ${method.name}(${paramsSignature}): Observable<${responseType}> {
148
- ${body}
149
- }`;
150
- }
151
- function buildMethods(groupedPath) {
152
- const methods = [];
153
- const pathData = swagger_store_1.swaggerStore.getPaths();
154
- const usedNames = [];
155
- for (const path of groupedPath.paths) {
156
- if (!pathData || !pathData[path])
157
- continue;
158
- for (const [httpMethod, pathInfo] of Object.entries(pathData[path])) {
159
- if (typeof pathInfo !== "object")
160
- continue;
161
- const method = buildMethod(path, httpMethod, pathInfo, groupedPath, usedNames);
162
- methods.push(method);
163
- usedNames.push(method.name);
164
- }
165
- }
166
- return methods;
167
- }
168
- function buildMethod(path, httpMethod, pathInfo, groupedPath, usedNames) {
169
- const baseUrl = groupedPath.baseUrl;
170
- const extraSegments = (0, path_utils_1.getExtraSegments)(path, baseUrl).join("/");
171
- const methodPath = extraSegments
172
- ? `\${this.baseUrl}/${extraSegments}`
173
- : `\${this.baseUrl}`;
174
- const responseType = getMethodResponseType(pathInfo);
175
- const parameters = getMethodParameters(path, httpMethod, pathInfo, groupedPath);
176
- const method = {
177
- name: computeName(path, httpMethod, usedNames),
178
- path: methodPath,
179
- method: httpMethod,
180
- parameters: parameters,
181
- responseType: responseType,
182
- comments: (0, generate_comments_1.generateServiceComments)(pathInfo.summary || "", responseType, parameters),
183
- };
184
- return method;
185
- }
186
- function getMethodResponseType(pathInfo) {
187
- const responses = pathInfo.responses;
188
- if (!responses)
189
- return "void";
190
- const successResponse = responses["200"] || responses["201"] || responses["default"];
191
- if (!successResponse)
192
- return "void";
193
- if ((0, type_guard_1.isReference)(successResponse)) {
194
- return "any";
195
- }
196
- const content = successResponse.content;
197
- if (!content || !content["application/json"])
198
- return "void";
199
- const schema = content["application/json"].schema;
200
- if (!schema)
201
- return "void";
202
- return (0, build_types_1.switchTypeJson)(schema);
203
- }
204
- function getMethodParameters(path, httpMethod, pathInfo, groupedPath) {
205
- const parameters = [];
206
- const openApiParameters = pathInfo.parameters || [];
207
- // Path parameters
208
- openApiParameters.forEach((param) => {
209
- if ((0, type_guard_1.isReference)(param))
210
- return;
211
- if (param.in === "path") {
212
- parameters.push({
213
- name: param.name,
214
- in: "path",
215
- required: param.required || false,
216
- type: (0, build_types_1.switchTypeJson)(param.schema),
217
- });
218
- }
219
- });
220
- // Query parameters (grouped)
221
- const queryParams = openApiParameters.filter((param) => !(0, type_guard_1.isReference)(param) && param.in === "query");
222
- if (queryParams.length > 0) {
223
- parameters.push({
224
- name: "parameters",
225
- in: "query",
226
- required: queryParams.some((p) => p.required),
227
- type: (0, generate_interface_1.computeParametersName)(httpMethod, path, groupedPath),
228
- });
229
- }
230
- // Request Body
231
- if (pathInfo.requestBody) {
232
- let bodyType = "any";
233
- if ((0, type_guard_1.isReference)(pathInfo.requestBody)) {
234
- bodyType = pathInfo.requestBody.$ref.split("/").pop();
235
- }
236
- else {
237
- const content = pathInfo.requestBody.content;
238
- if (content && content["application/json"]) {
239
- const schema = content["application/json"].schema;
240
- if (schema) {
241
- bodyType = (0, build_types_1.switchTypeJson)(schema);
242
- }
243
- }
244
- }
245
- parameters.push({
246
- name: "data",
247
- in: "body",
248
- required: true,
249
- type: bodyType,
250
- });
251
- }
252
- return parameters;
253
- }
254
- function computeName(path, httpMethod, usedNames) {
255
- const dict = {
256
- get: "get",
257
- post: "create",
258
- put: "update",
259
- delete: "delete",
260
- patch: "patch",
261
- };
262
- const parts = path.split("/").filter((p) => p);
263
- const endsInVariable = (0, path_utils_1.isVariable)(parts[parts.length - 1]);
264
- if (endsInVariable) {
265
- const name = dict[httpMethod];
266
- if (usedNames.includes(name)) {
267
- return name + (0, string_utils_1.kebabToPascalCase)(parts[parts.length - 2]);
268
- }
269
- return name;
270
- }
271
- if (httpMethod === "get" || httpMethod === "put" || httpMethod === "patch") {
272
- let name = dict[httpMethod] + "All";
273
- if (!usedNames.includes(name)) {
274
- return name;
275
- }
276
- name = dict[httpMethod] + (0, string_utils_1.kebabToPascalCase)(parts[parts.length - 1]);
277
- if (!usedNames.includes(name)) {
278
- return name;
279
- }
280
- return dict[httpMethod] + "By" + (0, string_utils_1.kebabToPascalCase)(parts[parts.length - 1]);
281
- }
282
- if (httpMethod === "post") {
283
- let name = dict[httpMethod];
284
- if (!usedNames.includes(name)) {
285
- return name;
286
- }
287
- name = (0, string_utils_1.kebabToPascalCase)(parts[parts.length - 1]);
288
- if (!usedNames.includes(name)) {
289
- return name;
290
- }
291
- name = "createBy" + (0, string_utils_1.kebabToPascalCase)(parts[parts.length - 1]);
292
- if (!usedNames.includes(name)) {
293
- return name;
294
- }
295
- return "create" + (0, string_utils_1.kebabToPascalCase)(parts[parts.length - 1]);
296
- }
297
- const name = dict[httpMethod];
298
- if (usedNames.includes(name)) {
299
- return name + (0, string_utils_1.kebabToPascalCase)(parts[parts.length - 1]);
300
- }
301
- return name + "By" + (0, string_utils_1.kebabToPascalCase)(parts[parts.length - 1]);
302
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });