Skip to content

Commit

Permalink
Update sergen's JSON schema (#4062)
Browse files Browse the repository at this point in the history
* Update sergen's JSON schema

Update schema to draft-07
Add new PreferRelativePaths property for the ServerTypings object
Refactor titles of some properties
Mark some properties as deprecated and also add it to the description
Refactor BaseRowClasses to be an array of BaseRowClass objects instead of a single BaseRowClass object
Move first level string properties of the schema before objects
Update positive tests and add a single negative test for the data type change of the BaseRowClasses property

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
furkanevran and pre-commit-ci[bot] authored Sep 11, 2024
1 parent 22871f7 commit 5a65f8b
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 48 deletions.
6 changes: 6 additions & 0 deletions src/negative_test/sergen/baserow-isnolonger-object.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"BaseRowClasses": {
"ClassName": "abc",
"Fields": ["abc"]
}
}
92 changes: 56 additions & 36 deletions src/schemas/json/sergen.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://json.schemastore.org/sergen.json",
"title": "Serenity Code Generator (sergen) Configuration",
"type": "object",
"additionalProperties": false,
"description": "Serenity code generator (sergen) configuration",
"definitions": {
"Table": {
"type": "object",
Expand Down Expand Up @@ -33,6 +37,7 @@
"Connection": {
"type": "object",
"title": "Connection",
"description": "Connection information",
"additionalProperties": false,
"required": ["Key"],
"properties": {
Expand Down Expand Up @@ -87,10 +92,30 @@
}
}
}
},
"BaseRowClass": {
"type": "object",
"title": "BaseRowClass",
"additionalProperties": false,
"required": ["ClassName", "Fields"],
"properties": {
"ClassName": {
"type": "string",
"description": "The class name",
"minLength": 1
},
"Fields": {
"type": "array",
"uniqueItems": true,
"description": "The base class fields that should exists in a table for this base class to be used",
"items": {
"type": "string",
"minLength": 1
}
}
}
}
},
"description": "Serenity code generator (sergen) configuration",
"id": "https://json.schemastore.org/sergen.json",
"properties": {
"Extends": {
"type": "string",
Expand Down Expand Up @@ -122,12 +147,12 @@
},
"EnableRowTemplates": {
"type": "boolean",
"description": "If true, enables RowTemplate class generation. This should only be used when Serenity.Pro.Coder is enabled in the project"
"description": "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": {
"type": "string",
"title": "EndOfLine",
"description": "End of line character to use in generated files. If not specified, it will be auto detected from the environment",
"description": "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",
"enum": ["LF", "CRLF"]
},
"FileScopedNamespaces": {
Expand Down Expand Up @@ -203,7 +228,7 @@
"SearchViewPaths": {
"type": "array",
"uniqueItems": true,
"description": "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",
"description": "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",
"items": {
"type": "string",
"minLength": 1
Expand Down Expand Up @@ -241,7 +266,7 @@
},
"OutDir": {
"type": "string",
"description": "The output directory for generated server typings files",
"description": "The output directory for generated server typings files. Not used for modules",
"minLength": 1
},
"LocalTexts": {
Expand All @@ -254,11 +279,17 @@
},
"ModuleTypings": {
"type": "boolean",
"description": "If true, module typings will be generated. Defaults to true if you have \"module\" defined in tsconfig.json"
"description": "If true, module typings will be generated. Defaults to true if you have \"module\" defined in tsconfig.json. Deprecated as only ES modules style code generation is supported now",
"deprecated": true
},
"NamespaceTypings": {
"type": "boolean",
"description": "If true, namespace typings will be generated. Defaults to true if you don't have \"module\" defined in tsconfig.json"
"description": "If true, namespace typings will be generated. Defaults to true if you don't have \"module\" defined in tsconfig.json. Deprecated as only ES modules style code generation is supported now",
"deprecated": true
},
"PreferRelativePaths": {
"type": "boolean",
"description": "If true, generated typings will use relative paths instead of paths from tsconfig.json, e.g. \"../ServerTypes/\" instead of \"@/ServerTypes/\""
},
"SourceGenerator": {
"type": "boolean",
Expand All @@ -269,7 +300,8 @@
"Restore": {
"type": "object",
"title": "Restore",
"description": "Sergen restore command related configuration",
"description": "Sergen restore command related configuration. Deprecated as Sergen no longer supports restoring static content",
"deprecated": true,
"additionalProperties": false,
"properties": {
"Include": {
Expand Down Expand Up @@ -304,7 +336,7 @@
"EntryPoints": {
"type": "array",
"uniqueItems": true,
"description": "List of entry point globs, default is \"**/Page.ts\", \"**/ScriptInit.ts\"",
"description": "List of entry point globs, default is \"**/*Page.ts\", \"**/*Page.tsx\", \"**/ScriptInit.ts\"",
"items": {
"type": "string",
"minLength": 1
Expand All @@ -328,38 +360,28 @@
"KDiff3Path": {
"type": "string",
"description": "Path to KDiff3 executable. If not specified, it will be auto detected from the environment. (deprecated)",
"minLength": 1
"minLength": 1,
"deprecated": true
},
"TSCPath": {
"type": "string",
"description": "Full path to TypeScript compiler. It is assumed to be in path if not specified",
"minLength": 1
"description": "Full path to TypeScript compiler. It is assumed to be in path if not specified. (deprecated)",
"minLength": 1,
"deprecated": true
},
"BaseRowClasses": {
"type": "object",
"type": "array",
"uniqueItems": true,
"title": "BaseRowClasses",
"additionalProperties": false,
"properties": {
"ClassName": {
"type": "string",
"description": "The base class name",
"minLength": 1
},
"Fields": {
"type": "array",
"uniqueItems": true,
"description": "The base class fields that should exists in a table for this base class to be used",
"items": {
"type": "string",
"minLength": 1
}
}
"description": "List of base row classes to be used instead of Row. They are matched by list of base properties",
"items": {
"$ref": "#/definitions/BaseRowClass"
}
},
"ForeignFieldSelection": {
"type": "string",
"title": "ForeignFieldSelection",
"description": "The set of foreign fields to generate, default is NameOnly",
"description": "The set of foreign fields to generate, default is NameOnly.\n\nNone: Don't generate any foreign view fields except the ones explicitly included via IncludeForeignFields\nAll: Generate all the foreign view fields, except ones excluded explicitly via RemoveForeignFields\nNameOnly: Don't generate any foreign view fields except the Name property of the target row and ones explicitly included via IncludeForeignFields",
"enum": ["None", "All", "NameOnly"]
},
"IncludeForeignFields": {
Expand All @@ -382,7 +404,7 @@
},
"CustomTemplates": {
"type": "string",
"description": "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 \nhttps://github.com/serenity-is/Serenity/tree/master/src/Serenity.Net.CodeGenerator/Templates",
"description": "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 \nhttps://github.com/serenity-is/Serenity/tree/master/src/Serenity.Net.CodeGenerator/Templates \nYou may also include additional files to be generated",
"minLength": 1
},
"CustomGenerate": {
Expand Down Expand Up @@ -439,7 +461,5 @@
}
}
}
},
"title": "Serenity Code Generator (sergen) Configuration",
"type": "object"
}
}
12 changes: 6 additions & 6 deletions src/test/sergen/extends-file.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{
"AppSettingFiles": [],
"BaseRowClasses": {
"ClassName": "abc",
"Fields": ["abc"]
},
"BaseRowClasses": [
{
"ClassName": "abc",
"Fields": ["abc"]
}
],
"ClientTypes": {
"OutDir": "abc",
"SourceGenerator": false
Expand Down Expand Up @@ -47,7 +49,6 @@
"ForeignFieldSelection": "NameOnly",
"IncludeForeignFields": ["test"],
"IncludeGlobalUsings": [],
"KDiff3Path": "abc",
"MVC": {
"OutDir": "abc",
"SearchViewPaths": ["abc"],
Expand All @@ -73,7 +74,6 @@
"SourceGenerator": true,
"extraProperty": "abc"
},
"TSCPath": "abc/def/ghi",
"UpgradeInfo": {
"InitialType": "Community",
"InitialVersion": "1.22.2"
Expand Down
12 changes: 6 additions & 6 deletions src/test/sergen/extends-version.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{
"AppSettingFiles": [],
"BaseRowClasses": {
"ClassName": "abc",
"Fields": ["abc"]
},
"BaseRowClasses": [
{
"ClassName": "abc",
"Fields": ["abc"]
}
],
"ClientTypes": {
"OutDir": "abc",
"SourceGenerator": false
Expand Down Expand Up @@ -47,7 +49,6 @@
"ForeignFieldSelection": "All",
"IncludeForeignFields": ["test"],
"IncludeGlobalUsings": [],
"KDiff3Path": "abc",
"MVC": {
"OutDir": "abc",
"SearchViewPaths": ["abc"],
Expand All @@ -74,7 +75,6 @@
"extraProperty": "abc",
"extraProperty2": true
},
"TSCPath": "abc/def/ghi",
"UpgradeInfo": {
"InitialType": "Community",
"InitialVersion": "5.22.0"
Expand Down

0 comments on commit 5a65f8b

Please sign in to comment.