Skip to content

Services

Services are the logical units that will compose your solution. There are several types of services, such as Web Apis, Background Jobs, among others. Your project can be split into several services, each one with a specific purpose for your business, forming a service oriented solution, or even in the granularity of Microservices.

Fields

A service contains the following fields to be defined:

Name

The name of service 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
Services:
- Name: My_First_Service


Type

The type of service to be created.

Possible types are:

  • WebApi: A RESTful services, also known as Web APIs

Requirements Rules:

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

Example:

1
2
3
Services:
- Name: My_First_Service
  Type: WebApi


Controllers

A list of classes for the current service, o provide the endpoints (actions) for other applications (like user interfaces or external systems) to communicate with the current service.

Requirements Rules:

  • Is Required;
  • Each controller on list must have an exclusive 'Name' property value;
  • Each controller on list must follows rules as specified in Controller

Example:

1
2
3
4
5
6
7
8
Services:
- Name: My_First_Service
  Type: WebApi
  Controllers:
  - Name: My_First_Controller
    ...
  - Name: My_Second_Controller
    ...


AllowedScopes

An array of scopes that this service can access through Http calls, using an access token. The scopes here can be understood as the names of the target services.

Each scope defined here will be added as AllowedScope to the service ClientApp via Migration. This grants access from the current service to the target service without the need for manual configuration.

Requirements Rules:

  • Must not have duplicate items;
  • Must not have empty or null items

Example:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
Services:
- Name: My_First_Service
  Type: WebApi
  Controllers:
  - Name: My_First_Controller
    ...
  - Name: My_Second_Controller
    ...
  AllowedScopes:
  - TargetServiceScope


HttpCommunications

An array of HttpCommunication which will be configured at service startup and will make it possible to make Http calls.

Note

If this HttpCommunication has HttpHandlers, the HttpCommunications used as BackChannel will be automatically configured in the service, without the need to enter them manually.

Requirements Rules:

  • Must haven't duplicated httpCommunication names;
  • Each name on array must exist in HttpCommunication list in the current model

Example:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
Services:
- Name: My_First_Service
  Type: WebApi
  Controllers:
  - Name: My_First_Controller
    ...
  - Name: My_Second_Controller
    ...
  AllowedScopes:
  - TargetServiceScope
  HttpCommunications:
  - My_First_HttpCommunication


Metadata

A set of information and descriptions about the current service.

This information will be published in an online documentation for the service, known as the OpenAPI Specification.

Requirements Rules:

  • Must follows rules as specified in Metadata

Example:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
Services:
- Name: My_First_Service
  Type: WebApi
  Controllers:
  - Name: My_First_Controller
    ...
  - Name: My_Second_Controller
    ...
  AllowedScopes:
  - TargetServiceScope
  HttpCommunications:
  - My_First_HttpCommunication
  Metadata:
    Version: v1


Complete Example

See below for a complete example, containing all the properties for the Services section.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
Services:
- Name: My_First_Service
  Type: WebApi
  Controllers:
  - Name: My_First_Controller
    Type: Crud
    EntityName: My_First_Entity
    RepositoryName: My_First_Repository
    Contexts:
    - Context: Create
      Validations:
      - Name: My_First_Validation
        Type: EntityValidation
        Order: 1
        ExecValidationName: My_First_EntityValidation # It is only performed if conditional validation is valid
        ConditionalValidationName: My_Second_EntityValidation # Run first
      Rules:
      - Name: My_First_Rule
        Type: EntityRule
        Order: 1
        ExecRuleName: My_First_EntityRule
  AllowedScopes:
  - TargetServiceScope
  HttpCommunications:
  - My_First_HttpCommunication
  Metadata:
    Version: v1
    Title: My_First_Service WebApi
    Description: A Rest Api for customers CRUD
    TermsOfServiceUrl: https://mydomain.com/my-first-service/service-terms
    Contact:
      ContactName: My_First_Service WebApi Team
      ContactEmail: team@domain.com
      ContactUrl: https://mydomain.com/contact
    License:
      LicenseInfo: Use under MIT
      LicenseUrl: https://mydomain.com/license

Back to top