Class PythonClientCodegen

  • All Implemented Interfaces:
    io.swagger.codegen.v3.CodegenConfig

    public class PythonClientCodegen
    extends DefaultCodegenConfig
    • Constructor Detail

      • PythonClientCodegen

        public PythonClientCodegen()
    • Method Detail

      • processOpts

        public void processOpts()
        Specified by:
        processOpts in interface io.swagger.codegen.v3.CodegenConfig
        Overrides:
        processOpts in class DefaultCodegenConfig
      • fromModel

        public io.swagger.codegen.v3.CodegenModel fromModel​(String name,
                                                            io.swagger.v3.oas.models.media.Schema schema,
                                                            Map<String,​io.swagger.v3.oas.models.media.Schema> allDefinitions)
        Description copied from class: DefaultCodegenConfig
        Convert Swagger Model object to Codegen Model object
        Specified by:
        fromModel in interface io.swagger.codegen.v3.CodegenConfig
        Overrides:
        fromModel in class DefaultCodegenConfig
        Parameters:
        name - the name of the model
        schema - Swagger Model object
        allDefinitions - a map of all Swagger models from the spec
        Returns:
        Codegen Model object
      • toModelImport

        public String toModelImport​(String name)
        Description copied from class: DefaultCodegenConfig
        Return the fully-qualified "Model" name for import
        Specified by:
        toModelImport in interface io.swagger.codegen.v3.CodegenConfig
        Overrides:
        toModelImport in class DefaultCodegenConfig
        Parameters:
        name - the name of the "Model"
        Returns:
        the fully-qualified "Model" name for import
      • toApiImport

        public String toApiImport​(String name)
        Description copied from class: DefaultCodegenConfig
        Return the fully-qualified "Api" name for import
        Specified by:
        toApiImport in interface io.swagger.codegen.v3.CodegenConfig
        Overrides:
        toApiImport in class DefaultCodegenConfig
        Parameters:
        name - the name of the "Api"
        Returns:
        the fully-qualified "Api" name for import
      • postProcessParameter

        public void postProcessParameter​(io.swagger.codegen.v3.CodegenParameter parameter)
        Specified by:
        postProcessParameter in interface io.swagger.codegen.v3.CodegenConfig
        Overrides:
        postProcessParameter in class DefaultCodegenConfig
      • postProcessModelProperty

        public void postProcessModelProperty​(io.swagger.codegen.v3.CodegenModel model,
                                             io.swagger.codegen.v3.CodegenProperty property)
        Specified by:
        postProcessModelProperty in interface io.swagger.codegen.v3.CodegenConfig
        Overrides:
        postProcessModelProperty in class DefaultCodegenConfig
      • postProcessPattern

        public void postProcessPattern​(String pattern,
                                       Map<String,​Object> vendorExtensions)
      • getTag

        public io.swagger.codegen.v3.CodegenType getTag()
      • getName

        public String getName()
      • getHelp

        public String getHelp()
      • escapeReservedWord

        public String escapeReservedWord​(String name)
        Description copied from class: DefaultCodegenConfig
        Return the escaped name of the reserved word
        Specified by:
        escapeReservedWord in interface io.swagger.codegen.v3.CodegenConfig
        Overrides:
        escapeReservedWord in class DefaultCodegenConfig
        Parameters:
        name - the name to be escaped
        Returns:
        the escaped reserved word throws Runtime exception as reserved word is not allowed (default behavior)
      • toModelDocFilename

        public String toModelDocFilename​(String name)
        Description copied from class: DefaultCodegenConfig
        Return the capitalized file name of the model documentation
        Specified by:
        toModelDocFilename in interface io.swagger.codegen.v3.CodegenConfig
        Overrides:
        toModelDocFilename in class DefaultCodegenConfig
        Parameters:
        name - the model name
        Returns:
        the file name of the model
      • toApiDocFilename

        public String toApiDocFilename​(String name)
        Description copied from class: DefaultCodegenConfig
        Return the file name of the Api Documentation
        Specified by:
        toApiDocFilename in interface io.swagger.codegen.v3.CodegenConfig
        Overrides:
        toApiDocFilename in class DefaultCodegenConfig
        Parameters:
        name - the file name of the Api
        Returns:
        the file name of the Api
      • toInstantiationType

        public String toInstantiationType​(io.swagger.v3.oas.models.media.Schema schema)
        Description copied from class: DefaultCodegenConfig
        Return the instantiation type of the property, especially for map and array
        Overrides:
        toInstantiationType in class DefaultCodegenConfig
        Parameters:
        schema - Swagger property object
        Returns:
        string presentation of the instantiation type of the property
      • getTypeDeclaration

        public String getTypeDeclaration​(io.swagger.v3.oas.models.media.Schema schema)
        Description copied from class: DefaultCodegenConfig
        Output the type declaration of the property
        Specified by:
        getTypeDeclaration in interface io.swagger.codegen.v3.CodegenConfig
        Overrides:
        getTypeDeclaration in class DefaultCodegenConfig
        Parameters:
        schema - Schema Property object
        Returns:
        a string presentation of the property type
      • getSchemaType

        public String getSchemaType​(io.swagger.v3.oas.models.media.Schema schema)
        Description copied from class: DefaultCodegenConfig
        returns the swagger type for the property
        Overrides:
        getSchemaType in class DefaultCodegenConfig
        Parameters:
        schema - Schema property object
        Returns:
        string presentation of the type
      • toVarName

        public String toVarName​(String name)
        Description copied from class: DefaultCodegenConfig
        Return the variable name by removing invalid characters and proper escaping if it's a reserved word.
        Overrides:
        toVarName in class DefaultCodegenConfig
        Parameters:
        name - the variable name
        Returns:
        the sanitized variable name
      • toParamName

        public String toParamName​(String name)
        Description copied from class: DefaultCodegenConfig
        Return the parameter name by removing invalid characters and proper escaping if it's a reserved word.
        Specified by:
        toParamName in interface io.swagger.codegen.v3.CodegenConfig
        Overrides:
        toParamName in class DefaultCodegenConfig
        Parameters:
        name - Codegen property object
        Returns:
        the sanitized parameter name
      • toModelName

        public String toModelName​(String name)
        Description copied from class: DefaultCodegenConfig
        Output the proper model name (capitalized). In case the name belongs to the TypeSystem it won't be renamed.
        Specified by:
        toModelName in interface io.swagger.codegen.v3.CodegenConfig
        Overrides:
        toModelName in class DefaultCodegenConfig
        Parameters:
        name - the name of the model
        Returns:
        capitalized model name
      • toModelFilename

        public String toModelFilename​(String name)
        Description copied from class: DefaultCodegenConfig
        Return the capitalized file name of the model
        Specified by:
        toModelFilename in interface io.swagger.codegen.v3.CodegenConfig
        Overrides:
        toModelFilename in class DefaultCodegenConfig
        Parameters:
        name - the model name
        Returns:
        the file name of the model
      • toModelTestFilename

        public String toModelTestFilename​(String name)
        Description copied from class: DefaultCodegenConfig
        Return the capitalized file name of the model test
        Specified by:
        toModelTestFilename in interface io.swagger.codegen.v3.CodegenConfig
        Overrides:
        toModelTestFilename in class DefaultCodegenConfig
        Parameters:
        name - the model name
        Returns:
        the file name of the model
      • toApiFilename

        public String toApiFilename​(String name)
        Description copied from class: DefaultCodegenConfig
        Return the file name of the Api Test
        Specified by:
        toApiFilename in interface io.swagger.codegen.v3.CodegenConfig
        Overrides:
        toApiFilename in class DefaultCodegenConfig
        Parameters:
        name - the file name of the Api
        Returns:
        the file name of the Api
      • toApiTestFilename

        public String toApiTestFilename​(String name)
        Description copied from class: DefaultCodegenConfig
        Return the file name of the Api Test
        Specified by:
        toApiTestFilename in interface io.swagger.codegen.v3.CodegenConfig
        Overrides:
        toApiTestFilename in class DefaultCodegenConfig
        Parameters:
        name - the file name of the Api
        Returns:
        the file name of the Api
      • toApiName

        public String toApiName​(String name)
        Description copied from class: DefaultCodegenConfig
        Output the API (class) name (capitalized) ending with "Api" Return DefaultApi if name is empty
        Specified by:
        toApiName in interface io.swagger.codegen.v3.CodegenConfig
        Overrides:
        toApiName in class DefaultCodegenConfig
        Parameters:
        name - the name of the Api
        Returns:
        capitalized Api name ending with "Api"
      • toApiVarName

        public String toApiVarName​(String name)
        Description copied from class: DefaultCodegenConfig
        Return the variable name in the Api
        Specified by:
        toApiVarName in interface io.swagger.codegen.v3.CodegenConfig
        Overrides:
        toApiVarName in class DefaultCodegenConfig
        Parameters:
        name - the varible name of the Api
        Returns:
        the snake-cased variable name
      • setPackageName

        public void setPackageName​(String packageName)
      • setProjectName

        public void setProjectName​(String projectName)
      • setPackageVersion

        public void setPackageVersion​(String packageVersion)
      • setPackageUrl

        public void setPackageUrl​(String packageUrl)
      • generatePackageName

        public String generatePackageName​(String packageName)
        Generate Python package name from String `packageName` (PEP 0008) Python packages should also have short, all-lowercase names, although the use of underscores is discouraged.
        Parameters:
        packageName - Package name
        Returns:
        Python package name that conforms to PEP 0008
      • toDefaultValue

        public String toDefaultValue​(io.swagger.v3.oas.models.media.Schema propertySchema)
        Return the default value of the property
        Overrides:
        toDefaultValue in class DefaultCodegenConfig
        Parameters:
        propertySchema - Swagger property object
        Returns:
        string presentation of the default value of the property
      • escapeQuotationMark

        public String escapeQuotationMark​(String input)
        Description copied from class: DefaultCodegenConfig
        Escape single and/or double quote to avoid code injection
        Specified by:
        escapeQuotationMark in interface io.swagger.codegen.v3.CodegenConfig
        Overrides:
        escapeQuotationMark in class DefaultCodegenConfig
        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: DefaultCodegenConfig
        override with any special text escaping logic to handle unsafe characters so as to avoid code injection
        Specified by:
        escapeUnsafeCharacters in interface io.swagger.codegen.v3.CodegenConfig
        Overrides:
        escapeUnsafeCharacters in class DefaultCodegenConfig
        Parameters:
        input - String to be cleaned up
        Returns:
        string with unsafe characters removed or escaped