Class AbstractTypeScriptClientCodegen

    • Constructor Detail

      • AbstractTypeScriptClientCodegen

        public AbstractTypeScriptClientCodegen()
    • Method Detail

      • toModelImportMap

        public Map<String,​String> toModelImportMap​(String name)
        Maps the fully qualified model import to the initial given name. In case of union types the map will have multiple entries. For example for "classA | classB" the map will two entries have ["model.classA","classA"] and ["model.classB","classB"].
        Specified by:
        toModelImportMap in interface CodegenConfig
        Overrides:
        toModelImportMap in class DefaultCodegen
        Parameters:
        name - the name of the "Model"
        Returns:
        Map between the fully qualified model import and the initial given 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
      • 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
      • 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
      • toTypescriptTypeName

        protected String toTypescriptTypeName​(String name,
                                              String safePrefix)
      • getParameterDataType

        protected String getParameterDataType​(io.swagger.v3.oas.models.parameters.Parameter parameter,
                                              io.swagger.v3.oas.models.media.Schema p)
        Description copied from class: DefaultCodegen
        Returns the data type of parameter. Returns null by default to use the CodegenProperty.datatype value
        Overrides:
        getParameterDataType in class DefaultCodegen
        Parameters:
        parameter - Parameter
        p - Schema
        Returns:
        data type
      • toDefaultValue

        public String toDefaultValue​(io.swagger.v3.oas.models.media.Schema p)
        Description copied from class: DefaultCodegen
        Return the default value of the property

        This method should be overridden in the generator to meet its requirement. Return null if you do NOT want a default value. Any non-null value will cause {{#defaultValue} check to pass.

        Overrides:
        toDefaultValue in class DefaultCodegen
        Parameters:
        p - Property schema
        Returns:
        string presentation of the default value of the property
      • 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
      • 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
      • setModelPropertyNaming

        public void setModelPropertyNaming​(String naming)
      • setParamNaming

        public void setParamNaming​(String naming)
      • 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
      • toEnumDefaultValue

        public String toEnumDefaultValue​(String value,
                                         String datatype)
        Description copied from class: DefaultCodegen
        Return the enum default value in the language specified format
        Overrides:
        toEnumDefaultValue in class DefaultCodegen
        Parameters:
        value - enum variable name
        datatype - data type
        Returns:
        the default value for the 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
      • setEnumPropertyNaming

        protected void setEnumPropertyNaming​(String naming)
      • setEnumPropertyNamingReplaceSpecialChar

        protected void setEnumPropertyNamingReplaceSpecialChar​(boolean replaceSpecialChars)
      • isEnumPropertyNamingReplaceSpecialChar

        protected boolean isEnumPropertyNamingReplaceSpecialChar()
      • updateDataTypeWithEnumForArray

        protected void updateDataTypeWithEnumForArray​(CodegenProperty property)
        Override to fix the inner enum naming issue for maps/arrays of enums.

        The parent implementation uses toEnumName(baseItem) which produces a generic name like "InnerEnum" based on the inner item's name. This override first calculates the correct property.enumName, then uses it in the datatypeWithEnum replacement.

        Overrides:
        updateDataTypeWithEnumForArray in class DefaultCodegen
        Parameters:
        property - Codegen property
      • updateDataTypeWithEnumForMap

        protected void updateDataTypeWithEnumForMap​(CodegenProperty property)
        Override to fix the inner enum naming issue for map properties.

        The parent implementation uses toEnumName(baseItem) which produces "InnerEnum" for properties whose inner item has a generic name like "inner". We instead calculate the enumName from the property itself first, then use it in the replacement.

        Overrides:
        updateDataTypeWithEnumForMap in class DefaultCodegen
        Parameters:
        property - Codegen property
      • 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-file", "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
      • toAnyOfName

        public String toAnyOfName​(List<String> names,
                                  io.swagger.v3.oas.models.media.Schema composedSchema)
        Description copied from class: DefaultCodegen
        Return the name of the anyOf schema
        Overrides:
        toAnyOfName in class DefaultCodegen
        Parameters:
        names - List of names
        composedSchema - composed schema
        Returns:
        name of the anyOf schema
      • toOneOfName

        public String toOneOfName​(List<String> names,
                                  io.swagger.v3.oas.models.media.Schema composedSchema)
        Description copied from class: DefaultCodegen
        Return the name of the oneOf schema.

        This name is used to set the value of CodegenProperty.openApiType.

        If the 'x-one-of-name' extension is specified in the OAS document, return that value. Otherwise, a name is constructed by creating a comma-separated list of all the names of the oneOf schemas.

        Overrides:
        toOneOfName in class DefaultCodegen
        Parameters:
        names - List of names
        composedSchema - composed schema
        Returns:
        name of the oneOf schema
      • toAllOfName

        public String toAllOfName​(List<String> names,
                                  io.swagger.v3.oas.models.media.Schema composedSchema)
        Description copied from class: DefaultCodegen
        Return the name of the 'allOf' composed schema.
        Overrides:
        toAllOfName in class DefaultCodegen
        Parameters:
        names - List of names
        composedSchema - composed schema
        Returns:
        name of the allOf schema
      • getTypesFromSchemas

        protected List<String> getTypesFromSchemas​(List<io.swagger.v3.oas.models.media.Schema> schemas)
        Extracts the list of type names from a list of schemas. Excludes `AnyType` if there are other valid types extracted.
        Parameters:
        schemas - list of schemas
        Returns:
        list of types
      • needToImport

        protected boolean needToImport​(String type)
        Description copied from class: DefaultCodegen
        Check the type to see if it needs import the library/module/package
        Overrides:
        needToImport in class DefaultCodegen
        Parameters:
        type - name of the type
        Returns:
        true if the library/module/package of the corresponding type needs to be imported
      • getLicenseNameDefaultValue

        protected String getLicenseNameDefaultValue()