Class AbstractCSharpCodegen
- java.lang.Object
-
- org.openapitools.codegen.DefaultCodegen
-
- org.openapitools.codegen.languages.AbstractCSharpCodegen
-
- All Implemented Interfaces:
CodegenConfig
- Direct Known Subclasses:
AspNetServerCodegen
,CSharpClientCodegen
,CSharpFunctionsServerCodegen
,CSharpReducedClientCodegen
public abstract class AbstractCSharpCodegen extends DefaultCodegen implements CodegenConfig
-
-
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, 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, outputFolder, parameterNameMapping, prependFormOrBodyParameters, releaseNote, removeEnumValuePrefix, removeOperationIdPrefix, removeOperationIdPrefixCount, removeOperationIdPrefixDelimiter, reservedWords, reservedWordsMappings, schemaMapping, serverVariables, skipOperationExample, skipOverwrite, sortModelPropertiesByRequiredFlag, sortParamsByRequiredFlag, specialCharReplacements, strictSpecBehavior, supportedLibraries, supportingFiles, supportsAdditionalPropertiesWithComposedSchema, supportsInheritance, supportsMixins, supportsMultipleInheritance, templateDir, templateOutputDirs, testPackage, trueSchema, typeAliases, typeMapping, useOneOfInterfaces, vendorExtensions, versionMetadataFilename, XML_MIME_PATTERN
-
-
Constructor Summary
Constructors Constructor Description AbstractCSharpCodegen()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected com.google.common.collect.ImmutableMap.Builder<String,com.samskivert.mustache.Mustache.Lambda>
addMustacheLambdas()
Preset map builder with commonly used Mustache lambdas.protected void
addParentFromContainer(CodegenModel model, io.swagger.v3.oas.models.media.Schema schema)
String
addRegularExpressionDelimiter(String pattern)
If the pattern misses the delimiter, add "/" to the beginning and end Otherwise, return the original patternString
apiFileFolder()
String
apiTestFileFolder()
protected List<Map<String,Object>>
buildEnumVars(List<Object> values, String dataType)
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
escapeReservedWord(CodegenModel model, String name)
String
escapeUnsafeCharacters(String input)
override with any special text escaping logic to handle unsafe characters so as to avoid code injectionGeneratorLanguage
generatorLanguage()
CodegenConstants.ENUM_PROPERTY_NAMING_TYPE
getEnumPropertyNaming()
String
getInterfacePrefix()
boolean
getNullableReferencesTypes()
String
getNullableType(io.swagger.v3.oas.models.media.Schema p, String type)
protected Set<String>
getNullableTypes()
Deprecated.String
getSchemaType(io.swagger.v3.oas.models.media.Schema p)
returns the OpenAPI type for the property.String
getTypeDeclaration(io.swagger.v3.oas.models.media.Schema p)
Output the language-specific type declaration of the property.boolean
getUseSourceGeneration()
protected Set<String>
getValueTypes()
boolean
isDataTypeString(String dataType)
checks if the data should be classified as "string" in enum e.g.protected boolean
isReservedWord(String word)
boolean
isSupportNullable()
protected boolean
isValueType(CodegenProperty var)
Return true if the property being passed is a C# value typeString
modelFileFolder()
String
modelTestFileFolder()
protected void
patchProperty(Map<String,CodegenModel> enumRefs, CodegenModel model, CodegenProperty property)
protected void
patchVendorExtensionNullableValueType(CodegenParameter parameter)
protected void
patchVendorExtensionNullableValueTypeLegacy(CodegenParameter parameter)
This is the same as patchVendorExtensionNullableValueType except it uses the deprecated getNullableTypes propertyMap<String,ModelsMap>
postProcessAllModels(Map<String,ModelsMap> objs)
Invoked byDefaultGenerator
after all models have been post-processed, allowing for a last pass of codegen-specific model cleanup.void
postProcessFile(File file, String fileType)
Post-process the auto-generated file, e.g.void
postProcessModelProperty(CodegenModel model, CodegenProperty property)
ModelsMap
postProcessModels(ModelsMap objs)
OperationsMap
postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels)
void
postProcessParameter(CodegenParameter parameter)
void
postProcessPattern(String pattern, Map<String,Object> vendorExtensions)
protected void
processOperation(CodegenOperation operation)
void
processOpts()
protected void
removePropertiesDeclaredInComposedTypes(Map<String,ModelsMap> objs, CodegenModel model, List<CodegenProperty> composedProperties)
void
setDateFormat(String dateFormat)
void
setDateTimeFormat(String dateTimeFormat)
void
setEnumNameSuffix(String enumNameSuffix)
void
setEnumPropertyNaming(String enumPropertyNamingType)
void
setEnumValueSuffix(String enumValueSuffix)
void
setInterfacePrefix(String interfacePrefix)
void
setLicenseName(String licenseName)
void
setLicenseUrl(String licenseUrl)
void
setNetCoreProjectFileFlag(boolean flag)
void
setNullableReferenceTypes(Boolean nullReferenceTypesFlag)
void
setOptionalMethodArgumentFlag(boolean flag)
void
setPackageAuthors(String packageAuthors)
void
setPackageCompany(String packageCompany)
void
setPackageCopyright(String packageCopyright)
void
setPackageDescription(String packageDescription)
void
setPackageName(String packageName)
void
setPackageProductName(String packageProductName)
void
setPackageTitle(String packageTitle)
void
setPackageVersion(String packageVersion)
void
setParameterExampleValue(CodegenParameter p)
Return the example value of the parameter.void
setReturnICollection(boolean returnICollection)
void
setSourceFolder(String sourceFolder)
void
setSupportNullable(boolean supportNullable)
void
setTestFolder(String testFolder)
protected void
setTypeMapping()
void
setUseCollection(boolean useCollection)
void
setUseSourceGeneration(Boolean useSourceGeneration)
void
setZeroBasedEnums(Boolean zeroBasedEnums)
String
testPackageName()
String
toApiTestFilename(String name)
Return the file name of the Api TestString
toDefaultValue(io.swagger.v3.oas.models.media.Schema p)
Return the default value of the propertyString
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 name, String datatype)
Return the sanitized variable name for enumString
toExampleValue(io.swagger.v3.oas.models.media.Schema p)
Return the example 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
toModelTestFilename(String name)
Return the capitalized file name of the model testString
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
toRegularExpression(String pattern)
Return the regular expression/JSON schema pattern (http://json-schema.org/latest/json-schema-validation.html#anchor33)String
toVarName(String name)
Return the variable name by removing invalid characters and proper escaping if it's a reserved word.protected void
updateCodegenParameterEnum(CodegenParameter parameter, CodegenModel model)
protected void
updateCodegenParameterEnumLegacy(CodegenParameter parameter, CodegenModel model)
void
updateCodegenPropertyEnum(CodegenProperty var)
Update codegen property's enum by adding "enumVars" (with name and value)void
useDateTimeOffset(boolean flag)
-
Methods inherited from class org.openapitools.codegen.DefaultCodegen
addAdditionPropertiesToCodeGenModel, addBodyModelSchema, addHeaders, addImport, addImport, addImport, addImports, addImports, addImports, addImportsForPropertyType, addImportsToOneOfInterface, additionalProperties, addOneOfInterfaceModel, addOneOfNameExtension, addOperationToGroup, addOption, addOption, addParentContainer, addProperties, addRequiredVarsMap, addSwitch, addVars, addVars, addVarsRequiredVarsAdditionalProps, apiDocFileFolder, apiDocFilename, apiDocTemplateFiles, apiFilename, apiFilename, apiPackage, apiTemplateFiles, apiTestFilename, apiTestTemplateFiles, buildLibraryCliOption, cliOptions, convertPropertyToBoolean, convertPropertyToBooleanAndWriteBack, createDiscriminator, defaultIncludes, defaultTemplatingEngine, embeddedTemplateDir, encodePath, enumNameMapping, escapeText, escapeTextWhileAllowingNewLines, fileSuffix, findCommonPrefixOfVars, findMethodResponse, fromCallback, fromFormProperty, fromModel, fromOperation, fromParameter, fromProperty, fromProperty, fromProperty, fromRequestBody, fromRequestBodyToFormParameters, fromResponse, fromSecurity, fromServers, fromServerVariables, generateExamplePath, generateJSONSpecFile, generateYAMLSpecFile, generatorLanguageVersion, 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, getOpenAPIGeneratorIgnoreList, getOrGenerateOperationId, getOutputDir, getParameterDataType, getPrependFormOrBodyParameters, getProducesInfo, getReleaseNote, getRemoveOperationIdPrefixCount, getRemoveOperationIdPrefixDelimiter, getSchemaAdditionalProperties, getSchemaFromBooleanOrSchema, getSchemaItems, getSingleSchemaType, getSortModelPropertiesByRequiredFlag, getSortParamsByRequiredFlag, getSupportedVendorExtensions, getSymbolName, getTag, getTemplatingEngine, getterAndSetterCapitalize, getTypeDeclaration, getUseInlineModelResolver, getUseOneOfInterfaces, getUseOpenAPINormalizer, getVersionMetadataFilename, handleConstantParams, handleMethodResponse, handleMethodResponse, handleSpecialCharacters, hasBodyParameter, hasFormParameter, importMapping, initializeSpecialCharacterMapping, inlineSchemaNameMapping, inlineSchemaOption, instantiationTypes, isAnyTypeSchema, isDataTypeBinary, isDataTypeFile, isEnableMinimalUpdate, isEnablePostProcessFile, isHideGenerationTimestamp, isJsonMimeType, isJsonVendorMimeType, isLibrary, isParameterNameUnique, isPropertyInnerMostEnum, isRemoveEnumValuePrefix, isRemoveOperationIdPrefix, isSkipOperationExample, isSkipOverwrite, isStrictSpecBehavior, isXmlMimeType, languageSpecificPrimitives, lowerCamelCase, modelDocFileFolder, modelDocTemplateFiles, modelFilename, modelFilename, modelNameMapping, modelPackage, modelTemplateFiles, modelTestTemplateFiles, modifyFeatureSet, nameMapping, needToImport, openapiGeneratorIgnoreList, openapiNormalizer, outputFolder, parameterNameMapping, postProcess, postProcessEnumVars, postProcessModelsEnum, postProcessResponseWithProperty, postProcessSupportingFileData, postProcessWebhooksWithModels, preprocessOpenAPI, processCompiler, processOpenAPI, processTemplatingEngine, processTestExampleData, removeImport, removeNonNameElementToCamelCase, removeNonNameElementToCamelCase, removeOption, removeSelfReferenceImports, reservedWords, reservedWordsMappings, sanitizeName, sanitizeName, sanitizeName, sanitizeTag, schemaMapping, serverVariableOverrides, setAddProps, setAllowUnicodeIdentifiers, setApiNamePrefix, setApiNameSuffix, setApiPackage, setAutosetConstants, 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, setParameterNullable, setPrependFormOrBodyParameters, setReleaseNote, setRemoveEnumValuePrefix, setRemoveOperationIdPrefix, setRemoveOperationIdPrefixCount, setRemoveOperationIdPrefixDelimiter, setReservedWordsLowerCase, setSkipOperationExample, setSkipOverwrite, setSortModelPropertiesByRequiredFlag, setSortParamsByRequiredFlag, setStrictSpecBehavior, setTemplateDir, setTemplatingEngine, setUseOneOfInterfaces, setVersionMetadataFilename, shouldAddImport, shouldOverwrite, specVersionGreaterThanOrEqualTo310, supportedLibraries, supportingFiles, templateDir, templateOutputDirs, testPackage, toAllOfName, toAnyOfName, toApiDocFilename, toApiFilename, toApiImport, toApiName, toApiVarName, toArrayModelParamName, toBooleanGetter, toDefaultParameterValue, toDefaultParameterValue, toDefaultValue, toDefaultValueWithParam, toEnumDefaultValue, toExamples, toGetter, toMediaTypeSchemaName, toModelDocFilename, toModelImport, toModelImportMap, toOneOfName, toSetter, toTestCaseName, typeMapping, unaliasPropertySchema, unaliasSchema, updateAllModels, 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
-
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, apiDocFileFolder, apiDocFilename, apiDocTemplateFiles, apiFilename, apiFilename, apiPackage, apiTemplateFiles, apiTestFilename, apiTestTemplateFiles, cliOptions, defaultIncludes, defaultTemplatingEngine, embeddedTemplateDir, encodePath, enumNameMapping, escapeText, escapeTextWhileAllowingNewLines, fileSuffix, fromModel, fromOperation, fromSecurity, fromServers, fromServerVariables, generateExamplePath, generatorLanguageVersion, getAddSuffixToDuplicateOperationNicknames, getDocExtension, getFeatureSet, getFilesMetadataFilename, getGeneratorMetadata, getGitHost, getGitRepoId, getGitUserId, getHelp, getHttpUserAgent, getIgnoreFilePathOverride, getInputSpec, getLibrary, getName, getOpenAPIGeneratorIgnoreList, getOutputDir, getReleaseNote, getSupportedVendorExtensions, getTag, getTemplatingEngine, getTypeDeclaration, getUseInlineModelResolver, getUseOpenAPINormalizer, getVersionMetadataFilename, importMapping, inlineSchemaNameMapping, inlineSchemaOption, instantiationTypes, isEnableMinimalUpdate, isEnablePostProcessFile, isHideGenerationTimestamp, isRemoveEnumValuePrefix, isRemoveOperationIdPrefix, isSkipOperationExample, isSkipOverwrite, isStrictSpecBehavior, languageSpecificPrimitives, modelDocFileFolder, modelDocTemplateFiles, modelFilename, modelFilename, modelNameMapping, modelPackage, modelTemplateFiles, modelTestTemplateFiles, nameMapping, openapiGeneratorIgnoreList, openapiNormalizer, outputFolder, parameterNameMapping, postProcess, postProcessResponseWithProperty, postProcessSupportingFileData, postProcessWebhooksWithModels, preprocessOpenAPI, processCompiler, processOpenAPI, processTemplatingEngine, reservedWords, reservedWordsMappings, sanitizeName, sanitizeTag, schemaMapping, serverVariableOverrides, setDocExtension, setEnableMinimalUpdate, setEnablePostProcessFile, setGitHost, setGitRepoId, setGitUserId, setHideGenerationTimestamp, setHttpUserAgent, setIgnoreFilePathOverride, setInputSpec, setLibrary, setOpenAPI, setOutputDir, setReleaseNote, setRemoveEnumValuePrefix, setRemoveOperationIdPrefix, setSkipOperationExample, setSkipOverwrite, setStrictSpecBehavior, setTemplatingEngine, shouldOverwrite, supportedLibraries, supportingFiles, templateDir, templateOutputDirs, testPackage, toApiDocFilename, toApiFilename, toApiImport, toApiName, toApiVarName, toBooleanGetter, toGetter, toModelDocFilename, toModelImport, toModelImportMap, toSetter, typeMapping, unaliasSchema, updateAllModels, vendorExtensions
-
-
-
-
Field Detail
-
optionalAssemblyInfoFlag
protected boolean optionalAssemblyInfoFlag
-
optionalEmitDefaultValuesFlag
protected boolean optionalEmitDefaultValuesFlag
-
conditionalSerialization
protected boolean conditionalSerialization
-
optionalProjectFileFlag
protected boolean optionalProjectFileFlag
-
optionalMethodArgumentFlag
protected boolean optionalMethodArgumentFlag
-
useDateTimeOffsetFlag
protected boolean useDateTimeOffsetFlag
-
useCollection
protected boolean useCollection
-
returnICollection
protected boolean returnICollection
-
netCoreProjectFileFlag
protected boolean netCoreProjectFileFlag
-
nullReferenceTypesFlag
protected boolean nullReferenceTypesFlag
-
useSourceGeneration
protected boolean useSourceGeneration
-
modelPropertyNaming
protected String modelPropertyNaming
-
licenseUrl
protected String licenseUrl
-
licenseName
protected String licenseName
-
packageVersion
protected String packageVersion
-
packageName
protected String packageName
-
packageTitle
protected String packageTitle
-
packageProductName
protected String packageProductName
-
packageDescription
protected String packageDescription
-
packageCompany
protected String packageCompany
-
packageCopyright
protected String packageCopyright
-
packageAuthors
protected String packageAuthors
-
DATE_FORMAT
public static final String DATE_FORMAT
- See Also:
- Constant Field Values
-
dateFormat
protected String dateFormat
-
DATETIME_FORMAT
public static final String DATETIME_FORMAT
- See Also:
- Constant Field Values
-
dateTimeFormat
protected String dateTimeFormat
-
interfacePrefix
protected String interfacePrefix
-
enumNameSuffix
protected String enumNameSuffix
-
enumValueSuffix
protected String enumValueSuffix
-
sourceFolder
protected String sourceFolder
-
invalidNamePrefix
protected String invalidNamePrefix
-
enumPropertyNaming
protected CodegenConstants.ENUM_PROPERTY_NAMING_TYPE enumPropertyNaming
-
testFolder
protected String testFolder
-
supportNullable
protected boolean supportNullable
-
zeroBasedEnums
protected Boolean zeroBasedEnums
-
zeroBasedEnumVendorExtension
protected static final String zeroBasedEnumVendorExtension
- See Also:
- Constant Field Values
-
-
Method Detail
-
setReturnICollection
public void setReturnICollection(boolean returnICollection)
-
setUseCollection
public void setUseCollection(boolean useCollection)
-
setOptionalMethodArgumentFlag
public void setOptionalMethodArgumentFlag(boolean flag)
-
setNetCoreProjectFileFlag
public void setNetCoreProjectFileFlag(boolean flag)
-
useDateTimeOffset
public void useDateTimeOffset(boolean flag)
-
addParentFromContainer
protected void addParentFromContainer(CodegenModel model, io.swagger.v3.oas.models.media.Schema schema)
- Overrides:
addParentFromContainer
in classDefaultCodegen
-
processOpts
public void processOpts()
- Specified by:
processOpts
in interfaceCodegenConfig
- Overrides:
processOpts
in classDefaultCodegen
-
addMustacheLambdas
protected com.google.common.collect.ImmutableMap.Builder<String,com.samskivert.mustache.Mustache.Lambda> addMustacheLambdas()
Description copied from class:DefaultCodegen
Preset map builder with commonly used Mustache lambdas. To extend the map, override addMustacheLambdas(), call parent method first and then add additional lambdas to the returned builder. If common lambdas are not desired, override addMustacheLambdas() method and return empty builder.- Overrides:
addMustacheLambdas
in classDefaultCodegen
- Returns:
- preinitialized map with common lambdas
-
postProcessModelProperty
public void postProcessModelProperty(CodegenModel model, CodegenProperty property)
- Specified by:
postProcessModelProperty
in interfaceCodegenConfig
- Overrides:
postProcessModelProperty
in classDefaultCodegen
-
postProcessModels
public ModelsMap postProcessModels(ModelsMap objs)
- Specified by:
postProcessModels
in interfaceCodegenConfig
- Overrides:
postProcessModels
in classDefaultCodegen
-
postProcessAllModels
public Map<String,ModelsMap> postProcessAllModels(Map<String,ModelsMap> objs)
Invoked byDefaultGenerator
after all models have been post-processed, allowing for a last pass of codegen-specific model cleanup.- Specified by:
postProcessAllModels
in interfaceCodegenConfig
- Overrides:
postProcessAllModels
in classDefaultCodegen
- Parameters:
objs
- Current state of codegen object model.- Returns:
- An in-place modified state of the codegen object model.
-
removePropertiesDeclaredInComposedTypes
protected void removePropertiesDeclaredInComposedTypes(Map<String,ModelsMap> objs, CodegenModel model, List<CodegenProperty> composedProperties)
-
patchProperty
protected void patchProperty(Map<String,CodegenModel> enumRefs, CodegenModel model, CodegenProperty property)
-
buildEnumVars
protected List<Map<String,Object>> buildEnumVars(List<Object> values, String dataType)
- Overrides:
buildEnumVars
in classDefaultCodegen
-
updateCodegenPropertyEnum
public void updateCodegenPropertyEnum(CodegenProperty var)
Update codegen property's enum by adding "enumVars" (with name and value)- Overrides:
updateCodegenPropertyEnum
in classDefaultCodegen
- Parameters:
var
- list of CodegenProperty
-
postProcessOperationsWithModels
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels)
- Specified by:
postProcessOperationsWithModels
in interfaceCodegenConfig
- Overrides:
postProcessOperationsWithModels
in classDefaultCodegen
-
patchVendorExtensionNullableValueType
protected void patchVendorExtensionNullableValueType(CodegenParameter parameter)
-
patchVendorExtensionNullableValueTypeLegacy
protected void patchVendorExtensionNullableValueTypeLegacy(CodegenParameter parameter)
This is the same as patchVendorExtensionNullableValueType except it uses the deprecated getNullableTypes property
-
processOperation
protected void processOperation(CodegenOperation operation)
-
updateCodegenParameterEnumLegacy
protected void updateCodegenParameterEnumLegacy(CodegenParameter parameter, CodegenModel model)
-
updateCodegenParameterEnum
protected void updateCodegenParameterEnum(CodegenParameter parameter, CodegenModel model)
-
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
-
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
-
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
-
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
-
toParamName
public String toParamName(String name)
Description copied from class:DefaultCodegen
Return the parameter name by removing invalid characters and proper escaping if it's a reserved word.- Specified by:
toParamName
in interfaceCodegenConfig
- Overrides:
toParamName
in classDefaultCodegen
- Parameters:
name
- Codegen property object- Returns:
- the sanitized parameter name
-
escapeReservedWord
public String escapeReservedWord(CodegenModel model, String name)
-
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)
-
toExampleValue
public String toExampleValue(io.swagger.v3.oas.models.media.Schema p)
Return the example value of the property- Overrides:
toExampleValue
in classDefaultCodegen
- Parameters:
p
- OpenAPI property object- Returns:
- string presentation of the example value of the property
-
toDefaultValue
public String toDefaultValue(io.swagger.v3.oas.models.media.Schema p)
Return the default value of the property- Overrides:
toDefaultValue
in classDefaultCodegen
- Parameters:
p
- OpenAPI property object- Returns:
- string presentation of the default value of the property
-
isReservedWord
protected boolean isReservedWord(String word)
- Overrides:
isReservedWord
in classDefaultCodegen
-
getNullableType
public String getNullableType(io.swagger.v3.oas.models.media.Schema p, String 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
-
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
-
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
-
apiTestFileFolder
public String apiTestFileFolder()
- Specified by:
apiTestFileFolder
in interfaceCodegenConfig
- Overrides:
apiTestFileFolder
in classDefaultCodegen
-
modelTestFileFolder
public String modelTestFileFolder()
- Specified by:
modelTestFileFolder
in interfaceCodegenConfig
- Overrides:
modelTestFileFolder
in classDefaultCodegen
-
toApiTestFilename
public String toApiTestFilename(String name)
Description copied from class:DefaultCodegen
Return the file name of the Api Test- Specified by:
toApiTestFilename
in interfaceCodegenConfig
- Overrides:
toApiTestFilename
in 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:DefaultCodegen
Return the capitalized file name of the model test- Specified by:
toModelTestFilename
in interfaceCodegenConfig
- Overrides:
toModelTestFilename
in classDefaultCodegen
- Parameters:
name
- the model name- Returns:
- the file name of the model
-
setLicenseUrl
public void setLicenseUrl(String licenseUrl)
-
setLicenseName
public void setLicenseName(String licenseName)
-
setPackageName
public void setPackageName(String packageName)
-
setPackageVersion
public void setPackageVersion(String packageVersion)
-
setPackageTitle
public void setPackageTitle(String packageTitle)
-
setPackageProductName
public void setPackageProductName(String packageProductName)
-
setDateFormat
public void setDateFormat(String dateFormat)
-
setDateTimeFormat
public void setDateTimeFormat(String dateTimeFormat)
-
setPackageDescription
public void setPackageDescription(String packageDescription)
-
setPackageCompany
public void setPackageCompany(String packageCompany)
-
setPackageCopyright
public void setPackageCopyright(String packageCopyright)
-
setPackageAuthors
public void setPackageAuthors(String packageAuthors)
-
setSourceFolder
public void setSourceFolder(String sourceFolder)
-
setTestFolder
public void setTestFolder(String testFolder)
-
getInterfacePrefix
public String getInterfacePrefix()
-
setZeroBasedEnums
public void setZeroBasedEnums(Boolean zeroBasedEnums)
-
setNullableReferenceTypes
public void setNullableReferenceTypes(Boolean nullReferenceTypesFlag)
-
getNullableReferencesTypes
public boolean getNullableReferencesTypes()
-
setUseSourceGeneration
public void setUseSourceGeneration(Boolean useSourceGeneration)
-
getUseSourceGeneration
public boolean getUseSourceGeneration()
-
setInterfacePrefix
public void setInterfacePrefix(String interfacePrefix)
-
setEnumNameSuffix
public void setEnumNameSuffix(String enumNameSuffix)
-
setEnumValueSuffix
public void setEnumValueSuffix(String enumValueSuffix)
-
isSupportNullable
public boolean isSupportNullable()
-
setSupportNullable
public void setSupportNullable(boolean supportNullable)
-
getEnumPropertyNaming
public CodegenConstants.ENUM_PROPERTY_NAMING_TYPE getEnumPropertyNaming()
-
setEnumPropertyNaming
public void setEnumPropertyNaming(String enumPropertyNamingType)
-
toEnumValue
public String toEnumValue(String value, String datatype)
Description copied from class:DefaultCodegen
Return the enum value in the language specified format e.g. status becomes "status"- Overrides:
toEnumValue
in classDefaultCodegen
- Parameters:
value
- enum variable namedatatype
- data type- Returns:
- the sanitized value for enum
-
toEnumVarName
public String toEnumVarName(String name, String datatype)
Description copied from class:DefaultCodegen
Return the sanitized variable name for enum- Overrides:
toEnumVarName
in classDefaultCodegen
- Parameters:
name
- enum variable namedatatype
- data type- Returns:
- the sanitized variable name for enum
-
toEnumName
public String toEnumName(CodegenProperty property)
Description copied from class:DefaultCodegen
Return the Enum name (e.g. StatusEnum given 'status')- Overrides:
toEnumName
in classDefaultCodegen
- Parameters:
property
- Codegen property- Returns:
- the Enum name
-
testPackageName
public String testPackageName()
-
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
-
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
-
isDataTypeString
public boolean isDataTypeString(String dataType)
Description copied from class:DefaultCodegen
checks if the data should be classified as "string" in enum e.g. double in C# needs to be double-quoted (e.g. "2.8") by treating it as a string In the future, we may rename this function to "isEnumString"- Overrides:
isDataTypeString
in classDefaultCodegen
- Parameters:
dataType
- data type- Returns:
- true if it's a enum string
-
isValueType
protected boolean isValueType(CodegenProperty var)
Return true if the property being passed is a C# value type- Parameters:
var
- property- Returns:
- true if property is a value type
-
setParameterExampleValue
public void setParameterExampleValue(CodegenParameter p)
Description copied from class:DefaultCodegen
Return the example value of the parameter.- Overrides:
setParameterExampleValue
in classDefaultCodegen
- Parameters:
p
- Codegen parameter
-
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
-
postProcessParameter
public void postProcessParameter(CodegenParameter parameter)
- Specified by:
postProcessParameter
in interfaceCodegenConfig
- Overrides:
postProcessParameter
in classDefaultCodegen
-
postProcessPattern
public void postProcessPattern(String pattern, Map<String,Object> vendorExtensions)
-
generatorLanguage
public GeneratorLanguage generatorLanguage()
- Specified by:
generatorLanguage
in interfaceCodegenConfig
- Overrides:
generatorLanguage
in classDefaultCodegen
-
toRegularExpression
public String toRegularExpression(String pattern)
Description copied from class:DefaultCodegen
Return the regular expression/JSON schema pattern (http://json-schema.org/latest/json-schema-validation.html#anchor33)- Overrides:
toRegularExpression
in classDefaultCodegen
- Parameters:
pattern
- the pattern (regular expression)- Returns:
- properly-escaped pattern
-
addRegularExpressionDelimiter
public String addRegularExpressionDelimiter(String pattern)
Description copied from class:DefaultCodegen
If the pattern misses the delimiter, add "/" to the beginning and end Otherwise, return the original pattern- Overrides:
addRegularExpressionDelimiter
in classDefaultCodegen
- Parameters:
pattern
- the pattern (regular expression)- Returns:
- the pattern with delimiter
-
getNullableTypes
@Deprecated protected Set<String> getNullableTypes()
Deprecated.
-
setTypeMapping
protected void setTypeMapping()
-
-