From 73f42f8df96a7967e571af08d1a143cb8cdf9446 Mon Sep 17 00:00:00 2001 From: Asish Kumar Date: Sat, 30 Dec 2023 20:18:06 +0530 Subject: [PATCH 1/2] feat: added kotlin constraint docs Signed-off-by: Asish Kumar --- docs/constraints/Kotlin.md | 41 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 docs/constraints/Kotlin.md diff --git a/docs/constraints/Kotlin.md b/docs/constraints/Kotlin.md new file mode 100644 index 0000000000..ea28a5b505 --- /dev/null +++ b/docs/constraints/Kotlin.md @@ -0,0 +1,41 @@ +# Kotlin Constraints + +These are the Kotlin specific constraints applied to the MetaModel before reaching the presets. [Read here to get a more general idea on the overall process](https://github.com/asyncapi/modelina/blob/master/docs/input-processing.md) of converting a MetaModel to a ConstrainedMetaModel. + +## Model Naming +These are the constraints that is applied to model naming. The `Rule key` is what you can use in the options to overwrite the default behavior. See [constraint customization](https://github.com/asyncapi/modelina/blob/master/docs/README.md). + +|Rule key|Rule|Resolution| +|---|---|---| +|NO_SPECIAL_CHAR|No special characters| Special characters are replaced by their name, for example `!` is replaced with `exclamation`. For kotlin `_` and `$` are an exception to this rule. | +|NO_NUMBER_START_CHAR|No numbers as starting characters|Default behavior is pre pending `number_` in front of the first character. | +|NO_EMPTY_VALUE|No empty values|Default behavior is to use `empty` as name. | +|NO_RESERVED_KEYWORDS|No reserved keywords|Kotlin has a list of reserved keywords ([see the full list here](https://github.com/asyncapi/modelina/blob/master/src/generators/kotlin/Constants.ts))| +|NAMING_FORMATTER|Must be formatted equally|Model name is formatted using pascal case.| + +## Property naming +These are the constraints that is applied to object properties and the naming of them. The `Rule key` is what you can use in the options to overwrite the default behavior. See [constraint customization](https://github.com/asyncapi/modelina/blob/master/docs/README.md). +|Rule key|Rule|Resolution| +|---|---|---| +|NO_SPECIAL_CHAR|No special characters| Special characters are replaced by their name, for example `!` is replaced with `exclamation`. For kotlin `_` and `$` are an exception to this rule. | +|NO_NUMBER_START_CHAR|No numbers as starting characters|Default behavior is pre pending `number_` in front of the first character. | +|NO_EMPTY_VALUE|No empty values|Default behavior is to use `empty` as name. | +|NO_RESERVED_KEYWORDS|No reserved keywords|Kotlin has a list of reserved keywords ([see the full list here](https://github.com/asyncapi/modelina/blob/master/src/generators/kotlin/Constants.ts))| +|NAMING_FORMATTER|Must be formatted equally|Property name is formatted using pascal case. | +|NO_DUPLICATE_PROPERTIES|No duplicate properties|If any of the above constraints changes the property name, we must make sure that no duplicates exist within the same object. If any is encountered `reserved_` is pre-pended. This is done recursively until no duplicates are found. | + + +## Enum key constraints +These are the constraints that is applied to enum keys. The `Rule key` is what you can use in the options to overwrite the default behavior. See [constraint customization](https://github.com/asyncapi/modelina/tree/master/docs/README.md). + +|Rule key|Rule|Resolution| +|---|---|---| +|NO_SPECIAL_CHAR|No special characters| Special characters are replaced by their name, for example `!` is replaced with `exclamation`. For kotlin `_` and `$` are an exception to this rule. | +|NO_NUMBER_START_CHAR|No numbers as starting characters|Default behavior is pre pending `number_` in front of the first character. | +|NO_EMPTY_VALUE|No empty values|Default behavior is to use `empty` as name. | +|NO_RESERVED_KEYWORDS|No reserved keywords|Kotlin has a list of reserved keywords ([see the full list here](https://github.com/asyncapi/modelina/blob/master/src/generators/kotlin/Constants.ts))| +|NAMING_FORMATTER|Must be formatted equally|Enum name is formatted using pascal case. | +|NO_DUPLICATE_KEYS|No duplicate enum keys|If any of the above constraints changes the enum key, we must make sure that no duplicates exist within the same enum. If any is encountered `reserved_` is pre-pended. This is done recursively until no duplicates are found. | + +## Constant +These are the constraints that are applied to constants. Currently, there are no hooks one can overwrite inside it. \ No newline at end of file From a4eb3dadd371bc2676e49da5522ca5340d029422 Mon Sep 17 00:00:00 2001 From: Asish Kumar Date: Sun, 31 Dec 2023 09:58:23 +0530 Subject: [PATCH 2/2] fix: updated constraint kotlin docs --- docs/constraints/Kotlin.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/constraints/Kotlin.md b/docs/constraints/Kotlin.md index ea28a5b505..eaad2935d8 100644 --- a/docs/constraints/Kotlin.md +++ b/docs/constraints/Kotlin.md @@ -7,7 +7,7 @@ These are the constraints that is applied to model naming. The `Rule key` is wha |Rule key|Rule|Resolution| |---|---|---| -|NO_SPECIAL_CHAR|No special characters| Special characters are replaced by their name, for example `!` is replaced with `exclamation`. For kotlin `_` and `$` are an exception to this rule. | +|NO_SPECIAL_CHAR|No special characters| Special characters are replaced by their name, for example `!` is replaced with `exclamation`. For kotlin `_` is an exception to this rule. | |NO_NUMBER_START_CHAR|No numbers as starting characters|Default behavior is pre pending `number_` in front of the first character. | |NO_EMPTY_VALUE|No empty values|Default behavior is to use `empty` as name. | |NO_RESERVED_KEYWORDS|No reserved keywords|Kotlin has a list of reserved keywords ([see the full list here](https://github.com/asyncapi/modelina/blob/master/src/generators/kotlin/Constants.ts))| @@ -17,11 +17,11 @@ These are the constraints that is applied to model naming. The `Rule key` is wha These are the constraints that is applied to object properties and the naming of them. The `Rule key` is what you can use in the options to overwrite the default behavior. See [constraint customization](https://github.com/asyncapi/modelina/blob/master/docs/README.md). |Rule key|Rule|Resolution| |---|---|---| -|NO_SPECIAL_CHAR|No special characters| Special characters are replaced by their name, for example `!` is replaced with `exclamation`. For kotlin `_` and `$` are an exception to this rule. | +|NO_SPECIAL_CHAR|No special characters| Special characters are replaced by their name, for example `!` is replaced with `exclamation`. For kotlin `_` is an exception to this rule. | |NO_NUMBER_START_CHAR|No numbers as starting characters|Default behavior is pre pending `number_` in front of the first character. | |NO_EMPTY_VALUE|No empty values|Default behavior is to use `empty` as name. | |NO_RESERVED_KEYWORDS|No reserved keywords|Kotlin has a list of reserved keywords ([see the full list here](https://github.com/asyncapi/modelina/blob/master/src/generators/kotlin/Constants.ts))| -|NAMING_FORMATTER|Must be formatted equally|Property name is formatted using pascal case. | +|NAMING_FORMATTER|Must be formatted equally|Property name is formatted using camel case. | |NO_DUPLICATE_PROPERTIES|No duplicate properties|If any of the above constraints changes the property name, we must make sure that no duplicates exist within the same object. If any is encountered `reserved_` is pre-pended. This is done recursively until no duplicates are found. | @@ -30,11 +30,11 @@ These are the constraints that is applied to enum keys. The `Rule key` is what y |Rule key|Rule|Resolution| |---|---|---| -|NO_SPECIAL_CHAR|No special characters| Special characters are replaced by their name, for example `!` is replaced with `exclamation`. For kotlin `_` and `$` are an exception to this rule. | +|NO_SPECIAL_CHAR|No special characters| Special characters are replaced by their name, for example `!` is replaced with `exclamation`. For kotlin `_` is an exception to this rule. | |NO_NUMBER_START_CHAR|No numbers as starting characters|Default behavior is pre pending `number_` in front of the first character. | |NO_EMPTY_VALUE|No empty values|Default behavior is to use `empty` as name. | |NO_RESERVED_KEYWORDS|No reserved keywords|Kotlin has a list of reserved keywords ([see the full list here](https://github.com/asyncapi/modelina/blob/master/src/generators/kotlin/Constants.ts))| -|NAMING_FORMATTER|Must be formatted equally|Enum name is formatted using pascal case. | +|NAMING_FORMATTER|Must be formatted equally|Enum name is formatted using constant case. | |NO_DUPLICATE_KEYS|No duplicate enum keys|If any of the above constraints changes the enum key, we must make sure that no duplicates exist within the same enum. If any is encountered `reserved_` is pre-pended. This is done recursively until no duplicates are found. | ## Constant