Backend Generator#
- class besser.generators.backend.backend_generator.BackendGenerator(model: DomainModel, http_methods: list = None, nested_creations: bool = False, output_dir: str = None, docker_image: bool = False, docker_config_path: str = None)[source]#
Bases:
GeneratorInterface
BackendGenerator is a class that implements the GeneratorInterface and is responsible for generating a Backend model code with a REST API using FAST API framework, SQLAlchemy and a Pydantic model based on the input B-UML model.
- Parameters:
model (DomainModel) – An instance of the DomainModel class representing the B-UML model.
http_methods (list, optional) – A list of HTTP methods to be used in the REST API. Defaults to All.
nested_creations (bool, optional) – This parameter specifies how entities are linked in the API request. If set to True, the API expects identifiers and links entities based on these IDs. If set to False, the API handles the creation of new entities based on the data provided in the request. Defaults to True
output_dir (str, optional) – The output directory where the generated code will be saved. Defaults to None.
docker_image (bool, optional) – Flag to indicate if Docker image generation is required. Defaults to False.
docker_config_path (str, optional) – The path to the docker configuration file to auto upload the image. Defaults to None.
- _abc_impl = <_abc._abc_data object>#
- build_and_push_docker_image(backend_folder_path)[source]#
Builds and pushes the Docker image based on the provided backend folder path.
- Parameters:
backend_folder_path (str) – The path to the backend folder containing the generated code.
- Returns:
None
- generate()[source]#
Generates Backend model code based on the provided B-UML model and saves it to the specified output directory. If the output directory was not specified, the code generated will be stored in the <current directory>/output_backend folder.
- Returns:
None, but stores the generated code as files main_api.py, sql_alchemy.py and pydantic_classes.py