UNPKG

22.7 kBTypeScriptView Raw
1import CliOption from './CliOption';
2export default class DefaultCodegen {
3 static addHasMore(objs: any): any;
4 /**
5 * Underscore the given word.
6 * Copied from Twitter elephant bird
7 * https://github.com/twitter/elephant-bird/blob/master/core/src/main/java/com/twitter/elephantbird/util/Strings.java
8 *
9 * @param word The word
10 * @return The underscored version of the word
11 */
12 static underscore(word: any): any;
13 /**
14 * Camelize name (parameter, property, method, etc)
15 *
16 * @param word string to be camelize
17 * @param lowercaseFirstLetter lower case for first letter if set to true
18 * @return camelized string
19 */
20 static camelize(word: any, lowercaseFirstLetter?: boolean): any;
21 /**
22 * Generate the next name for the given name, i.e. append "2" to the base name if not ending with a number,
23 * otherwise increase the number by 1. For example:
24 * status => status2
25 * status2 => status3
26 * myName100 => myName101
27 *
28 * @param name The base name
29 * @return The next name for the base name
30 */
31 static generateNextName(name: any): any;
32 __fileSuffix: any;
33 __templateDir: any;
34 __embeddedTemplateDir: any;
35 __outputFolder: string;
36 __languageSpecificPrimitives: import("./java/FakeHashSet").FakeHashSet;
37 __modelPackage: string;
38 __apiPackage: string;
39 modelNamePrefix: string;
40 modelNameSuffix: string;
41 __testPackage: string;
42 __apiTemplateFiles: import("./java/fakeMap").FakeHashMap;
43 __apiDataTemplateFile: import("./java/fakeMap").FakeHashMap;
44 __modelTemplateFiles: import("./java/fakeMap").FakeHashMap;
45 __apiTestTemplateFiles: import("./java/fakeMap").FakeHashMap;
46 __modelTestTemplateFiles: import("./java/fakeMap").FakeHashMap;
47 __apiDocTemplateFiles: import("./java/fakeMap").FakeHashMap;
48 __modelDocTemplateFiles: import("./java/fakeMap").FakeHashMap;
49 commonTemplateDir: string;
50 __additionalProperties: import("./java/fakeMap").FakeHashMap;
51 __vendorExtensions: import("./java/fakeMap").FakeHashMap;
52 __supportingFiles: any[];
53 __cliOptions: any[];
54 __supportedLibraries: import("./java/fakeMap").FakeHashMap;
55 sortParamsByRequiredFlag: boolean;
56 ensureUniqueParams: boolean;
57 specialCharReplacements: import("./java/fakeMap").FakeHashMap;
58 skipOverwrite: boolean;
59 supportsInheritance: boolean;
60 __defaultIncludes: import("./java/FakeHashSet").FakeHashSet;
61 __typeMapping: import("./java/fakeMap").FakeHashMap;
62 __instantiationTypes: import("./java/fakeMap").FakeHashMap;
63 __reservedWords: import("./java/FakeHashSet").FakeHashSet;
64 __importMapping: import("./java/fakeMap").FakeHashMap;
65 containerType: any;
66 library: any;
67 gitUserId: any;
68 gitRepoId: any;
69 releaseNote: any;
70 httpUserAgent: any;
71 /**
72 * Default constructor.
73 * This method will map between Swagger type and language-specified type, as well as mapping
74 * between Swagger type and the corresponding import statement for the language. This will
75 * also add some language specified CLI options, if any.
76 *
77 *
78 * returns string presentation of the example path (it's a constructor)
79 */
80 constructor();
81 initalizeCliOptions(): void;
82 cliOptions(): any[];
83 processOpts(): void;
84 addLicenseFile(): boolean;
85 addSwaggerIgnoreFile(): boolean;
86 postProcessAllModels(objs: any): any;
87 postProcessModels(objs: any): any;
88 /**
89 * post process enum defined in model's properties
90 *
91 * @param objs Map of models
92 * @return maps of models with better enum support
93 */
94 postProcessModelsEnum(objs: any): any;
95 /**
96 * Returns the common prefix of variables for enum naming
97 *
98 * @param vars List of variable names
99 * @return the common prefix for naming
100 */
101 findCommonPrefixOfVars(listStr: any): any;
102 /**
103 * Return the enum default value in the language specifed format
104 *
105 * @param value enum variable name
106 * @param datatype data type
107 * @return the default value for the enum
108 */
109 toEnumDefaultValue(value: any, datatype: any): string;
110 /**
111 * Return the enum value in the language specifed format
112 * e.g. status becomes "status"
113 *
114 * @param value enum variable name
115 * @param datatype data type
116 * @return the sanitized value for enum
117 */
118 toEnumValue(value: any, datatype: any): any;
119 /**
120 * Return the sanitized variable name for enum
121 *
122 * @param value enum variable name
123 * @param datatype data type
124 * @return the sanitized variable name for enum
125 */
126 toEnumVarName(value: any, datatype: any): any;
127 postProcessOperations(objs: any): any;
128 postProcessSupportingFileData(objs: any): any;
129 postProcessModelProperty(model: any, property: any): void;
130 postProcessParameter(parameter: any): void;
131 preprocessSwagger(swagger: any): void;
132 processSwagger(swagger: any): void;
133 escapeText(input: any): any;
134 /**
135 * override with any special text escaping logic to handle unsafe
136 * characters so as to avoid code injection
137 * @param input String to be cleaned up
138 * @return string with unsafe characters removed or escaped
139 */
140 escapeUnsafeCharacters(input: any): any;
141 /**
142 * Escape single and/or double quote to avoid code injection
143 * @param input String to be cleaned up
144 * @return string with quotation mark removed or escaped
145 */
146 escapeQuotationMark(input: any): any;
147 defaultIncludes(): import("./java/FakeHashSet").FakeHashSet;
148 typeMapping(): import("./java/fakeMap").FakeHashMap;
149 instantiationTypes(): import("./java/fakeMap").FakeHashMap;
150 reservedWords(): import("./java/FakeHashSet").FakeHashSet;
151 languageSpecificPrimitives(): import("./java/FakeHashSet").FakeHashSet;
152 importMapping(): import("./java/fakeMap").FakeHashMap;
153 testPackage(): string;
154 modelPackage(): string;
155 apiPackage(): string;
156 fileSuffix(): any;
157 templateDir(): any;
158 embeddedTemplateDir(): any;
159 getCommonTemplateDir(): string;
160 etCommonTemplateDir(commonTemplateDir: any): void;
161 apiDocTemplateFiles(): import("./java/fakeMap").FakeHashMap;
162 modelDocTemplateFiles(): import("./java/fakeMap").FakeHashMap;
163 apiTestTemplateFiles(): import("./java/fakeMap").FakeHashMap;
164 modelTestTemplateFiles(): import("./java/fakeMap").FakeHashMap;
165 apiTemplateFiles(): import("./java/fakeMap").FakeHashMap;
166 apiDataTemplateFile(): import("./java/fakeMap").FakeHashMap;
167 modelTemplateFiles(): import("./java/fakeMap").FakeHashMap;
168 apiFileFolder(): string;
169 /**
170 * Checks to see if an API file needs to be generated for this template, helps to apply some logic when you have more than one api file which is condition based.
171 * @param templateName
172 * @param operation
173 * @returns {boolean}
174 */
175 shouldGenerateApiFor(templateName: any, operation: any): boolean;
176 modelFileFolder(): string;
177 apiTestFileFolder(): string;
178 modelTestFileFolder(): string;
179 apiDocFileFolder(): string;
180 modelDocFileFolder(): string;
181 additionalProperties(): import("./java/fakeMap").FakeHashMap;
182 vendorExtensions(): import("./java/fakeMap").FakeHashMap;
183 supportingFiles(): any[];
184 outputFolder(): string;
185 setOutputDir(dir: any): void;
186 getOutputDir(): string;
187 setTemplateDir(templateDir: any): void;
188 setModelPackage(modelPackage: any): void;
189 setModelNamePrefix(modelNamePrefix: any): void;
190 setModelNameSuffix(modelNameSuffix: any): void;
191 setApiPackage(apiPackage: any): void;
192 setSortParamsByRequiredFlag(sortParamsByRequiredFlag: any): void;
193 setEnsureUniqueParams(ensureUniqueParams: any): void;
194 /**
195 * Return the regular expression/JSON schema pattern (http://json-schema.org/latest/json-schema-validation.html#anchor33)
196 *
197 * @param pattern the pattern (regular expression)
198 * @return properly-escaped pattern
199 */
200 toRegularExpression(pattern: any): any;
201 /**
202 * Return the file name of the Api Test
203 *
204 * @param name the file name of the Api
205 * @return the file name of the Api
206 */
207 toApiFilename(name: any): string;
208 /**
209 * Return the file name of the Api Documentation
210 *
211 * @param name the file name of the Api
212 * @return the file name of the Api
213 */
214 toApiDocFilename(name: any): string;
215 /**
216 * Return the file name of the Api Test
217 *
218 * @param name the file name of the Api
219 * @return the file name of the Api
220 */
221 toApiTestFilename(name: any): string;
222 /**
223 * Return the variable name in the Api
224 *
225 * @param name the varible name of the Api
226 * @return the snake-cased variable name
227 */
228 toApiVarName(name: any): any;
229 /**
230 * Return the capitalized file name of the model
231 *
232 * @param name the model name
233 * @return the file name of the model
234 */
235 toModelFilename(name: any): any;
236 /**
237 * Return the capitalized file name of the model test
238 *
239 * @param name the model name
240 * @return the file name of the model
241 */
242 toModelTestFilename(name: any): string;
243 /**
244 * Return the capitalized file name of the model documentation
245 *
246 * @param name the model name
247 * @return the file name of the model
248 */
249 toModelDocFilename(name: any): any;
250 /**
251 * Return the operation ID (method name)
252 *
253 * @param operationId operation ID
254 * @return the sanitized method name
255 */
256 toOperationId(operationId: any): any;
257 /**
258 * Return the variable name by removing invalid characters and proper escaping if
259 * it's a reserved word.
260 *
261 * @param name the variable name
262 * @return the sanitized variable name
263 */
264 toVarName(name: any): any;
265 /**
266 * Return the parameter name by removing invalid characters and proper escaping if
267 * it's a reserved word.
268 *
269 * @param name Codegen property object
270 * @return the sanitized parameter name
271 */
272 toParamName(name: any): any;
273 /**
274 * Return the Enum name (e.g. StatusEnum given 'status')
275 *
276 * @param property Codegen property
277 * @return the Enum name
278 */
279 toEnumName(property: any): string;
280 /**
281 * Return the escaped name of the reserved word
282 *
283 * @param name the name to be escaped
284 * @return the escaped reserved word
285 *
286 * throws Runtime exception as reserved word is not allowed (default behavior)
287 */
288 escapeReservedWord(name: any): void;
289 /**
290 * Return the fully-qualified "Model" name for import
291 *
292 * @param name the name of the "Model"
293 * @return the fully-qualified "Model" name for import
294 */
295 toModelImport(name: any): any;
296 /**
297 * Return the fully-qualified "Api" name for import
298 *
299 * @param name the name of the "Api"
300 * @return the fully-qualified "Api" name for import
301 */
302 toApiImport(name: any): string;
303 /**
304 * Initalize special character mapping
305 */
306 initalizeSpecialCharacterMapping(): void;
307 /**
308 * Return the symbol name of a symbol
309 *
310 * @param input Symbol (e.g. $)
311 * @return Symbol name (e.g. Dollar)
312 */
313 getSymbolName(input: any): any;
314 /**
315 * Return the instantiation type of the property, especially for map and array
316 *
317 * @param p Swagger property object
318 * @return string presentation of the instantiation type of the property
319 */
320 toInstantiationType(p: any): string | null;
321 /**
322 * Return the example value of the parameter.
323 *
324 * @param p Swagger property object
325 */
326 setParameterExampleValue(p: any): void;
327 /**
328 * Return the example value of the property
329 *
330 * @param p Swagger property object
331 * @return string presentation of the example value of the property
332 */
333 toExampleValue(p: any): any;
334 /**
335 * Return the default value of the property
336 *
337 * @param p Swagger property object
338 * @return string presentation of the default value of the property
339 */
340 toDefaultValue(p: any): any;
341 /**
342 * Return the property initialized from a data object
343 * Useful for initialization with a plain object in JavaScript
344 *
345 * @param name Name of the property object
346 * @param p Swagger property object
347 * @return string presentation of the default value of the property
348 */
349 toDefaultValueWithParam(name: any, p: any): string;
350 /**
351 * returns the swagger type for the property
352 * @param p Swagger property object
353 * @return string presentation of the type
354 */
355 getSwaggerType(p: any): any;
356 /**
357 * Return the snake-case of the string
358 *
359 * @param name string to be snake-cased
360 * @return snake-cased string
361 */
362 snakeCase(name: any): any;
363 /**
364 * Capitalize the string
365 *
366 * @param name string to be capitalized
367 * @return capitalized string
368 */
369 initialCaps(name: any): any;
370 /**
371 * Output the type declaration of a given name
372 *
373 * @param name name
374 * @return a string presentation of the type
375 */
376 getTypeDeclaration(name: any): any;
377 /**
378 * Output the API (class) name (capitalized) ending with "Api"
379 * Return DefaultApi if name is empty
380 *
381 * @param name the name of the Api
382 * @return capitalized Api name ending with "Api"
383 */
384 toApiName(name: any): string;
385 /**
386 * Output the proper model name (capitalized)
387 *
388 * @param name the name of the model
389 * @return capitalized model name
390 */
391 toModelName(name: any): any;
392 /**
393 * Convert Swagger Model object to Codegen Model object
394 *
395 * @param name the name of the model
396 * @param model Swagger Model object
397 * @param allDefinitions a map of all Swagger models from the spec
398 * @return Codegen Model object
399 */
400 fromModel(name: any, model: any, allDefinitions?: null): any;
401 addAdditionPropertiesToCodeGenModel(codegenModel: any, swaggerModel: any): void;
402 addProperties(properties: any, required: any, model: any, allDefinitions: any): void;
403 /**
404 * Camelize the method name of the getter and setter
405 *
406 * @param name string to be camelized
407 * @return Camelized string
408 */
409 getterAndSetterCapitalize(name: any): any;
410 /**
411 * Convert Swagger Property object to Codegen Property object
412 *
413 * @param name name of the property
414 * @param p Swagger property object
415 * @return Codegen Property object
416 */
417 fromProperty(name: any, p: any): any;
418 /**
419 * Update property for array(list) container
420 * @param property Codegen property
421 * @param innerProperty Codegen inner property of map or list
422 */
423 updatePropertyForArray(property: any, innerProperty: any): void;
424 /**
425 * Update property for map container
426 * @param property Codegen property
427 * @param innerProperty Codegen inner property of map or list
428 */
429 updatePropertyForMap(property: any, innerProperty: any): void;
430 /**
431 * Update property for map container
432 * @param property Codegen property
433 * @return True if the inner most type is enum
434 */
435 isPropertyInnerMostEnum(property: any): any;
436 getInnerEnumAllowableValues(property: any): any;
437 /**
438 * Update datatypeWithEnum for array container
439 * @param property Codegen property
440 */
441 updateDataTypeWithEnumForArray(property: any): void;
442 /**
443 * Update datatypeWithEnum for map container
444 * @param property Codegen property
445 */
446 updateDataTypeWithEnumForMap(property: any): void;
447 setNonArrayMapProperty(property: any, type: any): void;
448 /**
449 * Override with any special handling of response codes
450 * @param responses Swagger Operation's responses
451 * @return default method response or <tt>null</tt> if not found
452 */
453 findMethodResponse(responses: any): any;
454 /**
455 * Convert Swagger Operation object to Codegen Operation object
456 *
457 * @param p the path of the operation
458 * @param httpMethod HTTP method
459 * @param operation Swagger operation object
460 * @param definitions a map of Swagger models
461 * @param swagger a Swagger object representing the spec
462 * @return Codegen Operation object
463 */
464 fromOperation(p: any, httpMethod: any, operation: any, definitions: any, swagger?: any): any;
465 /**
466 * Convert Swagger Response object to Codegen Response object
467 *
468 * @param responseCode HTTP response code
469 * @param response Swagger Response object
470 * @return Codegen Response object
471 */
472 fromResponse(responseCode: any, response: any): any;
473 /**
474 * Convert Swagger Parameter object to Codegen Parameter object
475 *
476 * @param param Swagger parameter object
477 * @param imports set of imports for library/package/module
478 * @return Codegen Parameter object
479 */
480 fromParameter(param: any, imports: any): any;
481 isDataTypeBinary(dataType: any): any;
482 /**
483 * Convert map of Swagger SecuritySchemeDefinition objects to a list of Codegen Security objects
484 *
485 * @param schemes a map of Swagger SecuritySchemeDefinition object
486 * @return a list of Codegen Security objects
487 */
488 fromSecurity(schemes: any): any[] | readonly never[];
489 setReservedWordsLowerCase(words: any): void;
490 isReservedWord(word: any): boolean;
491 /**
492 * Get operationId from the operation object, and if it's blank, generate a new one from the given parameters.
493 *
494 * @param operation the operation object
495 * @param p the path of the operation
496 * @param httpMethod the HTTP method of the operation
497 * @return the (generated) operationId
498 */
499 getOrGenerateOperationId(operation: any, p: any, httpMethod: any): any;
500 /**
501 * Check the type to see if it needs import the library/module/package
502 *
503 * @param type name of the type
504 * @return true if the library/module/package of the corresponding type needs to be imported
505 */
506 needToImport(type: any): boolean;
507 toExamples(examples: any): any[] | null;
508 addHeaders(response: any, target: any): void;
509 /**
510 * Add operation to group
511 *
512 * @param tag name of the tag
513 * @param resourcePath path of the resource
514 * @param operation Swagger Operation object
515 * @param co Codegen Operation object
516 * @param operations map of Codegen operations
517 */
518 addOperationToGroup(tag: any, resourcePath: any, operation: any, co: any, operations: any): void;
519 addParentContainer(m: any, name: any, property: any): void;
520 /**
521 * Dashize the given word.
522 *
523 * @param word The word
524 * @return The dashized version of the word, e.g. "my-name"
525 */
526 dashize(word: any): any;
527 addImport(m: any, type: any): void;
528 addVars(m: any, properties: any, required: any, allProperties?: any, allRequired?: any): any;
529 _addVars(m: any, vars: any, properties: any, mandatory: any): void;
530 /**
531 * Remove characters that is not good to be included in method name from the input and camelize it
532 *
533 * @param name string to be camelize
534 * @param nonNameElementPattern a regex pattern of the characters that is not good to be included in name
535 * @return camelized string
536 */
537 removeNonNameElementToCamelCase(name: any, nonNameElementPattern?: string): any;
538 apiFilename(templateName: any, tag: any): string;
539 apiDataFilename(templateName: any, tag: any): string;
540 /**
541 * Return the full path and API documentation file
542 *
543 * @param templateName template name
544 * @param tag tag
545 *
546 * @return the API documentation file name with full path
547 */
548 apiDocFilename(templateName: any, tag: any): string;
549 /**
550 * Return the full path and API test file
551 *
552 * @param templateName template name
553 * @param tag tag
554 *
555 * @return the API test file name with full path
556 */
557 apiTestFilename(templateName: any, tag: any): string;
558 shouldOverwrite(filename: any): boolean;
559 isSkipOverwrite(): boolean;
560 setSkipOverwrite(skipOverwrite: any): void;
561 /**
562 * All library templates supported.
563 * (key: library name, value: library description)
564 * @return the supported libraries
565 */
566 supportedLibraries(): import("./java/fakeMap").FakeHashMap;
567 /**
568 * Set library template (sub-template).
569 *
570 * @param library Library template
571 */
572 setLibrary(library: any): void;
573 /**
574 * Library template (sub-template).
575 *
576 * @return Library template
577 */
578 getLibrary(): any;
579 /**
580 * Set Git user ID.
581 *
582 * @param gitUserId Git user ID
583 */
584 setGitUserId(gitUserId: any): void;
585 /**
586 * Git user ID
587 *
588 * @return Git user ID
589 */
590 getGitUserId(): any;
591 /**
592 * Set Git repo ID.
593 *
594 * @param gitRepoId Git repo ID
595 */
596 setGitRepoId(gitRepoId: any): void;
597 /**
598 * Git repo ID
599 *
600 * @return Git repo ID
601 */
602 getGitRepoId(): any;
603 /**
604 * Set release note.
605 *
606 * @param releaseNote Release note
607 */
608 setReleaseNote(releaseNote: any): void;
609 /**
610 * Release note
611 *
612 * @return Release note
613 */
614 getReleaseNote(): any;
615 /**
616 * Set HTTP user agent.
617 *
618 * @param httpUserAgent HTTP user agent
619 */
620 setHttpUserAgent(httpUserAgent: any): void;
621 /**
622 * HTTP user agent
623 *
624 * @return HTTP user agent
625 */
626 getHttpUserAgent(): any;
627 buildLibraryCliOption(supportedLibraries: any): CliOption;
628 /**
629 * Sanitize name (parameter, property, method, etc)
630 *
631 * @param name string to be sanitize
632 * @return sanitized string
633 */
634 sanitizeName(name: any): any;
635 /**
636 * Sanitize tag
637 *
638 * @param tag Tag
639 * @return Sanitized tag
640 */
641 sanitizeTag(tag: any): string;
642 /**
643 * Only write if the file doesn't exist
644 *
645 * @param outputFolder Output folder
646 * @param supportingFile Supporting file
647 */
648 writeOptional(outputFolder: any, supportingFile: any): void;
649 /**
650 * Set CodegenParameter boolean flag using CodegenProperty.
651 *
652 * @param parameter Codegen Parameter
653 * @param property Codegen property
654 */
655 setParameterBooleanFlagWithCodegenProperty(parameter: any, property: any): void;
656 /**
657 * Update codegen property's enum by adding "enumVars" (with name and value)
658 *
659 * @param var list of CodegenProperty
660 */
661 updateCodegenPropertyEnum(__var: any): void;
662}