Class AbstractAdaCodegen

    • Field Detail

      • packageName

        protected String packageName
      • projectName

        protected String projectName
      • nullableTypeMapping

        protected final Map<String,​String> nullableTypeMapping
      • mediaLists

        protected final List<List<org.openapitools.codegen.languages.AbstractAdaCodegen.NameBinding>> mediaLists
      • mediaToVariableName

        protected final Map<String,​String> mediaToVariableName
      • mediaVariables

        protected final List<org.openapitools.codegen.languages.AbstractAdaCodegen.NameBinding> mediaVariables
      • adaImports

        protected final List<org.openapitools.codegen.languages.AbstractAdaCodegen.NameBinding> adaImports
      • adaImportSet

        protected final Set<String> adaImportSet
      • scopeIndex

        protected int scopeIndex
      • httpClientPackageName

        protected String httpClientPackageName
      • openApiPackageName

        protected String openApiPackageName
    • Constructor Detail

      • AbstractAdaCodegen

        public AbstractAdaCodegen()
    • Method Detail

      • toAdaIdentifier

        protected String toAdaIdentifier​(String name,
                                         String prefix)
        Turn a parameter name, operation name into an Ada identifier.

        Ada programming standard avoid the camelcase syntax and prefer the underscore notation. We also have to make sure the identifier is not a reserved keyword. When this happens, we add the configurable prefix. The function translates:

        body - P_Body petId - Pet_Id updatePetWithForm - Update_Pet_With_Form

        Parameters:
        name - the parameter name.
        prefix - the optional prefix in case the parameter name is a reserved keyword.
        Returns:
        the Ada identifier to be used.
      • 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
      • toModelName

        public String toModelName​(String name)
        Output the proper model name (capitalized). 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
      • toEnumVarName

        public String toEnumVarName​(String value,
                                    String datatype)
        Description copied from class: DefaultCodegen
        Return the sanitized variable name for enum
        Overrides:
        toEnumVarName in class DefaultCodegen
        Parameters:
        value - enum variable name
        datatype - data type
        Returns:
        the sanitized variable name for enum
      • fromProperty

        public CodegenProperty fromProperty​(String name,
                                            io.swagger.v3.oas.models.media.Schema p,
                                            boolean required)
        Description copied from class: DefaultCodegen
        TODO remove this in 7.0.0 as a breaking change This method was kept when required was added to the fromProperty signature to ensure that the change was non-breaking
        Overrides:
        fromProperty in class DefaultCodegen
        Parameters:
        name - name of the property
        p - OAS property schema
        required - true if the property is required in the next higher object schema, false otherwise
        Returns:
        Codegen Property object
      • escapeReservedWord

        public String escapeReservedWord​(String name)
        Escapes a reserved word as defined in the `reservedWords` array. Handle escaping those terms here. This logic is only called if a variable matches the reserved words
        Specified by:
        escapeReservedWord in interface CodegenConfig
        Overrides:
        escapeReservedWord in class DefaultCodegen
        Parameters:
        name - the name to be escaped
        Returns:
        the escaped term
      • processCompiler

        public com.samskivert.mustache.Mustache.Compiler processCompiler​(com.samskivert.mustache.Mustache.Compiler compiler)
        Override the Mustache compiler configuration.

        We don't want to have special characters escaped

        Specified by:
        processCompiler in interface CodegenConfig
        Overrides:
        processCompiler in class DefaultCodegen
        Parameters:
        compiler - the compiler.
        Returns:
        the compiler to use.
      • getTypeDeclaration

        public String getTypeDeclaration​(io.swagger.v3.oas.models.media.Schema p)
        Optional - type declaration. This is a String which is used by the templates to instantiate your types. There is typically special handling for different property types
        Specified by:
        getTypeDeclaration in interface CodegenConfig
        Overrides:
        getTypeDeclaration in class DefaultCodegen
        Parameters:
        p - property schema
        Returns:
        a string value used as the `dataType` field for model templates, `returnType` for api templates
      • postProcessParameter

        public void postProcessParameter​(CodegenParameter parameter)
        Overrides postProcessParameter to add a vendor extension "x-is-model-type". This boolean indicates that the parameter comes from the model package.
        Specified by:
        postProcessParameter in interface CodegenConfig
        Overrides:
        postProcessParameter in class DefaultCodegen
        Parameters:
        parameter - CodegenParameter object to be processed.
      • 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: DefaultCodegen
        Convert OAS Operation object to Codegen Operation object
        Specified by:
        fromOperation in interface CodegenConfig
        Overrides:
        fromOperation in class DefaultCodegen
        Parameters:
        path - the path of the operation
        httpMethod - HTTP method
        operation - OAS operation object
        servers - list of servers
        Returns:
        Codegen Operation object
      • 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