Class AbstractScalaCodegen
- java.lang.Object
-
- org.openapitools.codegen.DefaultCodegen
-
- org.openapitools.codegen.languages.AbstractScalaCodegen
-
- All Implemented Interfaces:
CodegenConfig
- Direct Known Subclasses:
ScalaAkkaClientCodegen
,ScalaAkkaHttpServerCodegen
,ScalaGatlingCodegen
,ScalaLagomServerCodegen
,ScalaPlayFrameworkServerCodegen
,ScalaSttp4ClientCodegen
,ScalaSttpClientCodegen
,ScalatraServerCodegen
,ScalazClientCodegen
public abstract class AbstractScalaCodegen extends DefaultCodegen
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
AbstractScalaCodegen.CamelizeLambda
protected static class
AbstractScalaCodegen.CustomLambda
protected static class
AbstractScalaCodegen.DateLibraries
-
Field Summary
Fields Modifier and Type Field Description protected String
apiVersion
protected String
appDescription
protected String
appName
protected String
dateLibrary
protected String
infoEmail
protected String
infoUrl
protected String
invokerPackage
protected String
licenseInfo
protected String
licenseUrl
protected String
modelPropertyNaming
protected String
sourceFolder
protected boolean
stripPackageName
-
Fields inherited from class org.openapitools.codegen.DefaultCodegen
additionalProperties, addOneOfInterfaceImports, addOneOfInterfaces, addSuffixToDuplicateOperationNicknames, allowUnicodeIdentifiers, apiDocTemplateFiles, apiNamePrefix, apiNameSuffix, apiPackage, apiTemplateFiles, apiTestTemplateFiles, cliOptions, DefaultFeatureSet, defaultIncludes, disallowAdditionalPropertiesIfNotPresent, docExtension, embeddedTemplateDir, enableMinimalUpdate, enablePostProcessFile, ensureUniqueParams, enumUnknownDefaultCase, enumUnknownDefaultCaseName, falseSchema, filesMetadataFilename, fileSuffix, generatorMetadata, gitHost, gitRepoId, gitUserId, hideGenerationTimestamp, httpUserAgent, ignoreFilePathOverride, importBaseType, importContainerType, importMapping, inlineSchemaNameDefault, inlineSchemaNameMapping, inputSpec, instantiationTypes, JSON_MIME_PATTERN, JSON_VENDOR_MIME_PATTERN, languageSpecificPrimitives, legacyDiscriminatorBehavior, library, loadDeepObjectIntoItems, modelDocTemplateFiles, modelNamePrefix, modelNameSuffix, modelPackage, modelTemplateFiles, modelTestTemplateFiles, openAPI, openapiNormalizer, outputFolder, prependFormOrBodyParameters, releaseNote, removeEnumValuePrefix, removeOperationIdPrefix, removeOperationIdPrefixCount, removeOperationIdPrefixDelimiter, reservedWords, reservedWordsMappings, schemaMapping, serverVariables, skipOperationExample, skipOverwrite, sortModelPropertiesByRequiredFlag, sortParamsByRequiredFlag, specialCharReplacements, strictSpecBehavior, supportedLibraries, supportingFiles, supportsAdditionalPropertiesWithComposedSchema, supportsInheritance, supportsMixins, supportsMultipleInheritance, templateDir, testPackage, trueSchema, typeAliases, typeMapping, useOneOfInterfaces, vendorExtensions, versionMetadataFilename
-
-
Constructor Summary
Constructors Constructor Description AbstractScalaCodegen()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
apiFileFolder()
String
escapeQuotationMark(String input)
Escape single and/or double quote to avoid code injectionString
escapeReservedWord(String name)
Return the escaped name of the reserved wordString
escapeUnsafeCharacters(String input)
override with any special text escaping logic to handle unsafe characters so as to avoid code injectionprotected String
formatIdentifier(String name, boolean capitalized)
CodegenProperty
fromProperty(String name, io.swagger.v3.oas.models.media.Schema p, boolean required)
Convert OAS Property object to Codegen Property objectGeneratorLanguage
generatorLanguage()
String
getDateLibrary()
String
getModelPropertyNaming()
String
getNameUsingModelPropertyNaming(String name)
String
getSchemaType(io.swagger.v3.oas.models.media.Schema p)
returns the OpenAPI type for the property.String
getSourceFolder()
String
getTypeDeclaration(io.swagger.v3.oas.models.media.Schema p)
Output the language-specific type declaration of the property.String
modelFileFolder()
void
postProcessFile(File file, String fileType)
Post-process the auto-generated file, e.g.ModelsMap
postProcessModels(ModelsMap objs)
com.samskivert.mustache.Mustache.Compiler
processCompiler(com.samskivert.mustache.Mustache.Compiler compiler)
void
processOpts()
void
setDateLibrary(String dateLibrary, boolean withLegacy)
void
setInvokerPackage(String invokerPackage)
void
setModelPropertyNaming(String naming)
void
setSourceFolder(String sourceFolder)
protected String
stripPackageName(String input)
String
toDefaultValue(io.swagger.v3.oas.models.media.Schema p)
Return the default value of the propertyString
toInstantiationType(io.swagger.v3.oas.models.media.Schema p)
Return the instantiation type of the property, especially for map and arrayString
toModelFilename(String name)
Return the capitalized file name of the modelString
toModelName(String name)
Converts the OpenAPI schema name to a model name suitable for the current code generator.String
toOperationId(String operationId)
Return the operation ID (method name)String
toVarName(String name)
Return the variable name by removing invalid characters and proper escaping if it's a reserved word.-
Methods inherited from class org.openapitools.codegen.DefaultCodegen
addAdditionPropertiesToCodeGenModel, addBodyModelSchema, addHeaders, addImport, addImport, addImport, addImports, addImports, addImports, addImportsForPropertyType, addImportsToOneOfInterface, additionalProperties, addMustacheLambdas, addOneOfInterfaceModel, addOneOfNameExtension, addOperationToGroup, addOption, addOption, addParentContainer, addProperties, addRegularExpressionDelimiter, addRequiredVarsMap, addSwitch, addVars, addVars, addVarsRequiredVarsAdditionalProps, apiDocFileFolder, apiDocFilename, apiDocTemplateFiles, apiFilename, apiPackage, apiTemplateFiles, apiTestFileFolder, apiTestFilename, apiTestTemplateFiles, buildEnumVars, buildLibraryCliOption, cliOptions, convertPropertyToBoolean, convertPropertyToBooleanAndWriteBack, createDiscriminator, defaultIncludes, defaultTemplatingEngine, embeddedTemplateDir, encodePath, escapeText, escapeTextWhileAllowingNewLines, fileSuffix, findCommonPrefixOfVars, findMethodResponse, fromCallback, fromFormProperty, fromModel, fromOperation, fromParameter, fromProperty, fromProperty, fromRequestBody, fromRequestBodyToFormParameters, fromResponse, fromSecurity, fromServers, fromServerVariables, generateExamplePath, generateJSONSpecFile, generateYAMLSpecFile, generatorLanguageVersion, getAdditionalProperties, getAdditionalPropertiesName, getAddSuffixToDuplicateOperationNicknames, getAlias, getAllModels, getAllOfDescendants, getAllowUnicodeIdentifiers, getApiNamePrefix, getApiNameSuffix, getCollectionFormat, getCollectionFormat, getConsumesInfo, getContent, getContentType, getDisallowAdditionalPropertiesIfNotPresent, getDocExtension, getEnsureUniqueParams, getEnumDefaultValue, getEnumUnknownDefaultCase, getFeatureSet, getFilesMetadataFilename, getGeneratorMetadata, getGitHost, getGitRepoId, getGitUserId, getHelp, getHttpUserAgent, getIgnoreFilePathOverride, getInnerEnumAllowableValues, getInputSpec, getItemsName, getLegacyDiscriminatorBehavior, getLibrary, getModelNamePrefix, getModelNameSuffix, getModelNameToSchemaCache, getMostInnerItems, getName, getOneOfAnyOfDescendants, getOrGenerateOperationId, getOutputDir, getParameterDataType, getPrependFormOrBodyParameters, getProducesInfo, getReleaseNote, getRemoveOperationIdPrefixCount, getRemoveOperationIdPrefixDelimiter, getSchemaAdditionalProperties, getSchemaFromBooleanOrSchema, getSchemaItems, getSingleSchemaType, getSortModelPropertiesByRequiredFlag, getSortParamsByRequiredFlag, getSupportedVendorExtensions, getSymbolName, getTag, getTemplatingEngine, getterAndSetterCapitalize, getTypeDeclaration, getUseInlineModelResolver, getUseOneOfInterfaces, getUseOpenAPINormalizer, getVersionMetadataFilename, handleMethodResponse, handleMethodResponse, handleSpecialCharacters, hasBodyParameter, hasFormParameter, importMapping, initializeSpecialCharacterMapping, inlineSchemaNameDefault, inlineSchemaNameMapping, instantiationTypes, isAnyTypeSchema, isDataTypeBinary, isDataTypeFile, isDataTypeString, isEnableMinimalUpdate, isEnablePostProcessFile, isFreeFormObject, isHideGenerationTimestamp, isJsonMimeType, isJsonVendorMimeType, isLibrary, isParameterNameUnique, isPropertyInnerMostEnum, isRemoveEnumValuePrefix, isRemoveOperationIdPrefix, isReservedWord, isSkipOperationExample, isSkipOverwrite, isStrictSpecBehavior, languageSpecificPrimitives, lowerCamelCase, modelDocFileFolder, modelDocTemplateFiles, modelFilename, modelPackage, modelTemplateFiles, modelTestFileFolder, modelTestTemplateFiles, modifyFeatureSet, needToImport, openapiNormalizer, outputFolder, postProcess, postProcessAllModels, postProcessModelProperty, postProcessModelsEnum, postProcessOperationsWithModels, postProcessParameter, postProcessSupportingFileData, preprocessOpenAPI, processOpenAPI, processTemplatingEngine, processTestExampleData, removeImport, removeNonNameElementToCamelCase, removeNonNameElementToCamelCase, removeOption, removeSelfReferenceImports, reservedWords, reservedWordsMappings, sanitizeName, sanitizeName, sanitizeName, sanitizeTag, schemaMapping, serverVariableOverrides, setAddProps, setAllowUnicodeIdentifiers, setApiNamePrefix, setApiNameSuffix, setApiPackage, setCircularReferences, setDisallowAdditionalPropertiesIfNotPresent, setDocExtension, setEnableMinimalUpdate, setEnablePostProcessFile, setEnsureUniqueParams, setEnumUnknownDefaultCase, setFilesMetadataFilename, setGitHost, setGitRepoId, setGitUserId, setHideGenerationTimestamp, setHttpUserAgent, setIgnoreFilePathOverride, setInputSpec, setLegacyDiscriminatorBehavior, setLibrary, setModelNamePrefix, setModelNameSuffix, setModelPackage, setNonArrayMapProperty, setOpenAPI, setOutputDir, setParameterBooleanFlagWithCodegenProperty, setParameterEncodingValues, setParameterExamples, setParameterExampleValue, setParameterExampleValue, setParameterExampleValue, setParameterNullable, setPrependFormOrBodyParameters, setReleaseNote, setRemoveEnumValuePrefix, setRemoveOperationIdPrefix, setRemoveOperationIdPrefixCount, setRemoveOperationIdPrefixDelimiter, setReservedWordsLowerCase, setSkipOperationExample, setSkipOverwrite, setSortModelPropertiesByRequiredFlag, setSortParamsByRequiredFlag, setStrictSpecBehavior, setTemplateDir, setTemplatingEngine, setUseOneOfInterfaces, setVersionMetadataFilename, shouldAddImport, shouldOverwrite, supportedLibraries, supportingFiles, templateDir, testPackage, toAllOfName, toAnyOfName, toApiDocFilename, toApiFilename, toApiImport, toApiName, toApiTestFilename, toApiVarName, toArrayModelParamName, toBooleanGetter, toDefaultParameterValue, toDefaultParameterValue, toDefaultValue, toDefaultValueWithParam, toEnumDefaultValue, toEnumName, toEnumValue, toEnumVarName, toExamples, toExampleValue, toGetter, toMediaTypeSchemaName, toModelDocFilename, toModelImport, toModelImportMap, toModelTestFilename, toOneOfName, toParamName, toRegularExpression, toSetter, toTestCaseName, typeMapping, unaliasPropertySchema, unaliasSchema, updateAllModels, updateCodegenPropertyEnum, updateDataTypeWithEnumForArray, updateDataTypeWithEnumForMap, updateEnumVarsWithExtensions, updateModelForAnyType, updateModelForComposedSchema, updateModelForInteger, updateModelForNumber, updateModelForObject, updateModelForString, updateOption, updateParameterForString, updatePropertyForAnyType, updatePropertyForArray, updatePropertyForInteger, updatePropertyForMap, updatePropertyForMap, updatePropertyForNumber, updatePropertyForObject, updatePropertyForString, updateRequestBodyForArray, updateRequestBodyForMap, updateRequestBodyForObject, updateRequestBodyForPrimitiveType, updateRequestBodyForString, vendorExtensions, writePropertyBack
-
-
-
-
Field Detail
-
modelPropertyNaming
protected String modelPropertyNaming
-
invokerPackage
protected String invokerPackage
-
sourceFolder
protected String sourceFolder
-
appName
protected String appName
-
appDescription
protected String appDescription
-
infoUrl
protected String infoUrl
-
infoEmail
protected String infoEmail
-
licenseInfo
protected String licenseInfo
-
licenseUrl
protected String licenseUrl
-
apiVersion
protected String apiVersion
-
stripPackageName
protected boolean stripPackageName
-
dateLibrary
protected String dateLibrary
-
-
Method Detail
-
processOpts
public void processOpts()
- Specified by:
processOpts
in interfaceCodegenConfig
- Overrides:
processOpts
in classDefaultCodegen
-
setDateLibrary
public void setDateLibrary(String dateLibrary, boolean withLegacy)
-
getDateLibrary
public String getDateLibrary()
-
setModelPropertyNaming
public void setModelPropertyNaming(String naming)
-
getModelPropertyNaming
public String getModelPropertyNaming()
-
toVarName
public String toVarName(String name)
Description copied from class:DefaultCodegen
Return the variable name by removing invalid characters and proper escaping if it's a reserved word.- Overrides:
toVarName
in classDefaultCodegen
- Parameters:
name
- the variable name- Returns:
- the sanitized variable name
-
getSourceFolder
public String getSourceFolder()
-
setSourceFolder
public void setSourceFolder(String sourceFolder)
-
escapeReservedWord
public String escapeReservedWord(String name)
Description copied from class:DefaultCodegen
Return the escaped name of the reserved word- Specified by:
escapeReservedWord
in interfaceCodegenConfig
- Overrides:
escapeReservedWord
in classDefaultCodegen
- Parameters:
name
- the name to be escaped- Returns:
- the escaped reserved word
throws Runtime exception as reserved word is not allowed (default behavior)
-
processCompiler
public com.samskivert.mustache.Mustache.Compiler processCompiler(com.samskivert.mustache.Mustache.Compiler compiler)
- Specified by:
processCompiler
in interfaceCodegenConfig
- Overrides:
processCompiler
in classDefaultCodegen
-
apiFileFolder
public String apiFileFolder()
- Specified by:
apiFileFolder
in interfaceCodegenConfig
- Overrides:
apiFileFolder
in classDefaultCodegen
-
modelFileFolder
public String modelFileFolder()
- Specified by:
modelFileFolder
in interfaceCodegenConfig
- Overrides:
modelFileFolder
in classDefaultCodegen
-
getTypeDeclaration
public String getTypeDeclaration(io.swagger.v3.oas.models.media.Schema p)
Description copied from class:DefaultCodegen
Output the language-specific type declaration of the property.- Specified by:
getTypeDeclaration
in interfaceCodegenConfig
- Overrides:
getTypeDeclaration
in classDefaultCodegen
- Parameters:
p
- property schema- Returns:
- a string presentation of the property type
-
getSchemaType
public String getSchemaType(io.swagger.v3.oas.models.media.Schema p)
Description copied from class:DefaultCodegen
returns the OpenAPI type for the property. Use getAlias to handle $ref of primitive type- Overrides:
getSchemaType
in classDefaultCodegen
- Parameters:
p
- property schema- Returns:
- string presentation of the type
-
toInstantiationType
public String toInstantiationType(io.swagger.v3.oas.models.media.Schema p)
Description copied from class:DefaultCodegen
Return the instantiation type of the property, especially for map and array- Overrides:
toInstantiationType
in classDefaultCodegen
- Parameters:
p
- property schema- Returns:
- string presentation of the instantiation type of the property
-
toDefaultValue
public String toDefaultValue(io.swagger.v3.oas.models.media.Schema p)
Description copied from class:DefaultCodegen
Return the default value of the propertyThis method should be overridden in the generator to meet its requirement. Return null if you do NOT want a default value. Any non-null value will cause {{#defaultValue} check to pass.
- Overrides:
toDefaultValue
in classDefaultCodegen
- Parameters:
p
- Property schema- Returns:
- string presentation of the default value of the property
-
fromProperty
public CodegenProperty fromProperty(String name, io.swagger.v3.oas.models.media.Schema p, boolean required)
Convert OAS Property object to Codegen Property object- Overrides:
fromProperty
in classDefaultCodegen
- Parameters:
name
- name of the propertyp
- OAS property objectrequired
- true if the property is required in the next higher object schema, false otherwise- Returns:
- Codegen Property object
-
postProcessModels
public ModelsMap postProcessModels(ModelsMap objs)
- Specified by:
postProcessModels
in interfaceCodegenConfig
- Overrides:
postProcessModels
in classDefaultCodegen
-
toModelName
public String toModelName(String name)
Description copied from class:DefaultCodegen
Converts the OpenAPI schema name to a model name suitable for the current code generator. May be overridden for each programming language. In case the name belongs to the TypeSystem it won't be renamed.- Specified by:
toModelName
in interfaceCodegenConfig
- Overrides:
toModelName
in classDefaultCodegen
- Parameters:
name
- the name of the model- Returns:
- capitalized model name
-
toModelFilename
public String toModelFilename(String name)
Description copied from class:DefaultCodegen
Return the capitalized file name of the model- Specified by:
toModelFilename
in interfaceCodegenConfig
- Overrides:
toModelFilename
in classDefaultCodegen
- Parameters:
name
- the model name- Returns:
- the file name of the model
-
escapeUnsafeCharacters
public String escapeUnsafeCharacters(String input)
Description copied from class:DefaultCodegen
override with any special text escaping logic to handle unsafe characters so as to avoid code injection- Specified by:
escapeUnsafeCharacters
in interfaceCodegenConfig
- Overrides:
escapeUnsafeCharacters
in classDefaultCodegen
- Parameters:
input
- String to be cleaned up- Returns:
- string with unsafe characters removed or escaped
-
escapeQuotationMark
public String escapeQuotationMark(String input)
Description copied from class:DefaultCodegen
Escape single and/or double quote to avoid code injection- Specified by:
escapeQuotationMark
in interfaceCodegenConfig
- Overrides:
escapeQuotationMark
in classDefaultCodegen
- Parameters:
input
- String to be cleaned up- Returns:
- string with quotation mark removed or escaped
-
postProcessFile
public void postProcessFile(File file, String fileType)
Description copied from class:DefaultCodegen
Post-process the auto-generated file, e.g. using go-fmt to format the Go code. The file type can be "model-test", "model-doc", "model", "api", "api-test", "api-doc", "supporting-mustache", "supporting-common", "openapi-generator-ignore", "openapi-generator-version"TODO: store these values in enum instead
- Specified by:
postProcessFile
in interfaceCodegenConfig
- Overrides:
postProcessFile
in classDefaultCodegen
- Parameters:
file
- file to be processedfileType
- file type
-
toOperationId
public String toOperationId(String operationId)
Description copied from class:DefaultCodegen
Return the operation ID (method name)- Overrides:
toOperationId
in classDefaultCodegen
- Parameters:
operationId
- operation ID- Returns:
- the sanitized method name
-
setInvokerPackage
public void setInvokerPackage(String invokerPackage)
-
generatorLanguage
public GeneratorLanguage generatorLanguage()
- Specified by:
generatorLanguage
in interfaceCodegenConfig
- Overrides:
generatorLanguage
in classDefaultCodegen
-
-