Data Api configuration
The Data Api configuration section starts with the dataApi
tag.
Example:
dataApi:
entityGroups:
- group: default
enableHistory: true
enableTransactions: true
readComponents:
- type: MongoDbComponent
writeComponents:
- type: ValidationComponent
- type: MongoDbComponent
endpoints:
- type: WebApiEndpoint
Immediately under the dataApi
tag, you can define the properties useGroupFolder
and projectsPrefix
which, if used, can be defined for all entity groups. Both of these properties can be overridden in Entity Groups section.
Properties
useGroupFolder: true
| false
( if not defined and also not defined in any of the child properties, the default will be false)
projectsPrefix defines the prefix that is used in project names.
Entity Groups
Under the dataApi
tag, you can define the list of entity groups. Node name is entityGroups
.
Each entity group can define a different configuration of repositories and endpoints for entitites grouped in the groups section.
The name of the entity group has to correspond to the name of a defined group.
If you don’t have any groups defined and want to use all the entities, you can use the value default
for a group name.
When you have a group defined, you cannot use default
anymore, only the name of one of your groups.
Properties
Enable History
enableHistory: true
| false
( default: false
)
Generates the code that tracks all the modifications of an entity and can be used for history or auditing purposes.
Enable Transactions
- enableTransactions:
true
|false
( default:false
)
Generates the endpoint (per entity) that can be used by agents for bulk data import.
Use Group Folder
- useGroupFolder:
true
|false
( default:false
)
Groups the classes related to one entity in a folder. The folder name is taken from the memberOf
property defined in the entity, or if memberOf
is not set, the entity’s pluralName
is used.
Example of configuration:
solutionName: Axellon.FolderGroups.Cfg1
dataApi:
entityGroups:
- group: default
enableHistory: true
enableTransactions: false
useGroupFolder: true
readComponents:
- type: MongoDbComponent
writeComponents:
- type: ValidationComponent
- type: MongoDbComponent
endpoints:
- type: WebApiEndpoint
Resulting folder structure:
For more granular control, you can use the useGroupFolder
property on the project level as well (and this value will override the parent value).
solutionName: Axellon.FolderGroups.Cfg2
dataApi:
entityGroups:
- group: default
enableHistory: true
enableTransactions: false
useGroupFolder: false
repository:
projectName: Axellon.FolderGroups.Cfg2.Repository
useGroupFolder: true
repositoryModels:
projectName: Axellon.FolderGroups.Cfg2.Repository.Models
useGroupFolder: true
endpoints:
- type: WebApiEndpoint
configuration:
projectName: Axellon.FolderGroups.Cfg2.WebApi
webApiModels:
useGroupFolder: true
projectName: Axellon.FolderGroups.Cfg2.WebApi.Model
readComponents:
- type: MongoDbComponent
writeComponents:
- type: ValidationComponent
- type: MongoDbComponent
Project Names
For each entity group, es-builder
creates the following projects in the generated solution
Repository
Repository.Extensions
Repository.Models
//and if the endpoint type is WebApiEndpoint
WebApi
WebApi.Models
Names of these .NET projects can be customized in two different ways:
- by propagating segments of the project names through different levels or
- by setting a name directly for each project.
Project name Prefix
It is possible to define Prefix string that is added to project’s names in selected group.
Here is an example of setting the prefix User
for projects name:
solutionName: ES.Demo
dataApi:
projectsPrefix: Data
entityGroups:
- group: default
useGroupFolder: true
projectsPrefix: Users
endpoints:
- type: WebApiEndpoint
readComponents:
- type: MongoDbComponent
writeComponents:
- type: ValidationComponent
- type: MongoDbComponent
Based on this configuration, the project names will be constructed as
{solutionName}.{dataApi.ProjectsPrefix}.{entytyGroup.ProjectsPrefix}
,
and calculated values will be:
ES.Demo.Data.Users.Repository
ES.Demo.Data.Users.Repository.Extensions
ES.Demo.Data.Users.Repository.Models
Custom Project name
Each project can also have the full name set as a custom value in the configuration, using the property projectName
:
solutionName: Axellon.Demo
dataApi:
entityGroups:
- group: default
enableHistory: true
repository:
projectName: MyEntityServer.Repository
repositoryExtensions:
projectName: MyEntityServer.Repository.Extensions
repositoryModels:
projectName: MyEntityServer.Repository.Models
readComponents:
- type: MongoDbComponent
writeComponents:
- type: ValidationComponent
- type: MongoDbComponent
endpoints:
- type: WebApiEndpoint
configuration:
projectName: MyEntityServer.WebApi
webApiModelsConfig:
projectName: MyEntityServer.WebApi.Models