Ejemplo n.º 1
0
    def testJavaBeanTemplateWithFilter(self):
        dirpath = Path('tmp', 'javaBeans3')
        if dirpath.exists() and dirpath.is_dir():
            shutil.rmtree(dirpath)
        modelFile = 'resources/models/yaml/userConfig.swagger.yaml'
        modelFileExists = os.path.isfile(modelFile)
        self.assertTrue('model file exists: ' + modelFile, modelFileExists)
        model = config.Model()
        model.schema = modelFile
        modelTypes = getModelFromYaml(model, [])
        templateFile = 'resources/templates/examples/javaBeans.mako'
        templateFileExists = os.path.isfile(templateFile)
        self.assertTrue('template file exists: ' + templateFile,
                        templateFileExists)
        templateParameters = []
        templateParam = config.TemplateParam()
        templateParam.name = 'modelPackage'
        templateParam.value = 'de.test.model'
        templateParameters.append(templateParam)
        multiFileTask = MultiFileTask()
        multiFileTask.template = templateFile
        multiFileTask.destDir = 'tmp/javaBeans3/de/test/model'
        multiFileTask.destFileExt = 'java'
        multiFileTask.upperCaseStartedDestFileName = True
        multiFileTask.fileFilterType = MultiFileTaskFileFilterTypeEnum.OPENAPIOPERATIONID
        multiFileTask.templateParams = templateParameters
        whiteList = []
        whiteListEntry = BlackWhiteListEntry()
        whiteListEntry.name = 'PathType'
        whiteListEntry.type = BlackWhiteListEntryTypeEnum.TYPETYPE
        whiteList.append(whiteListEntry)

        renderMultiFileTemplate(modelTypes, (), whiteList, multiFileTask)
Ejemplo n.º 2
0
    def testJavaBeanTemplate(self):
        dirpath = Path('tmp', 'javaBeans')
        if dirpath.exists() and dirpath.is_dir():
            shutil.rmtree(dirpath)
        modelFile = 'resources/models/json/yacg_model_schema.json'
        modelFileExists = os.path.isfile(modelFile)
        self.assertTrue('model file exists: ' + modelFile, modelFileExists)
        model = config.Model()
        model.schema = modelFile
        modelTypes = getModelFromJson(model, [])
        templateFile = 'resources/templates/examples/javaBeans.mako'
        templateFileExists = os.path.isfile(templateFile)
        self.assertTrue('template file exists: ' + templateFile,
                        templateFileExists)
        templateParameters = []
        templateParam = config.TemplateParam()
        templateParam.name = 'modelPackage'
        templateParam.value = 'de.test.model'
        templateParameters.append(templateParam)
        multiFileTask = MultiFileTask()
        multiFileTask.template = templateFile
        multiFileTask.destDir = 'tmp/javaBeans/de/test/model'
        multiFileTask.destFileExt = 'java'
        multiFileTask.templateParams = templateParameters

        renderMultiFileTemplate(modelTypes, (), (), multiFileTask)
Ejemplo n.º 3
0
Archivo: yacg.py Proyecto: OkieOth/yacg
def _getTemplateParameters(args):
    """extracts the per command line given template parameters, copies them
    into a dictionary and return this dictonary
    """

    templateParameters = []
    if args.templateParameters is not None:
        for parameter in args.templateParameters:
            keyValueArray = parameter.split('=')
            if (len(keyValueArray) == 2):
                templateParam = config.TemplateParam()
                templateParam.name = keyValueArray[0]
                templateParam.value = keyValueArray[1]
                templateParameters.append(templateParam)
            else:
                printError(
                    '\ntemplate param with wrong structure found ... skipped: {}'
                    .format(parameter))
    return templateParameters