Skip to content

Controllers

The controller section is where you design classes to provide the endpoints (actions) for other applications (like user interfaces or external systems) to communicate with the current service.

Fields

A controller contains the following fields to be defined:

Name

The name of controller to be created.

Requirements Rules:

  • Is Required;
  • Must not be a Reserved Keyword;
  • Must start with a letter;
  • Must contains only letters, numbers and the underline char ('_');
  • Max length of 50 chars;

Example:

1
2
Controllers:
- Name: My_First_Controller


Type

The type of controller to be created.

Possible types are:

  • Crud: Creates all needed endpoints for entity data CRUD operation contexts, they are: Create (Post), Update (Put), UpdatePartial (Patch), Delete (Delete), ReadAll (Get) and ReadByKey (Get);
  • Query: Allows perform queries in your database through OData standard. This is a powerful tool for building customized queries, eliminating, in most cases, the need of building endpoints for this task;
    To learn more about the OData standard, see the official documentation available at the following links:

Requirements Rules:

  • Is Required;
  • Must be an Allowed valid type, according to the types informed above;

Example:

1
2
3
Controllers:
- Name: My_First_Controller
  Type: Crud


EntityName

The name of business entity linked to this controller.

Requirements Rules:

  • Is Required;
  • The entity cannot be in more than one controller of the same type for the same service;
  • The name must exist in Entities list in the current model;
    • See Entity section for more details.

Example:

1
2
3
4
Controllers:
- Name: My_First_Controller
  Type: Crud
  EntityName: My_First_Entity


RepositoryName

The name of repository linked to this controller for data access.

Requirements Rules:

  • Is Required;
  • The name must exist in Repositories list in the current model;
  • The entity name of the current controller must be the same as this repository

Example:

1
2
3
4
5
Controllers:
- Name: My_First_Controller
  Type: Crud
  EntityName: My_First_Entity
  RepositoryName: My_First_Repository


Contexts

A collection of business contexts defined for the controller type. See Contexts section for more details.

Requirements Rules:

  • Must haven't duplicated context types;
  • Each context on list must follows rules as specified in Context

Example:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
Controllers:
- Name: My_First_Controller
  Type: Crud
  EntityName: My_First_Entity
  RepositoryName: My_First_Repository
  Contexts:
  - Context: Create
    ...
  - Context: Update
    ...


Back to top