public class CodeGenerator extends Object
This class generates Service definitions, clients for a provided ballerina service.
| Constructor and Description |
|---|
CodeGenerator() |
| Modifier and Type | Method and Description |
|---|---|
String |
generateOutput(GeneratorConstants.GenType type,
ClientContextHolder context)
Generates code(client, server etc) for ballerina source provided in
definitionPath. |
String |
getConvertedString(Object object,
String templateDir,
String templateName)
Get converted string for given service definition.
|
void |
writeGeneratedSource(GeneratorConstants.GenType type,
ClientContextHolder context,
String outPath)
Write generated source of a given
context to a file at outpath. |
public String generateOutput(GeneratorConstants.GenType type, ClientContextHolder context) throws CodeGeneratorException
definitionPath.
Method can be used for generating OAS 3.0.0, Swagger or Ballerina Client
type - Output type. Following types are supported
context - Context details for generating the clientCodeGeneratorException - when file operations failpublic void writeGeneratedSource(GeneratorConstants.GenType type, ClientContextHolder context, String outPath) throws CodeGeneratorException
context to a file at outpath.type - Generator Type to be used. Following types are supported.
context - Definition object containing required properties to be extracted for code generationoutPath - resulting file pathCodeGeneratorException - when error occurred while generating the codepublic String getConvertedString(Object object, String templateDir, String templateName) throws CodeGeneratorException
object - Object to be built as parsable contexttemplateDir - Template directory which contains templates for specific output type.templateName - Name of the template to be use for code generation.CodeGeneratorException - when error occurs while compile, build context.Copyright © 2018 WSO2. All rights reserved.