Type object
File match sergen.json sergen.*.json *.sergen.json
Schema URL https://catalog.lintel.tools/schemas/schemastore/serenity-code-generator-sergen/latest.json
Source https://www.schemastore.org/sergen.json

Validate with Lintel

npx @lintel/lintel check
Type: object

Serenity code generator (sergen) configuration

Properties

Extends string

If specified, the settings in this file extends settings in a base file similar to tsconfig.json You can also use Sergen defaults by specifying this like "[email protected]"

minLength=1
Any of: string string, enum enum
RootNamespace string

The root namespace for the target project. It is recommended to have this in sergen.json. If not there, it will be auto calculated from root namespace in CSPROJ file, or derived from project file name by removing .Web suffix. Generated code will be placed under this namespace and project's own types are assumed to be under this namespace as well

minLength=1
DeclareJoinConstants boolean

If true, generated code will declare and use jFKTable type of constants for expressions in entities

EnableGenerateFields boolean

If true, it allows the use of [GenerateFields] attributes on rows, which automatically generates the fields using a source generator. This should only be used when Serenity.Pro.Coder is enabled in the project

EnableGenerateInterface boolean

If true, it allows the use of [GenerateInterface] attributes on handlers, which automatically generates the interface using a source generator. This should only be used when Serenity.Pro.Coder is enabled in the project

EnableRowTemplates boolean

If true, enables RowTemplate class generation. This should only be used when Serenity.Pro.Coder is enabled in the project. Has no effect when EnableGenerateFields is true. EnableGenerateFields should be preferred over this as RowTemplate might cause some issues

EndOfLine string

End of line character to use in generated files. If not specified, it will be auto detected from the environment. It is recommended to have "lf" for multi platform projects

Values: "LF" "CRLF"
FileScopedNamespaces boolean

If true, generated code will use file scoped namespaces

ParseGlobalUsings boolean

If true, generated code will parse global usings from the current project. Default is true

IncludeGlobalUsings string[]

If specified, generated code will assume these usings are in global using scope

uniqueItems=true
ExcludeGlobalUsings string[]

If specified, generated code will assume these usings are not in global using scope even if they are in global using scope

uniqueItems=true
OmitDefaultSchema boolean

If true, the default schema name, e.g. "dbo" for SQL Server won't be emitted in generated field expressions in Row.cs files. This is true by default only for MySql as in MySql schema names are actually database names

UseOriginAttribute boolean

If true, instead of using [Expression] attributes for foreign view fields, it will use Origin(nameof(jFK), nameof(FKRow.ViewField)) if the FKRow is already generated in the project. It will also use ForeignKey(typeof(FKRow)) type of foreign keys instead of strings

SaveGeneratedTables boolean

If true, generated table options like Identity, Module etc. will be saved to the Connections array in sergen.json after code generation. Default is true

ClientTypes object

Client types code generation related configuration

2 nested properties
OutDir string

The output directory for generated client types .cs files

minLength=1
SourceGenerator boolean

If false, the client types source generator in Serenity.Pro.Coder will be disabled

MVC object

MVC (e.g. view locations) related configuration

7 nested properties
UseRootNamespace boolean

Deprecated, Sergen will always use the root namespace to avoid class name clashes

AsNamespace boolean

If true, use namespace {RootNamespace}.MVC instead of a MVC class inside the RootNamespace. ESM helpers will also be generated in this namespace. Default is false. This is useful if to avoid class name clashes with referenced projects. E.g. when add Serenity.Extensions to global usings, its MVC class would clash with the MVC class generated for the current project, sometimes causing issues in Razor views without a @namespace directive. So this is recommended for feature projects like Serenity.Extensions

InternalAccess boolean

If true, Use internal instead of public for generated top level class (MVC/ESM)

OutDir string

The output directory for MVC.cs

minLength=1
SearchViewPaths string[]

View paths to search for, defaults to "Modules" and "Views". "ProjectName" is used instead of "Modules" if Razor SDK is used for the project, e.g. a Razor class library

uniqueItems=true
StripViewPaths string[]

Strip view paths from generated files. Defaults to "Modules", "Views". E.g. a subclass for Modules and Views won't be generated

uniqueItems=true
SourceGenerator boolean

If false, the view paths source generator in Serenity.Pro.Coder will be disabled

ServerTypings object

Server typings code generation related configuration

8 nested properties
Assemblies string[]

Assemblies for server typings generation. Specify only if Sergen can't auto determine your project output file

uniqueItems=true
OutDir string

The output directory for generated server typings files. Not used for modules

minLength=1
LocalTexts boolean

If true, local texts will be generated

