public class JavascriptClientCodegen extends DefaultCodegen implements CodegenConfig
| Modifier and Type | Field and Description |
|---|---|
protected String |
apiDocPath |
protected String |
apiTestPath |
static String |
EMIT_JS_DOC |
static String |
EMIT_MODEL_METHODS |
protected boolean |
emitJSDoc |
protected boolean |
emitModelMethods |
protected String |
invokerPackage |
protected String |
licenseName |
protected String |
localVariablePrefix |
protected String |
modelDocPath |
protected String |
modelTestPath |
static String |
MODULE_NAME |
protected String |
moduleName |
static String |
PROJECT_DESCRIPTION |
static String |
PROJECT_NAME |
static String |
PROJECT_VERSION |
protected String |
projectDescription |
protected String |
projectName |
protected String |
projectVersion |
protected String |
sourceFolder |
static String |
USE_ES6 |
static String |
USE_INHERITANCE |
static String |
USE_PROMISES |
protected boolean |
useES6 |
protected boolean |
usePromises |
additionalProperties, allowUnicodeIdentifiers, apiDocTemplateFiles, apiPackage, apiTemplateFiles, apiTestTemplateFiles, cliOptions, commonTemplateDir, DEFAULT_CONTENT_TYPE, defaultIncludes, embeddedTemplateDir, ensureUniqueParams, fileSuffix, gitRepoId, gitUserId, hideGenerationTimestamp, httpUserAgent, ignoreFilePathOverride, importMapping, inputSpec, instantiationTypes, languageSpecificPrimitives, library, modelDocTemplateFiles, modelNamePrefix, modelNameSuffix, modelPackage, modelTemplateFiles, modelTestTemplateFiles, outputFolder, releaseNote, removeOperationIdPrefix, REQUEST_BODY_NAME, reservedWords, reservedWordsMappings, skipOverwrite, sortParamsByRequiredFlag, specialCharReplacements, supportedLibraries, supportingFiles, supportsInheritance, supportsMixins, templateDir, testPackage, typeAliases, typeMapping, vendorExtensions| Constructor and Description |
|---|
JavascriptClientCodegen() |
| Modifier and Type | Method and Description |
|---|---|
String |
apiDocFileFolder() |
String |
apiFileFolder() |
String |
apiTestFileFolder() |
String |
escapeQuotationMark(String input)
Escape single and/or double quote to avoid code injection
|
String |
escapeReservedWord(String name)
Return the escaped name of the reserved word
|
String |
escapeUnsafeCharacters(String input)
override with any special text escaping logic to handle unsafe
characters so as to avoid code injection
|
CodegenModel |
fromModel(String name,
io.swagger.v3.oas.models.media.Schema schema,
Map<String,io.swagger.v3.oas.models.media.Schema> allSchemas)
Convert Swagger Model object to Codegen Model object
|
CodegenOperation |
fromOperation(String path,
String httpMethod,
io.swagger.v3.oas.models.Operation operation,
Map<String,io.swagger.v3.oas.models.media.Schema> schemas,
io.swagger.v3.oas.models.OpenAPI openAPI)
Convert Swagger Operation object to Codegen Operation object
|
String |
getHelp() |
String |
getName() |
String |
getSchemaType(io.swagger.v3.oas.models.media.Schema propertySchema)
returns the swagger type for the property
|
CodegenType |
getTag() |
String |
getTypeDeclaration(io.swagger.v3.oas.models.media.Schema propertySchema)
Output the type declaration of the property
|
String |
modelDocFileFolder() |
String |
modelFileFolder() |
String |
modelTestFileFolder() |
protected boolean |
needToImport(String type)
Check the type to see if it needs import the library/module/package
|
String |
normalizeType(String type)
Normalize type by wrapping primitive types with single quotes.
|
Map<String,Object> |
postProcessModels(Map<String,Object> objs) |
Map<String,Object> |
postProcessOperations(Map<String,Object> objs) |
void |
preprocessOpenAPI(io.swagger.v3.oas.models.OpenAPI openAPI) |
void |
processOpts() |
void |
setEmitJSDoc(boolean emitJSDoc) |
void |
setEmitModelMethods(boolean emitModelMethods) |
void |
setInvokerPackage(String invokerPackage) |
void |
setLicenseName(String licenseName) |
void |
setLocalVariablePrefix(String localVariablePrefix) |
void |
setModuleName(String moduleName) |
void |
setParameterExampleValue(CodegenParameter p)
Return the example value of the parameter.
|
void |
setProjectDescription(String projectDescription) |
void |
setProjectName(String projectName) |
void |
setProjectVersion(String projectVersion) |
void |
setSourceFolder(String sourceFolder) |
void |
setUseES6(boolean useES6) |
void |
setUseInheritance(boolean useInheritance) |
void |
setUsePromises(boolean usePromises) |
String |
toApiDocFilename(String name)
Return the file name of the Api Documentation
|
String |
toApiImport(String name)
Return the fully-qualified "Api" name for import
|
String |
toApiTestFilename(String name)
Return the file name of the Api Test
|
String |
toDefaultValue(io.swagger.v3.oas.models.media.Schema propertySchema)
Return the default value of the property
|
String |
toDefaultValueWithParam(String name,
io.swagger.v3.oas.models.media.Schema propertySchema)
Return the property initialized from a data object
Useful for initialization with a plain object in Javascript
|
String |
toEnumName(CodegenProperty property)
Return the Enum name (e.g.
|
String |
toEnumValue(String value,
String datatype)
Return the enum value in the language specified format
e.g.
|
String |
toEnumVarName(String value,
String datatype)
Return the sanitized variable name for enum
|
String |
toModelDocFilename(String name)
Return the capitalized file name of the model documentation
|
String |
toModelFilename(String name)
Return the capitalized file name of the model
|
String |
toModelImport(String name)
Return the fully-qualified "Model" name for import
|
String |
toModelName(String name)
Output the proper model name (capitalized).
|
String |
toModelTestFilename(String name)
Return the capitalized file name of the model test
|
String |
toOperationId(String operationId)
Return the operation ID (method name)
|
String |
toParamName(String name)
Return the parameter name by removing invalid characters and proper escaping if
it's a reserved word.
|
String |
toVarName(String name)
Return the variable name by removing invalid characters and proper escaping if
it's a reserved word.
|
addAdditionPropertiesToCodeGenModel, addConsumesInfo, addHandlebarHelpers, addImport, additionalProperties, addOperationToGroup, addProducesInfo, addProperties, addRegularExpressionDelimiter, apiDocFilename, apiDocTemplateFiles, apiFilename, apiPackage, apiTemplateFiles, apiTestFilename, apiTestTemplateFiles, buildLibraryCliOption, camelize, camelize, cliOptions, convertPropertyToBoolean, convertPropertyToBooleanAndWriteBack, dashize, defaultIncludes, detectParent, embeddedTemplateDir, escapeText, fileSuffix, findMethodResponse, fromModel, fromOperation, fromParameter, fromProperty, fromRequestBody, fromResponse, fromSecurity, generateExamplePath, getAlias, getCollectionFormat, getCommonTemplateDir, getConsumesInfo, getContentType, getGitRepoId, getGitUserId, getHttpUserAgent, getIgnoreFilePathOverride, getInnerEnumAllowableValues, getInputSpec, getLibrary, getOrGenerateOperationId, getOutputDir, getParameterFromRef, getParentName, getProducesInfo, getReleaseNote, getSchemaFromBody, getSchemaFromResponse, getSimpleRef, getSymbolName, getterAndSetterCapitalize, getTypeDeclaration, hasSchemaProperties, importMapping, initialCaps, instantiationTypes, isDataTypeBinary, isDataTypeFile, isPropertyInnerMostEnum, isRemoveOperationIdPrefix, isReservedWord, isSkipOverwrite, languageSpecificPrimitives, modelDocTemplateFiles, modelPackage, modelTemplateFiles, modelTestTemplateFiles, outputFolder, postProcessAllModels, postProcessModelProperty, postProcessModelsEnum, postProcessOperationsWithModels, postProcessParameter, postProcessSupportingFileData, processCompiler, processOpenAPI, removeNonNameElementToCamelCase, removeNonNameElementToCamelCase, reservedWords, reservedWordsMappings, sanitizeName, sanitizeTag, setAllowUnicodeIdentifiers, setApiPackage, setCommonTemplateDir, setEnsureUniqueParams, setGitRepoId, setGitUserId, setHttpUserAgent, setIgnoreFilePathOverride, setInputSpec, setLibrary, setModelNamePrefix, setModelNameSuffix, setModelPackage, setNonArrayMapProperty, setOutputDir, setParameterBooleanFlagWithCodegenProperty, setReleaseNote, setRemoveOperationIdPrefix, setReservedWordsLowerCase, setSkipOverwrite, setSortParamsByRequiredFlag, setTemplateDir, shouldOverwrite, snakeCase, supportedLibraries, supportingFiles, templateDir, testPackage, toApiFilename, toApiName, toApiVarName, toBooleanGetter, toEnumDefaultValue, toExamples, toExampleValue, toGetter, toInstantiationType, toRegularExpression, toSetter, typeMapping, underscore, updateDataTypeWithEnumForArray, updateDataTypeWithEnumForMap, updatePropertyForArray, updatePropertyForMap, vendorExtensions, writeOptional, writePropertyBackclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddHandlebarHelpers, additionalProperties, addOperationToGroup, apiDocFilename, apiDocTemplateFiles, apiFilename, apiPackage, apiTemplateFiles, apiTestFilename, apiTestTemplateFiles, cliOptions, defaultIncludes, embeddedTemplateDir, escapeText, fileSuffix, fromModel, fromOperation, fromSecurity, generateExamplePath, getCommonTemplateDir, getGitRepoId, getGitUserId, getHttpUserAgent, getIgnoreFilePathOverride, getInputSpec, getLibrary, getOutputDir, getReleaseNote, getTypeDeclaration, importMapping, instantiationTypes, isRemoveOperationIdPrefix, isSkipOverwrite, languageSpecificPrimitives, modelDocTemplateFiles, modelPackage, modelTemplateFiles, modelTestTemplateFiles, outputFolder, postProcessAllModels, postProcessModelProperty, postProcessOperationsWithModels, postProcessParameter, postProcessSupportingFileData, processCompiler, processOpenAPI, reservedWords, reservedWordsMappings, sanitizeTag, setGitRepoId, setGitUserId, setHttpUserAgent, setIgnoreFilePathOverride, setInputSpec, setLibrary, setOutputDir, setReleaseNote, setRemoveOperationIdPrefix, setSkipOverwrite, shouldOverwrite, supportedLibraries, supportingFiles, templateDir, testPackage, toApiFilename, toApiName, toApiVarName, toBooleanGetter, toGetter, toSetter, typeMapping, vendorExtensionspublic static final String PROJECT_NAME
public static final String MODULE_NAME
public static final String PROJECT_DESCRIPTION
public static final String PROJECT_VERSION
public static final String USE_PROMISES
public static final String USE_INHERITANCE
public static final String EMIT_MODEL_METHODS
public static final String EMIT_JS_DOC
public static final String USE_ES6
protected String projectName
protected String moduleName
protected String projectDescription
protected String projectVersion
protected String licenseName
protected String invokerPackage
protected String sourceFolder
protected String localVariablePrefix
protected boolean usePromises
protected boolean emitModelMethods
protected boolean emitJSDoc
protected String apiDocPath
protected String modelDocPath
protected String apiTestPath
protected String modelTestPath
protected boolean useES6
public CodegenType getTag()
getTag in interface CodegenConfiggetTag in class DefaultCodegenpublic String getName()
getName in interface CodegenConfiggetName in class DefaultCodegenpublic String getHelp()
getHelp in interface CodegenConfiggetHelp in class DefaultCodegenpublic void processOpts()
processOpts in interface CodegenConfigprocessOpts in class DefaultCodegenpublic void preprocessOpenAPI(io.swagger.v3.oas.models.OpenAPI openAPI)
preprocessOpenAPI in interface CodegenConfigpreprocessOpenAPI in class DefaultCodegenpublic String escapeReservedWord(String name)
DefaultCodegenescapeReservedWord in interface CodegenConfigescapeReservedWord in class DefaultCodegenname - the name to be escapedpublic String apiTestFileFolder()
apiTestFileFolder in interface CodegenConfigapiTestFileFolder in class DefaultCodegenpublic String modelTestFileFolder()
modelTestFileFolder in interface CodegenConfigmodelTestFileFolder in class DefaultCodegenpublic String apiFileFolder()
apiFileFolder in interface CodegenConfigapiFileFolder in class DefaultCodegenpublic String modelFileFolder()
modelFileFolder in interface CodegenConfigmodelFileFolder in class DefaultCodegenpublic void setInvokerPackage(String invokerPackage)
public void setSourceFolder(String sourceFolder)
public void setProjectName(String projectName)
public void setLocalVariablePrefix(String localVariablePrefix)
public void setModuleName(String moduleName)
public void setProjectDescription(String projectDescription)
public void setProjectVersion(String projectVersion)
public void setLicenseName(String licenseName)
public void setUsePromises(boolean usePromises)
public void setUseES6(boolean useES6)
public void setUseInheritance(boolean useInheritance)
public void setEmitModelMethods(boolean emitModelMethods)
public void setEmitJSDoc(boolean emitJSDoc)
public String apiDocFileFolder()
apiDocFileFolder in interface CodegenConfigapiDocFileFolder in class DefaultCodegenpublic String modelDocFileFolder()
modelDocFileFolder in interface CodegenConfigmodelDocFileFolder in class DefaultCodegenpublic String toApiDocFilename(String name)
DefaultCodegentoApiDocFilename in interface CodegenConfigtoApiDocFilename in class DefaultCodegenname - the file name of the Apipublic String toModelDocFilename(String name)
DefaultCodegentoModelDocFilename in interface CodegenConfigtoModelDocFilename in class DefaultCodegenname - the model namepublic String toApiTestFilename(String name)
DefaultCodegentoApiTestFilename in interface CodegenConfigtoApiTestFilename in class DefaultCodegenname - the file name of the Apipublic String toModelTestFilename(String name)
DefaultCodegentoModelTestFilename in interface CodegenConfigtoModelTestFilename in class DefaultCodegenname - the model namepublic String toVarName(String name)
DefaultCodegentoVarName in class DefaultCodegenname - the variable namepublic String toParamName(String name)
DefaultCodegentoParamName in interface CodegenConfigtoParamName in class DefaultCodegenname - Codegen property objectpublic String toModelName(String name)
DefaultCodegentoModelName in interface CodegenConfigtoModelName in class DefaultCodegenname - the name of the modelpublic String toModelFilename(String name)
DefaultCodegentoModelFilename in interface CodegenConfigtoModelFilename in class DefaultCodegenname - the model namepublic String toModelImport(String name)
DefaultCodegentoModelImport in interface CodegenConfigtoModelImport in class DefaultCodegenname - the name of the "Model"public String toApiImport(String name)
DefaultCodegentoApiImport in interface CodegenConfigtoApiImport in class DefaultCodegenname - the name of the "Api"public String getTypeDeclaration(io.swagger.v3.oas.models.media.Schema propertySchema)
DefaultCodegengetTypeDeclaration in interface CodegenConfiggetTypeDeclaration in class DefaultCodegenpropertySchema - Schema Property objectpublic String toDefaultValue(io.swagger.v3.oas.models.media.Schema propertySchema)
DefaultCodegentoDefaultValue in class DefaultCodegenpropertySchema - Schema property objectpublic String toDefaultValueWithParam(String name, io.swagger.v3.oas.models.media.Schema propertySchema)
DefaultCodegentoDefaultValueWithParam in class DefaultCodegenname - Name of the property objectpropertySchema - openAPI schema objectpublic void setParameterExampleValue(CodegenParameter p)
DefaultCodegensetParameterExampleValue in class DefaultCodegenp - Swagger property objectpublic String normalizeType(String type)
type - Primitive typepublic String getSchemaType(io.swagger.v3.oas.models.media.Schema propertySchema)
DefaultCodegengetSchemaType in class DefaultCodegenpropertySchema - Schema property objectpublic String toOperationId(String operationId)
DefaultCodegentoOperationId in class DefaultCodegenoperationId - operation IDpublic CodegenOperation fromOperation(String path, String httpMethod, io.swagger.v3.oas.models.Operation operation, Map<String,io.swagger.v3.oas.models.media.Schema> schemas, io.swagger.v3.oas.models.OpenAPI openAPI)
DefaultCodegenfromOperation in interface CodegenConfigfromOperation in class DefaultCodegenpath - the path of the operationhttpMethod - HTTP methodoperation - Swagger operation objectschemas - a map of schemasopenAPI - a OpenAPI object representing the specpublic CodegenModel fromModel(String name, io.swagger.v3.oas.models.media.Schema schema, Map<String,io.swagger.v3.oas.models.media.Schema> allSchemas)
DefaultCodegenfromModel in interface CodegenConfigfromModel in class DefaultCodegenname - the name of the modelschema - Swagger Model objectallSchemas - a map of all Swagger models from the specpublic Map<String,Object> postProcessOperations(Map<String,Object> objs)
postProcessOperations in interface CodegenConfigpostProcessOperations in class DefaultCodegenpublic Map<String,Object> postProcessModels(Map<String,Object> objs)
postProcessModels in interface CodegenConfigpostProcessModels in class DefaultCodegenprotected boolean needToImport(String type)
DefaultCodegenneedToImport in class DefaultCodegentype - name of the typepublic String toEnumName(CodegenProperty property)
DefaultCodegentoEnumName in class DefaultCodegenproperty - Codegen propertypublic String toEnumVarName(String value, String datatype)
DefaultCodegentoEnumVarName in class DefaultCodegenvalue - enum variable namedatatype - data typepublic String toEnumValue(String value, String datatype)
DefaultCodegentoEnumValue in class DefaultCodegenvalue - enum variable namedatatype - data typepublic String escapeQuotationMark(String input)
DefaultCodegenescapeQuotationMark in interface CodegenConfigescapeQuotationMark in class DefaultCodegeninput - String to be cleaned uppublic String escapeUnsafeCharacters(String input)
DefaultCodegenescapeUnsafeCharacters in interface CodegenConfigescapeUnsafeCharacters in class DefaultCodegeninput - String to be cleaned upCopyright © 2018. All rights reserved.