Class AbstractJavaCodegen
- java.lang.Object
-
- org.openapitools.codegen.DefaultCodegen
-
- org.openapitools.codegen.languages.AbstractJavaCodegen
-
- All Implemented Interfaces:
CodegenConfig,DocumentationProviderFeatures
- Direct Known Subclasses:
AbstractJavaJAXRSServerCodegen,GroovyClientCodegen,JavaClientCodegen,JavaCXFClientCodegen,JavaHelidonCommonCodegen,JavaInflectorServerCodegen,JavaMicronautAbstractCodegen,JavaPKMSTServerCodegen,JavaPlayFrameworkCodegen,JavaUndertowServerCodegen,JavaVertXServerCodegen,JavaVertXWebServerCodegen,JavaWiremockServerCodegen,SpringCodegen
public abstract class AbstractJavaCodegen extends DefaultCodegen implements CodegenConfig, DocumentationProviderFeatures
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classAbstractJavaCodegen.ENUM_PROPERTY_NAMING_TYPE-
Nested classes/interfaces inherited from interface org.openapitools.codegen.languages.features.DocumentationProviderFeatures
DocumentationProviderFeatures.AnnotationLibrary, DocumentationProviderFeatures.DocumentationProvider
-
-
Field Summary
-
Fields inherited from class org.openapitools.codegen.DefaultCodegen
additionalProperties, addOneOfInterfaceImports, addOneOfInterfaces, addSuffixToDuplicateOperationNicknames, allowUnicodeIdentifiers, apiDocTemplateFiles, apiNamePrefix, apiNameSuffix, apiPackage, apiTemplateFiles, apiTestTemplateFiles, autosetConstants, cliOptions, DefaultFeatureSet, defaultIncludes, defaultToEmptyContainer, disallowAdditionalPropertiesIfNotPresent, docExtension, embeddedTemplateDir, enableMinimalUpdate, enablePostProcessFile, ensureUniqueParams, enumNameMapping, enumUnknownDefaultCase, enumUnknownDefaultCaseName, falseSchema, filesMetadataFilename, fileSuffix, generatorMetadata, gitHost, gitRepoId, gitUserId, hideGenerationTimestamp, httpUserAgent, ignoreFilePathOverride, importBaseType, importContainerType, importMapping, inlineSchemaNameMapping, inlineSchemaOption, inputSpec, instantiationTypes, JSON_MIME_PATTERN, JSON_VENDOR_MIME_PATTERN, languageSpecificPrimitives, legacyDiscriminatorBehavior, library, loadDeepObjectIntoItems, modelDocTemplateFiles, modelNameMapping, modelNamePrefix, modelNameSuffix, modelPackage, modelTemplateFiles, modelTestTemplateFiles, nameMapping, openAPI, openapiGeneratorIgnoreList, openapiNormalizer, operationIdNameMapping, outputFolder, parameterNameMapping, prependFormOrBodyParameters, releaseNote, removeEnumValuePrefix, removeOperationIdPrefix, removeOperationIdPrefixCount, removeOperationIdPrefixDelimiter, reservedWords, reservedWordsMappings, schemaMapping, serverVariables, skipOperationExample, skipOverwrite, skipSortingOperations, sortModelPropertiesByRequiredFlag, sortParamsByRequiredFlag, specialCharReplacements, strictSpecBehavior, supportedLibraries, supportingFiles, supportsAdditionalPropertiesWithComposedSchema, supportsInheritance, supportsMixins, supportsMultipleInheritance, templateDir, templateOutputDirs, testPackage, trueSchema, typeAliases, typeMapping, useOneOfInterfaces, vendorExtensions, versionMetadataFilename, XML_MIME_PATTERN
-
Fields inherited from interface org.openapitools.codegen.languages.features.DocumentationProviderFeatures
ANNOTATION_LIBRARY, DOCUMENTATION_PROVIDER
-
-
Constructor Summary
Constructors Constructor Description AbstractJavaCodegen()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddAdditionPropertiesToCodeGenModel(CodegenModel codegenModel, io.swagger.v3.oas.models.media.Schema schema)Handle the model for the 'additionalProperties' keyword in the OAS schema.static voidaddImports(List<Map<String,String>> imports, CodegenModel cm, Map<String,String> imports2Classnames)voidaddImportsToOneOfInterface(List<Map<String,String>> imports)StringapiDocFileFolder()StringapiFileFolder()StringapiTestFileFolder()protected voidapplyJakartaPackage()protected voidapplyJavaxPackage()StringescapeQuotationMark(String input)Escape single and/or double quote to avoid code injectionStringescapeReservedWord(String name)Return the escaped name of the reserved wordStringescapeUnsafeCharacters(String input)override with any special text escaping logic to handle unsafe characters so as to avoid code injectionprotected Optional<CodegenProperty>findByName(String name, List<CodegenProperty> properties)Search for property byCodegenProperty.nameCodegenModelfromModel(String name, io.swagger.v3.oas.models.media.Schema model)Convert OAS Model object to Codegen Model object.CodegenOperationfromOperation(String path, String httpMethod, io.swagger.v3.oas.models.Operation operation, List<io.swagger.v3.oas.models.servers.Server> servers)Convert OAS Operation object to Codegen Operation objectDocumentationProviderFeatures.AnnotationLibrarygetAnnotationLibrary()DocumentationProviderFeatures.DocumentationProvidergetDocumentationProvider()StringgetOutputTestFolder()StringgetSchemaType(io.swagger.v3.oas.models.media.Schema p)returns the OpenAPI type for the property.List<VendorExtension>getSupportedVendorExtensions()StringgetterAndSetterCapitalize(String name)Camelize the method name of the getter and setterStringgetTypeDeclaration(io.swagger.v3.oas.models.media.Schema p)Output the language-specific type declaration of the property.protected voidhandleImplicitHeaders(CodegenOperation operation)This method removes all implicit header parameters from the list of parametersbooleanisAddNullableImports(CodegenModel cm, boolean addImports, CodegenProperty var)protected booleanisConstructorWithAllArgsAllowed(CodegenModel codegenModel)trigger the generation of all arguments constructor or not.booleanisTypeErasedGenerics()StringmodelDocFileFolder()StringmodelFileFolder()StringmodelTestFileFolder()protected booleanneedToImport(String type)Check the type to see if it needs import the library/module/packageMap<String,ModelsMap>postProcessAllModels(Map<String,ModelsMap> objs)Analyse and post process all Models.voidpostProcessFile(File file, String fileType)Post-process the auto-generated file, e.g. using go-fmt to format the Go code.voidpostProcessModelProperty(CodegenModel model, CodegenProperty property)ModelsMappostProcessModels(ModelsMap objs)OperationsMappostProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels)voidpostProcessResponseWithProperty(CodegenResponse response, CodegenProperty property)voidpreprocessOpenAPI(io.swagger.v3.oas.models.OpenAPI openAPI)voidprocessOpts()StringremoveAnnotations(String dataType)Remove annotations from the given data type string.StringsanitizeDataType(String dataType)Sanitize the datatype.StringsanitizeTag(String tag)Sanitize tagvoidsetAnnotationLibrary(DocumentationProviderFeatures.AnnotationLibrary annotationLibrary)voidsetDocumentationProvider(DocumentationProviderFeatures.DocumentationProvider documentationProvider)voidsetEnumPropertyNaming(String enumPropertyNamingType)Sets the naming convention for Java enum propertiesvoidsetOutputDir(String dir)voidsetParameterExampleValue(CodegenParameter p)Return the example value of the parameter.voidsetParameterExampleValue(CodegenParameter codegenParameter, io.swagger.v3.oas.models.parameters.Parameter parameter)Return the example value of the parameter.voidsetParameterExampleValue(CodegenParameter codegenParameter, io.swagger.v3.oas.models.parameters.RequestBody requestBody)Return the example value of the parameter.StringtoApiDocFilename(String name)Return the file name of the Api DocumentationStringtoApiFilename(String name)Return the file name of the ApiStringtoApiTestFilename(String name)Return the file name of the Api TestStringtoArrayDefaultValue(CodegenProperty cp, io.swagger.v3.oas.models.media.Schema schema)Return the default value of array propertyStringtoBooleanGetter(String name)Output the Getter name for boolean property, e.g. isActiveStringtoDefaultParameterValue(io.swagger.v3.oas.models.media.Schema<?> schema)Return the default value of the parameterStringtoDefaultValue(CodegenProperty cp, io.swagger.v3.oas.models.media.Schema schema)Return the default value of the propertyStringtoEnumName(CodegenProperty property)Return the Enum name (e.g.StringtoEnumValue(String value, String datatype)Return the enum value in the language specified format e.g. status becomes "status"StringtoEnumVarName(String value, String datatype)Return the sanitized variable name for enumStringtoExampleValue(io.swagger.v3.oas.models.media.Schema p)Return the example value of the propertyStringtoModelDocFilename(String name)Return the capitalized file name of the model documentationStringtoModelFilename(String name)Return the capitalized file name of the modelStringtoModelName(String name)Converts the OpenAPI schema name to a model name suitable for the current code generator.StringtoModelTestFilename(String name)Return the capitalized file name of the model testStringtoOperationId(String operationId)Return the operation ID (method name)StringtoParamName(String name)Return the parameter name by removing invalid characters and proper escaping if it's a reserved word.StringtoRegularExpression(String pattern)Return the regular expression/JSON schema pattern (http://json-schema.org/latest/json-schema-validation.html#anchor33)StringtoVarName(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
addBodyModelSchema, addHeaders, addImport, addImport, addImport, addImports, addImports, addImports, addImportsForPropertyType, additionalProperties, addMustacheLambdas, addOneOfInterfaceModel, addOneOfNameExtension, addOperationToGroup, addOption, addOption, addParentContainer, addParentFromContainer, addProperties, addRegularExpressionDelimiter, addRequiredVarsMap, addSwitch, addVars, addVars, addVarsRequiredVarsAdditionalProps, apiDocFilename, apiDocTemplateFiles, apiFilename, apiFilename, apiPackage, apiTemplateFiles, apiTestFilename, apiTestTemplateFiles, buildEnumVars, buildLibraryCliOption, cliOptions, convertPropertyToBoolean, convertPropertyToBooleanAndWriteBack, convertPropertyToBooleanAndWriteBack, convertPropertyToStringAndWriteBack, convertPropertyToTypeAndWriteBack, createDiscriminator, defaultIncludes, defaultTemplatingEngine, embeddedTemplateDir, encodePath, enumNameMapping, escapeText, escapeTextInSingleQuotes, escapeTextWhileAllowingNewLines, executePostProcessor, fileSuffix, findCommonPrefixOfVars, findMethodResponse, fromCallback, fromFormProperty, fromParameter, fromProperty, fromProperty, fromProperty, fromRequestBody, fromRequestBodyToFormParameters, fromResponse, fromSecurity, fromServers, fromServerVariables, generateExamplePath, generateJSONSpecFile, generateYAMLSpecFile, generatorLanguage, generatorLanguageVersion, getAdditionalPropertiesName, getAddSuffixToDuplicateOperationNicknames, getAlias, getAllModels, getAllOfDescendants, getCollectionFormat, getCollectionFormat, getConsumesInfo, getContent, getContentType, getDisallowAdditionalPropertiesIfNotPresent, getDocExtension, getEnumDefaultValue, getEnumUnknownDefaultCase, getEnumValueForProperty, getFeatureSet, getFilesMetadataFilename, getGeneratorMetadata, getGitHost, getGitRepoId, getGitUserId, getHelp, getHttpUserAgent, getIgnoreFilePathOverride, getInnerEnumAllowableValues, getInputSpec, getItemsName, getLegacyDiscriminatorBehavior, getLibrary, getModelNameToSchemaCache, getMostInnerItems, getName, getOneOfAnyOfDescendants, getOpenapiGeneratorIgnoreList, getOrGenerateOperationId, getOutputDir, getParameterDataType, getProducesInfo, getReleaseNote, getSchemaAdditionalProperties, getSchemaFromBooleanOrSchema, getSingleSchemaType, getSymbolName, getTag, getTemplatingEngine, getTypeDeclaration, getUseInlineModelResolver, getUseOneOfInterfaces, getUseOpenapiNormalizer, getVersionMetadataFilename, handleConstantParams, handleMethodResponse, handleMethodResponse, handleSpecialCharacters, hasBodyParameter, hasFormParameter, importMapping, initializeSpecialCharacterMapping, inlineSchemaNameMapping, inlineSchemaOption, instantiationTypes, isDataTypeBinary, isDataTypeFile, isDataTypeString, isEnableMinimalUpdate, isEnablePostProcessFile, isHideGenerationTimestamp, isJsonMimeType, isJsonVendorMimeType, isLibrary, isParameterNameUnique, isPropertyInnerMostEnum, isRemoveEnumValuePrefix, isRemoveOperationIdPrefix, isReservedWord, isSkipOperationExample, isSkipOverwrite, isSkipSortingOperations, isStrictSpecBehavior, isXmlMimeType, languageSpecificPrimitives, lowerCamelCase, modelDocTemplateFiles, modelFilename, modelFilename, modelNameMapping, modelPackage, modelTemplateFiles, modelTestTemplateFiles, modifyFeatureSet, nameMapping, openapiGeneratorIgnoreList, openapiNormalizer, operationIdNameMapping, outputFolder, parameterNameMapping, postProcess, postProcessEnumVars, postProcessModelsEnum, postProcessParameter, postProcessSupportingFileData, postProcessWebhooksWithModels, processCompiler, processOpenAPI, processTemplatingEngine, processTestExampleData, removeImport, removeNonNameElementToCamelCase, removeNonNameElementToCamelCase, removeOption, removeSelfReferenceImports, reservedWords, reservedWordsMappings, sanitizeName, sanitizeName, sanitizeName, schemaMapping, serverVariableOverrides, setAddProps, setCircularReferences, setDocExtension, setEnableMinimalUpdate, setEnablePostProcessFile, setEnumDiscriminatorDefaultValue, setGitHost, setGitRepoId, setGitUserId, setHideGenerationTimestamp, setHttpUserAgent, setIgnoreFilePathOverride, setInputSpec, setLibrary, setNonArrayMapProperty, setOpenAPI, setParameterBooleanFlagWithCodegenProperty, setParameterEncodingValues, setParameterExamples, setParameterNullable, setReleaseNote, setRemoveEnumValuePrefix, setRemoveOperationIdPrefix, setReservedWordsLowerCase, setSkipOperationExample, setSkipOverwrite, setSkipSortingOperations, setStrictSpecBehavior, setTemplatingEngine, setUseOneOfInterfaces, shouldAddImport, shouldOverwrite, SortModelPropertiesByRequiredFlag, SortParametersByRequiredFlag, specVersionGreaterThanOrEqualTo310, supportedLibraries, supportingFiles, templateDir, templateOutputDirs, testPackage, toAllOfName, toAnyOfName, toApiImport, toApiName, toApiVarName, toArrayModelParamName, toDefaultParameterValue, toDefaultValue, toDefaultValueWithParam, toEnumDefaultValue, toEnumDefaultValue, toExamples, toGetter, toInstantiationType, toMediaTypeSchemaName, toModelImport, toModelImportMap, toOneOfName, 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, useCodegenAsMustacheParentContext, vendorExtensions, writePropertyBack
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.openapitools.codegen.CodegenConfig
additionalProperties, addOperationToGroup, apiDocFilename, apiDocTemplateFiles, apiFilename, apiFilename, apiPackage, apiTemplateFiles, apiTestFilename, apiTestTemplateFiles, cliOptions, defaultIncludes, defaultTemplatingEngine, embeddedTemplateDir, encodePath, enumNameMapping, escapeText, escapeTextWhileAllowingNewLines, fileSuffix, fromSecurity, fromServers, fromServerVariables, generateExamplePath, generatorLanguage, generatorLanguageVersion, getAddSuffixToDuplicateOperationNicknames, getDocExtension, getFeatureSet, getFilesMetadataFilename, getGeneratorMetadata, getGitHost, getGitRepoId, getGitUserId, getHelp, getHttpUserAgent, getIgnoreFilePathOverride, getInputSpec, getLibrary, getName, getOpenapiGeneratorIgnoreList, getOutputDir, getReleaseNote, getTag, getTemplatingEngine, getTypeDeclaration, getUseInlineModelResolver, getUseOpenapiNormalizer, getVersionMetadataFilename, importMapping, inlineSchemaNameMapping, inlineSchemaOption, instantiationTypes, isEnableMinimalUpdate, isEnablePostProcessFile, isHideGenerationTimestamp, isRemoveEnumValuePrefix, isRemoveOperationIdPrefix, isSkipOperationExample, isSkipOverwrite, isSkipSortingOperations, isStrictSpecBehavior, languageSpecificPrimitives, modelDocTemplateFiles, modelFilename, modelFilename, modelNameMapping, modelPackage, modelTemplateFiles, modelTestTemplateFiles, nameMapping, openapiGeneratorIgnoreList, openapiNormalizer, operationIdNameMapping, outputFolder, parameterNameMapping, postProcess, postProcessParameter, postProcessSupportingFileData, postProcessWebhooksWithModels, processCompiler, processOpenAPI, processTemplatingEngine, reservedWords, reservedWordsMappings, sanitizeName, schemaMapping, serverVariableOverrides, setDocExtension, setEnableMinimalUpdate, setEnablePostProcessFile, setGitHost, setGitRepoId, setGitUserId, setHideGenerationTimestamp, setHttpUserAgent, setIgnoreFilePathOverride, setInputSpec, setLibrary, setOpenAPI, setReleaseNote, setRemoveEnumValuePrefix, setRemoveOperationIdPrefix, setSkipOperationExample, setSkipOverwrite, setSkipSortingOperations, setStrictSpecBehavior, setTemplatingEngine, shouldOverwrite, supportedLibraries, supportingFiles, templateDir, templateOutputDirs, testPackage, toApiImport, toApiName, toApiVarName, toGetter, toModelImport, toModelImportMap, toSetter, typeMapping, unaliasSchema, updateAllModels, vendorExtensions
-
Methods inherited from interface org.openapitools.codegen.languages.features.DocumentationProviderFeatures
defaultDocumentationProvider, supportedAnnotationLibraries, supportedDocumentationProvider
-
-
-
-
Field Detail
-
DEFAULT_LIBRARY
public static final String DEFAULT_LIBRARY
- See Also:
- Constant Field Values
-
DATE_LIBRARY
public static final String DATE_LIBRARY
- See Also:
- Constant Field Values
-
SUPPORT_ASYNC
public static final String SUPPORT_ASYNC
- See Also:
- Constant Field Values
-
WITH_XML
public static final String WITH_XML
- See Also:
- Constant Field Values
-
DISABLE_HTML_ESCAPING
public static final String DISABLE_HTML_ESCAPING
- See Also:
- Constant Field Values
-
BOOLEAN_GETTER_PREFIX
public static final String BOOLEAN_GETTER_PREFIX
- See Also:
- Constant Field Values
-
IGNORE_ANYOF_IN_ENUM
public static final String IGNORE_ANYOF_IN_ENUM
- See Also:
- Constant Field Values
-
ADDITIONAL_MODEL_TYPE_ANNOTATIONS
public static final String ADDITIONAL_MODEL_TYPE_ANNOTATIONS
- See Also:
- Constant Field Values
-
ADDITIONAL_ONE_OF_TYPE_ANNOTATIONS
public static final String ADDITIONAL_ONE_OF_TYPE_ANNOTATIONS
- See Also:
- Constant Field Values
-
ADDITIONAL_ENUM_TYPE_ANNOTATIONS
public static final String ADDITIONAL_ENUM_TYPE_ANNOTATIONS
- See Also:
- Constant Field Values
-
DISCRIMINATOR_CASE_SENSITIVE
public static final String DISCRIMINATOR_CASE_SENSITIVE
- See Also:
- Constant Field Values
-
OPENAPI_NULLABLE
public static final String OPENAPI_NULLABLE
- See Also:
- Constant Field Values
-
JACKSON
public static final String JACKSON
- See Also:
- Constant Field Values
-
TEST_OUTPUT
public static final String TEST_OUTPUT
- See Also:
- Constant Field Values
-
IMPLICIT_HEADERS
public static final String IMPLICIT_HEADERS
- See Also:
- Constant Field Values
-
IMPLICIT_HEADERS_REGEX
public static final String IMPLICIT_HEADERS_REGEX
- See Also:
- Constant Field Values
-
JAVAX_PACKAGE
public static final String JAVAX_PACKAGE
- See Also:
- Constant Field Values
-
USE_JAKARTA_EE
public static final String USE_JAKARTA_EE
- See Also:
- Constant Field Values
-
CONTAINER_DEFAULT_TO_NULL
public static final String CONTAINER_DEFAULT_TO_NULL
- See Also:
- Constant Field Values
-
CAMEL_CASE_DOLLAR_SIGN
public static final String CAMEL_CASE_DOLLAR_SIGN
- See Also:
- Constant Field Values
-
USE_ONE_OF_INTERFACES
public static final String USE_ONE_OF_INTERFACES
- See Also:
- Constant Field Values
-
LOMBOK
public static final String LOMBOK
- See Also:
- Constant Field Values
-
DEFAULT_TEST_FOLDER
public static final String DEFAULT_TEST_FOLDER
- See Also:
- Constant Field Values
-
GENERATE_CONSTRUCTOR_WITH_ALL_ARGS
public static final String GENERATE_CONSTRUCTOR_WITH_ALL_ARGS
- See Also:
- Constant Field Values
-
GENERATE_BUILDERS
public static final String GENERATE_BUILDERS
- See Also:
- Constant Field Values
-
dateLibrary
protected String dateLibrary
-
supportAsync
protected boolean supportAsync
-
withXml
protected boolean withXml
-
invokerPackage
protected String invokerPackage
-
groupId
protected String groupId
-
artifactId
protected String artifactId
-
artifactVersion
protected String artifactVersion
-
artifactUrl
protected String artifactUrl
-
artifactDescription
protected String artifactDescription
-
developerName
protected String developerName
-
developerEmail
protected String developerEmail
-
developerOrganization
protected String developerOrganization
-
developerOrganizationUrl
protected String developerOrganizationUrl
-
scmConnection
protected String scmConnection
-
scmDeveloperConnection
protected String scmDeveloperConnection
-
scmUrl
protected String scmUrl
-
licenseName
protected String licenseName
-
licenseUrl
protected String licenseUrl
-
projectFolder
protected String projectFolder
-
projectTestFolder
protected String projectTestFolder
-
sourceFolder
protected String sourceFolder
-
testFolder
protected String testFolder
-
ENUM_PROPERTY_NAMING_DESC
protected static final String ENUM_PROPERTY_NAMING_DESC
- See Also:
- Constant Field Values
-
enumPropertyNaming
protected AbstractJavaCodegen.ENUM_PROPERTY_NAMING_TYPE enumPropertyNaming
-
discriminatorCaseSensitive
protected boolean discriminatorCaseSensitive
-- SETTER -- Set whether discriminator value lookup is case-sensitive or not.
-
serializableModel
protected Boolean serializableModel
-
serializeBigDecimalAsString
protected boolean serializeBigDecimalAsString
-
apiDocPath
protected String apiDocPath
-
modelDocPath
protected String modelDocPath
-
disableHtmlEscaping
protected boolean disableHtmlEscaping
-
booleanGetterPrefix
protected String booleanGetterPrefix
-
ignoreAnyOfInEnum
protected boolean ignoreAnyOfInEnum
-
parentGroupId
protected String parentGroupId
-
parentArtifactId
protected String parentArtifactId
-
parentVersion
protected String parentVersion
-
parentOverridden
protected boolean parentOverridden
-
openApiNullable
protected boolean openApiNullable
-
outputTestFolder
protected String outputTestFolder
-
documentationProvider
protected DocumentationProviderFeatures.DocumentationProvider documentationProvider
-
annotationLibrary
protected DocumentationProviderFeatures.AnnotationLibrary annotationLibrary
-
implicitHeaders
protected boolean implicitHeaders
-
implicitHeadersRegex
protected String implicitHeadersRegex
-
camelCaseDollarSign
protected boolean camelCaseDollarSign
-
useJakartaEe
protected boolean useJakartaEe
-
containerDefaultToNull
protected boolean containerDefaultToNull
-
generateConstructorWithAllArgs
protected boolean generateConstructorWithAllArgs
-
jackson
protected boolean jackson
-
generateBuilders
protected boolean generateBuilders
-
useBeanValidation
protected boolean useBeanValidation
useBeanValidation has been moved from child generators to AbstractJavaCodegen. The reason is that getBeanValidation needs it
-
-
Method Detail
-
processOpts
public void processOpts()
- Specified by:
processOptsin interfaceCodegenConfig- Overrides:
processOptsin classDefaultCodegen
-
postProcessAllModels
public Map<String,ModelsMap> postProcessAllModels(Map<String,ModelsMap> objs)
Analyse and post process all Models.- Specified by:
postProcessAllModelsin interfaceCodegenConfig- Overrides:
postProcessAllModelsin classDefaultCodegen- Parameters:
objs- the models map.- Returns:
- the processed models map.
-
isConstructorWithAllArgsAllowed
protected boolean isConstructorWithAllArgsAllowed(CodegenModel codegenModel)
trigger the generation of all arguments constructor or not. It avoids generating the same constructor twice.- Returns:
- true if an allArgConstructor must be generated
-
applyJavaxPackage
protected void applyJavaxPackage()
-
applyJakartaPackage
protected void applyJakartaPackage()
-
escapeReservedWord
public String escapeReservedWord(String name)
Description copied from class:DefaultCodegenReturn the escaped name of the reserved word- Specified by:
escapeReservedWordin interfaceCodegenConfig- Overrides:
escapeReservedWordin classDefaultCodegen- Parameters:
name- the name to be escaped- Returns:
- the escaped reserved word
throws Runtime exception as reserved word is not allowed (default behavior)
-
apiFileFolder
public String apiFileFolder()
- Specified by:
apiFileFolderin interfaceCodegenConfig- Overrides:
apiFileFolderin classDefaultCodegen
-
apiTestFileFolder
public String apiTestFileFolder()
- Specified by:
apiTestFileFolderin interfaceCodegenConfig- Overrides:
apiTestFileFolderin classDefaultCodegen
-
modelTestFileFolder
public String modelTestFileFolder()
- Specified by:
modelTestFileFolderin interfaceCodegenConfig- Overrides:
modelTestFileFolderin classDefaultCodegen
-
modelFileFolder
public String modelFileFolder()
- Specified by:
modelFileFolderin interfaceCodegenConfig- Overrides:
modelFileFolderin classDefaultCodegen
-
apiDocFileFolder
public String apiDocFileFolder()
- Specified by:
apiDocFileFolderin interfaceCodegenConfig- Overrides:
apiDocFileFolderin classDefaultCodegen
-
modelDocFileFolder
public String modelDocFileFolder()
- Specified by:
modelDocFileFolderin interfaceCodegenConfig- Overrides:
modelDocFileFolderin classDefaultCodegen
-
toApiDocFilename
public String toApiDocFilename(String name)
Description copied from class:DefaultCodegenReturn the file name of the Api Documentation- Specified by:
toApiDocFilenamein interfaceCodegenConfig- Overrides:
toApiDocFilenamein classDefaultCodegen- Parameters:
name- the file name of the Api- Returns:
- the file name of the Api
-
toModelDocFilename
public String toModelDocFilename(String name)
Description copied from class:DefaultCodegenReturn the capitalized file name of the model documentation- Specified by:
toModelDocFilenamein interfaceCodegenConfig- Overrides:
toModelDocFilenamein classDefaultCodegen- Parameters:
name- the model name- Returns:
- the file name of the model
-
toApiTestFilename
public String toApiTestFilename(String name)
Description copied from class:DefaultCodegenReturn the file name of the Api Test- Specified by:
toApiTestFilenamein interfaceCodegenConfig- Overrides:
toApiTestFilenamein classDefaultCodegen- Parameters:
name- the file name of the Api- Returns:
- the file name of the Api
-
toModelTestFilename
public String toModelTestFilename(String name)
Description copied from class:DefaultCodegenReturn the capitalized file name of the model test- Specified by:
toModelTestFilenamein interfaceCodegenConfig- Overrides:
toModelTestFilenamein classDefaultCodegen- Parameters:
name- the model name- Returns:
- the file name of the model
-
toApiFilename
public String toApiFilename(String name)
Description copied from class:DefaultCodegenReturn the file name of the Api- Specified by:
toApiFilenamein interfaceCodegenConfig- Overrides:
toApiFilenamein classDefaultCodegen- Parameters:
name- the file name of the Api- Returns:
- the file name of the Api
-
toVarName
public String toVarName(String name)
Description copied from class:DefaultCodegenReturn the variable name by removing invalid characters and proper escaping if it's a reserved word.- Overrides:
toVarNamein classDefaultCodegen- Parameters:
name- the variable name- Returns:
- the sanitized variable name
-
toParamName
public String toParamName(String name)
Description copied from class:DefaultCodegenReturn the parameter name by removing invalid characters and proper escaping if it's a reserved word.- Specified by:
toParamNamein interfaceCodegenConfig- Overrides:
toParamNamein classDefaultCodegen- Parameters:
name- Codegen property object- Returns:
- the sanitized parameter name
-
toModelName
public String toModelName(String name)
Description copied from class:DefaultCodegenConverts 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:
toModelNamein interfaceCodegenConfig- Overrides:
toModelNamein classDefaultCodegen- Parameters:
name- the name of the model- Returns:
- capitalized model name
-
toModelFilename
public String toModelFilename(String name)
Description copied from class:DefaultCodegenReturn the capitalized file name of the model- Specified by:
toModelFilenamein interfaceCodegenConfig- Overrides:
toModelFilenamein classDefaultCodegen- Parameters:
name- the model name- Returns:
- the file name of the model
-
getTypeDeclaration
public String getTypeDeclaration(io.swagger.v3.oas.models.media.Schema p)
Description copied from class:DefaultCodegenOutput the language-specific type declaration of the property.- Specified by:
getTypeDeclarationin interfaceCodegenConfig- Overrides:
getTypeDeclarationin classDefaultCodegen- Parameters:
p- property schema- Returns:
- a string presentation of the property type
-
toArrayDefaultValue
public String toArrayDefaultValue(CodegenProperty cp, io.swagger.v3.oas.models.media.Schema schema)
Return the default value of array propertyReturn null if there's no default value. Any non-null value will cause {{#defaultValue} check to pass.
- Parameters:
cp- Codegen propertyschema- Property schema- Returns:
- string presentation of the default value of the property
-
toDefaultValue
public String toDefaultValue(CodegenProperty cp, io.swagger.v3.oas.models.media.Schema schema)
Description copied from class:DefaultCodegenReturn the default value of the propertyReturn null if you do NOT want a default value. Any non-null value will cause {{#defaultValue} check to pass.
- Overrides:
toDefaultValuein classDefaultCodegen- Parameters:
cp- Codegen propertyschema- Property schema- Returns:
- string presentation of the default value of the property
-
toDefaultParameterValue
public String toDefaultParameterValue(io.swagger.v3.oas.models.media.Schema<?> schema)
Description copied from class:DefaultCodegenReturn the default value of the parameterReturn null if you do NOT want a default value. Any non-null value will cause {{#defaultValue} check to pass.
- Overrides:
toDefaultParameterValuein classDefaultCodegen- Parameters:
schema- Parameter schema- Returns:
- string presentation of the default value of the parameter
-
setParameterExampleValue
public void setParameterExampleValue(CodegenParameter codegenParameter, io.swagger.v3.oas.models.parameters.Parameter parameter)
Return the example value of the parameter. Overrides the setParameterExampleValue(CodegenParameter, Parameter) method in DefaultCodegen to always call setParameterExampleValue(CodegenParameter) in this class, which adds single quotes around strings from the x-example property.- Overrides:
setParameterExampleValuein classDefaultCodegen- Parameters:
codegenParameter- Codegen parameterparameter- Parameter
-
setParameterExampleValue
public void setParameterExampleValue(CodegenParameter codegenParameter, io.swagger.v3.oas.models.parameters.RequestBody requestBody)
Return the example value of the parameter. Overrides the parent method in DefaultCodegen to not set examples on complex models, as they don't compile properly.- Overrides:
setParameterExampleValuein classDefaultCodegen- Parameters:
codegenParameter- Codegen parameterrequestBody- Request body
-
setParameterExampleValue
public void setParameterExampleValue(CodegenParameter p)
Description copied from class:DefaultCodegenReturn the example value of the parameter.- Overrides:
setParameterExampleValuein classDefaultCodegen- Parameters:
p- Codegen parameter
-
toExampleValue
public String toExampleValue(io.swagger.v3.oas.models.media.Schema p)
Description copied from class:DefaultCodegenReturn the example value of the propertyThis method should be overridden in the generator to meet its requirement.
- Overrides:
toExampleValuein classDefaultCodegen- Parameters:
p- Property schema- Returns:
- string presentation of the example value of the property
-
getSchemaType
public String getSchemaType(io.swagger.v3.oas.models.media.Schema p)
Description copied from class:DefaultCodegenreturns the OpenAPI type for the property. Use getAlias to handle $ref of primitive type- Overrides:
getSchemaTypein classDefaultCodegen- Parameters:
p- property schema- Returns:
- string presentation of the type
-
toOperationId
public String toOperationId(String operationId)
Description copied from class:DefaultCodegenReturn the operation ID (method name)- Overrides:
toOperationIdin classDefaultCodegen- Parameters:
operationId- operation ID- Returns:
- the sanitized method name
-
fromModel
public CodegenModel fromModel(String name, io.swagger.v3.oas.models.media.Schema model)
Description copied from class:DefaultCodegenConvert OAS Model object to Codegen Model object.- Specified by:
fromModelin interfaceCodegenConfig- Overrides:
fromModelin classDefaultCodegen- Parameters:
name- the name of the modelmodel- OAS Model object- Returns:
- Codegen Model object
-
postProcessModelProperty
public void postProcessModelProperty(CodegenModel model, CodegenProperty property)
- Specified by:
postProcessModelPropertyin interfaceCodegenConfig- Overrides:
postProcessModelPropertyin classDefaultCodegen
-
postProcessResponseWithProperty
public void postProcessResponseWithProperty(CodegenResponse response, CodegenProperty property)
- Specified by:
postProcessResponseWithPropertyin interfaceCodegenConfig- Overrides:
postProcessResponseWithPropertyin classDefaultCodegen
-
removeAnnotations
public String removeAnnotations(String dataType)
Remove annotations from the given data type string.For example:
@Min(0) @Max(10)Integer->Integer@Pattern(regexp = "^[a-z]$")String>->StringList<@Pattern(regexp = "^[a-z]$")String>" -> "List<String>"List<@Valid Pet>" -> "List<Pet>"
- Parameters:
dataType- the data type string- Returns:
- the data type string without annotations
-
sanitizeDataType
public String sanitizeDataType(String dataType)
Sanitize the datatype. This will remove all characters except alphanumeric ones. It will also first use {removeAnnotations(String)} to remove the annotations added to the datatype- Parameters:
dataType- the data type string- Returns:
- the data type string without annotations and any characters except alphanumeric ones
-
postProcessModels
public ModelsMap postProcessModels(ModelsMap objs)
- Specified by:
postProcessModelsin interfaceCodegenConfig- Overrides:
postProcessModelsin classDefaultCodegen
-
postProcessOperationsWithModels
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels)
- Specified by:
postProcessOperationsWithModelsin interfaceCodegenConfig- Overrides:
postProcessOperationsWithModelsin classDefaultCodegen
-
preprocessOpenAPI
public void preprocessOpenAPI(io.swagger.v3.oas.models.OpenAPI openAPI)
- Specified by:
preprocessOpenAPIin interfaceCodegenConfig- Overrides:
preprocessOpenAPIin classDefaultCodegen
-
needToImport
protected boolean needToImport(String type)
Description copied from class:DefaultCodegenCheck the type to see if it needs import the library/module/package- Overrides:
needToImportin classDefaultCodegen- Parameters:
type- name of the type- Returns:
- true if the library/module/package of the corresponding type needs to be imported
-
toEnumName
public String toEnumName(CodegenProperty property)
Description copied from class:DefaultCodegenReturn the Enum name (e.g. StatusEnum given 'status')- Overrides:
toEnumNamein classDefaultCodegen- Parameters:
property- Codegen property- Returns:
- the Enum name
-
toEnumVarName
public String toEnumVarName(String value, String datatype)
Description copied from class:DefaultCodegenReturn the sanitized variable name for enum- Overrides:
toEnumVarNamein classDefaultCodegen- Parameters:
value- enum variable namedatatype- data type- Returns:
- the sanitized variable name for enum
-
toEnumValue
public String toEnumValue(String value, String datatype)
Description copied from class:DefaultCodegenReturn the enum value in the language specified format e.g. status becomes "status"- Overrides:
toEnumValuein classDefaultCodegen- Parameters:
value- enum variable namedatatype- data type- Returns:
- the sanitized value for enum
-
fromOperation
public CodegenOperation fromOperation(String path, String httpMethod, io.swagger.v3.oas.models.Operation operation, List<io.swagger.v3.oas.models.servers.Server> servers)
Description copied from class:DefaultCodegenConvert OAS Operation object to Codegen Operation object- Specified by:
fromOperationin interfaceCodegenConfig- Overrides:
fromOperationin classDefaultCodegen- Parameters:
path- the path of the operationhttpMethod- HTTP methodoperation- OAS operation objectservers- list of servers- Returns:
- Codegen Operation object
-
setOutputDir
public void setOutputDir(String dir)
- Specified by:
setOutputDirin interfaceCodegenConfig- Overrides:
setOutputDirin classDefaultCodegen
-
getOutputTestFolder
public String getOutputTestFolder()
-
getDocumentationProvider
public DocumentationProviderFeatures.DocumentationProvider getDocumentationProvider()
- Specified by:
getDocumentationProviderin interfaceDocumentationProviderFeatures
-
setDocumentationProvider
public void setDocumentationProvider(DocumentationProviderFeatures.DocumentationProvider documentationProvider)
- Specified by:
setDocumentationProviderin interfaceDocumentationProviderFeatures
-
getAnnotationLibrary
public DocumentationProviderFeatures.AnnotationLibrary getAnnotationLibrary()
- Specified by:
getAnnotationLibraryin interfaceDocumentationProviderFeatures
-
setAnnotationLibrary
public void setAnnotationLibrary(DocumentationProviderFeatures.AnnotationLibrary annotationLibrary)
- Specified by:
setAnnotationLibraryin interfaceDocumentationProviderFeatures
-
escapeQuotationMark
public String escapeQuotationMark(String input)
Description copied from class:DefaultCodegenEscape single and/or double quote to avoid code injection- Specified by:
escapeQuotationMarkin interfaceCodegenConfig- Overrides:
escapeQuotationMarkin classDefaultCodegen- Parameters:
input- String to be cleaned up- Returns:
- string with quotation mark removed or escaped
-
escapeUnsafeCharacters
public String escapeUnsafeCharacters(String input)
Description copied from class:DefaultCodegenoverride with any special text escaping logic to handle unsafe characters so as to avoid code injection- Specified by:
escapeUnsafeCharactersin interfaceCodegenConfig- Overrides:
escapeUnsafeCharactersin classDefaultCodegen- Parameters:
input- String to be cleaned up- Returns:
- string with unsafe characters removed or escaped
-
toRegularExpression
public String toRegularExpression(String pattern)
Description copied from class:DefaultCodegenReturn the regular expression/JSON schema pattern (http://json-schema.org/latest/json-schema-validation.html#anchor33)- Overrides:
toRegularExpressionin classDefaultCodegen- Parameters:
pattern- the pattern (regular expression)- Returns:
- properly-escaped pattern
-
toBooleanGetter
public String toBooleanGetter(String name)
Output the Getter name for boolean property, e.g. isActive- Specified by:
toBooleanGetterin interfaceCodegenConfig- Overrides:
toBooleanGetterin classDefaultCodegen- Parameters:
name- the name of the property- Returns:
- getter name based on naming convention
-
sanitizeTag
public String sanitizeTag(String tag)
Description copied from class:DefaultCodegenSanitize tag- Specified by:
sanitizeTagin interfaceCodegenConfig- Overrides:
sanitizeTagin classDefaultCodegen- Parameters:
tag- Tag- Returns:
- Sanitized tag
-
getterAndSetterCapitalize
public String getterAndSetterCapitalize(String name)
Camelize the method name of the getter and setter- Overrides:
getterAndSetterCapitalizein classDefaultCodegen- Parameters:
name- string to be camelized- Returns:
- Camelized string
-
postProcessFile
public void postProcessFile(File file, String fileType)
Description copied from class:DefaultCodegenPost-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-file", "openapi-generator-ignore", "openapi-generator-version"TODO: store these values in enum instead
- Specified by:
postProcessFilein interfaceCodegenConfig- Overrides:
postProcessFilein classDefaultCodegen- Parameters:
file- file to be processedfileType- file type
-
addAdditionPropertiesToCodeGenModel
protected void addAdditionPropertiesToCodeGenModel(CodegenModel codegenModel, io.swagger.v3.oas.models.media.Schema schema)
Description copied from class:DefaultCodegenHandle the model for the 'additionalProperties' keyword in the OAS schema.- Overrides:
addAdditionPropertiesToCodeGenModelin classDefaultCodegen- Parameters:
codegenModel- The codegen representation of the schema.schema- The input OAS schema.
-
findByName
protected Optional<CodegenProperty> findByName(String name, List<CodegenProperty> properties)
Search for property byCodegenProperty.name- Parameters:
name- name to search forproperties- list of properties- Returns:
- either found property or
Optional.empty()if nothing has been found
-
handleImplicitHeaders
protected void handleImplicitHeaders(CodegenOperation operation)
This method removes all implicit header parameters from the list of parameters- Parameters:
operation- - operation to be processed
-
addImportsToOneOfInterface
public void addImportsToOneOfInterface(List<Map<String,String>> imports)
- Overrides:
addImportsToOneOfInterfacein classDefaultCodegen
-
getSupportedVendorExtensions
public List<VendorExtension> getSupportedVendorExtensions()
- Specified by:
getSupportedVendorExtensionsin interfaceCodegenConfig- Overrides:
getSupportedVendorExtensionsin classDefaultCodegen
-
isAddNullableImports
public boolean isAddNullableImports(CodegenModel cm, boolean addImports, CodegenProperty var)
-
addImports
public static void addImports(List<Map<String,String>> imports, CodegenModel cm, Map<String,String> imports2Classnames)
-
isTypeErasedGenerics
public boolean isTypeErasedGenerics()
- Specified by:
isTypeErasedGenericsin interfaceCodegenConfig- Overrides:
isTypeErasedGenericsin classDefaultCodegen
-
setEnumPropertyNaming
public void setEnumPropertyNaming(String enumPropertyNamingType)
Sets the naming convention for Java enum properties- Parameters:
enumPropertyNamingType- The string representation of the naming convention, as defined byAbstractJavaCodegen.ENUM_PROPERTY_NAMING_TYPE
-
-