ModuleReExports boolean

If true, module re-exports will be generated. Defaults to true

ModuleTypings boolean

Deprecated as only ES modules style code generation is supported now. If true, module typings will be generated. Defaults to true if you have "module" defined in tsconfig.json

NamespaceTypings boolean

Deprecated as only ES modules style code generation is supported now. If true, namespace typings will be generated. Defaults to true if you don't have "module" defined in tsconfig.json

PreferRelativePaths boolean

If true, generated typings will use relative paths instead of paths from tsconfig.json, e.g. "../ServerTypes/" instead of "@/ServerTypes/"

SourceGenerator boolean

If false, the server typings source generator in Serenity.Pro.Coder will be disabled

Restore object

Deprecated as Sergen no longer supports restoring static content. Sergen restore command related configuration

3 nested properties
Include string[]

List of files (git ignore like) to include while restoring

uniqueItems=true
Exclude string[]

List of files (git ignore like) to exclude while restoring

uniqueItems=true
Typings boolean

Set false to disable namespace typings restore to typings/ folder

TSBuild object
2 nested properties
EntryPoints string[]

List of entry point globs, default is "Modules//*Page.ts", "Modules//Page.tsx", "Modules//ScriptInit.ts", "Modules//.mts"

uniqueItems=true
SourceGenerator boolean

Should the list of entry points, e.g. ESM be generated, only available with Serenity.Pro.Coder

Connections Connection[]

List of connections. It is only needed when it is desired to work / generated code based on a connection string that is not in appsettings.json

uniqueItems=true
KDiff3Path string

Deprecated. Path to KDiff3 executable. If not specified, it will be auto detected from the environment

minLength=1
TSCPath string

Deprecated. Full path to TypeScript compiler. It is assumed to be in path if not specified

minLength=1
BaseRowClasses BaseRowClass[]

List of base row classes to be used instead of Row. They are matched by list of base properties

uniqueItems=true
ForeignFieldSelection string

The set of foreign fields to generate, default is NameOnly.

None: Don't generate any foreign view fields except the ones explicitly included via IncludeForeignFields All: Generate all the foreign view fields, except ones excluded explicitly via RemoveForeignFields NameOnly: Don't generate any foreign view fields except the Name property of the target row and ones explicitly included via IncludeForeignFields

Values: "None" "All" "NameOnly"
IncludeForeignFields string[]

A list of foreign fields to include in generated code. This could be used to include some additional fields This could be used to include some additional fields. Not so useful if ForeignFieldSelection is All

uniqueItems=true
RemoveForeignFields string[]

A list of foreign fields to omit from generated code. This could be used to disable generating code for join fields like CreatedBy, ModifiedBy etc, so properties like CustomerCreatedBy, CustomerModifiedBy etc. won't be generated in OrderRow. Not so useful if ForeignFieldSelection is None or NameOnly

uniqueItems=true
CustomTemplates string

The location of custom templates folder. The files in this folder will override the default scriban templates in Sergen. You may also include additional files to be generated. Their names must match the names at https://github.com/serenity-is/Serenity/tree/master/src/codegenerator/Templates You may also include additional files to be generated

minLength=1
CustomGenerate Record<string, string>

The relative paths of custom generated files

CustomSettings object

Custom settings to be passed to and used in custom templates

AppSettingFiles string[]

The list of appsettings.json files in order. Default is appsettings.json, appsettings.machine.json

uniqueItems=true
UpgradeInfo object

The upgrade / migration related information used by stargen to determine the base version of template used, and already applied upgrades

3 nested properties
InitialType string

Initial type of project. Available options are "Community" e.g. Serene, "Premium" e.g. StartSharp

Values: "Community" "Premium"
InitialVersion string

Version this project is created from. Used to determine which migrations should be applied to project (starting from)

minLength=1pattern=^(\d+.)?(\d+.)?(\d+.)?(\d+)?$
AppliedUpgrades string[]

List of already applied upgrades if any

uniqueItems=true

Definitions

Table object
Tablename string required

Table name

minLength=1
Identifier string required

Row identifier without Row suffix

minLength=1
Module string required

Module name

minLength=1
PermissionKey string required

Permission key

minLength=1
Connection object

Connection information

Key string required

Key of connection

minLength=1
ConnectionString string

Connection string

minLength=1
ProviderName string

Provider name

minLength=1
Dialect string

Dialect

minLength=1
Any of: enum enum, string string
Tables Table[]

Generated table information

uniqueItems=true
BaseRowClass object
ClassName string required

The class name

minLength=1
Fields string[] required

The base class fields that should exists in a table for this base class to be used

uniqueItems=true