Class AbstractCSharpCodegen

    • 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
      • 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
      • dateFormat

        protected String dateFormat
      • dateTimeFormat

        protected String dateTimeFormat
      • interfacePrefix

        protected String interfacePrefix
      • enumNameSuffix

        protected String enumNameSuffix
      • enumValueSuffix

        protected String enumValueSuffix
      • sourceFolder

        protected String sourceFolder
      • invalidNamePrefix

        protected String invalidNamePrefix
      • testFolder

        protected String testFolder
      • collectionTypes

        protected Set<String> collectionTypes
      • supportNullable

        protected boolean supportNullable
      • zeroBasedEnums

        protected Boolean zeroBasedEnums
      • propertySpecialKeywords

        protected Set<String> propertySpecialKeywords
    • Constructor Detail

      • AbstractCSharpCodegen

        public AbstractCSharpCodegen()
    • 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)
      • 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 class DefaultCodegen
        Returns:
        preinitialized map with common lambdas
      • updateCodegenPropertyEnum

        public void updateCodegenPropertyEnum​(CodegenProperty var)
        Update codegen property's enum by adding "enumVars" (with name and value)
        Overrides:
        updateCodegenPropertyEnum in class DefaultCodegen
        Parameters:
        var - list of CodegenProperty
      • 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)
      • toOperationId

        public String toOperationId​(String operationId)
        Description copied from class: DefaultCodegen
        Return the operation ID (method name)
        Overrides:
        toOperationId in class DefaultCodegen
        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 class DefaultCodegen
        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 interface CodegenConfig
        Overrides:
        toParamName in class DefaultCodegen
        Parameters:
        name - Codegen property object
        Returns:
        the sanitized parameter name
      • toExampleValue

        public String toExampleValue​(io.swagger.v3.oas.models.media.Schema p)
        Return the example value of the property
        Overrides:
        toExampleValue in class DefaultCodegen
        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 class DefaultCodegen
        Parameters:
        p - OpenAPI property object
        Returns:
        string presentation of the default value of the property
      • 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 class DefaultCodegen
        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 class DefaultCodegen
        Parameters:
        p - property schema
        Returns:
        string presentation of the instantiation type of the property
      • 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 interface CodegenConfig
        Overrides:
        toModelName in class DefaultCodegen
        Parameters:
        name - the name of the model
        Returns:
        capitalized model name
      • 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()
      • 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)
      • 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 class DefaultCodegen
        Parameters:
        value - enum variable name
        datatype - 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 class DefaultCodegen
        Parameters:
        name - enum variable name
        datatype - data type
        Returns:
        the sanitized variable name for enum
      • testPackageName

        public String testPackageName()
      • 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 class DefaultCodegen
        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
      • 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 interface CodegenConfig
        Overrides:
        postProcessFile in class DefaultCodegen
        Parameters:
        file - file to be processed
        fileType - file type
      • 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 class DefaultCodegen
        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 class DefaultCodegen
        Parameters:
        pattern - the pattern (regular expression)
        Returns:
        the pattern with delimiter
      • getValueTypes

        protected Set<String> getValueTypes()
      • setTypeMapping

        protected void setTypeMapping()