diff --git a/README.md b/README.md index 8a3f13c..2a05f78 100644 --- a/README.md +++ b/README.md @@ -127,6 +127,19 @@ inputs: ... ``` +You can also optionally define `name` which is a hint for code generators what name can be used as class name. + +```yaml +... +inputs: + fetch-depth: + type: integer + name: Amount + named-values: + infinite: 0 + ... +``` + ### Float A number with a fractional component. diff --git a/build.gradle.kts b/build.gradle.kts index 8ebf6e8..daea22f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -16,6 +16,10 @@ dependencies { testImplementation("io.kotest:kotest-assertions-core") } +kotlin { + jvmToolchain(21) +} + tasks.jar { manifest.attributes["Main-Class"] = "MainKt" } diff --git a/dist/github-actions-typing/lib/github-actions-typing.jar b/dist/github-actions-typing/lib/github-actions-typing.jar index 5c0c08b..ed446ab 100644 Binary files a/dist/github-actions-typing/lib/github-actions-typing.jar and b/dist/github-actions-typing/lib/github-actions-typing.jar differ diff --git a/src/main/kotlin/it/krzeminski/githubactionstyping/validation/types/Integer.kt b/src/main/kotlin/it/krzeminski/githubactionstyping/validation/types/Integer.kt index cf9b8d1..3187d3b 100644 --- a/src/main/kotlin/it/krzeminski/githubactionstyping/validation/types/Integer.kt +++ b/src/main/kotlin/it/krzeminski/githubactionstyping/validation/types/Integer.kt @@ -4,8 +4,8 @@ import it.krzeminski.githubactionstyping.parsing.ApiItem import it.krzeminski.githubactionstyping.validation.ItemValidationResult fun ApiItem.validateInteger(): ItemValidationResult { - if (this.name != null) { - return ItemValidationResult.Invalid("'name' is not allowed for this type.") + if ((this.namedValues == null) && (this.name != null)) { + return ItemValidationResult.Invalid("'name' is only allowed for this type when also having 'named-values'.") } if (this.allowedValues != null) { return ItemValidationResult.Invalid("'allowed-values' is not allowed for this type.") diff --git a/src/test/kotlin/it/krzeminski/githubactionstyping/validation/ManifestValidationTest.kt b/src/test/kotlin/it/krzeminski/githubactionstyping/validation/ManifestValidationTest.kt index a60c5da..0a68cee 100644 --- a/src/test/kotlin/it/krzeminski/githubactionstyping/validation/ManifestValidationTest.kt +++ b/src/test/kotlin/it/krzeminski/githubactionstyping/validation/ManifestValidationTest.kt @@ -14,7 +14,15 @@ class ManifestValidationTest : FunSpec({ "string-input" to ApiItem(type = "string"), "boolean-input" to ApiItem(type = "boolean"), "integer-input" to ApiItem(type = "integer"), - "integer-with-named-values-input" to ApiItem(type = "integer", namedValues = mapOf("foo" to 1, "bar" to 2)), + "integer-with-named-values-input" to ApiItem( + type = "integer", + namedValues = mapOf("foo" to 1, "bar" to 2) + ), + "integer-with-named-values-and-custom-item-name-input" to ApiItem( + type = "integer", + name = "SomeItemName", + namedValues = mapOf("foo" to 1, "bar" to 2) + ), "float-input" to ApiItem(type = "float"), ), ) @@ -30,6 +38,7 @@ class ManifestValidationTest : FunSpec({ "boolean-input" to ItemValidationResult.Valid, "integer-input" to ItemValidationResult.Valid, "integer-with-named-values-input" to ItemValidationResult.Valid, + "integer-with-named-values-and-custom-item-name-input" to ItemValidationResult.Valid, "float-input" to ItemValidationResult.Valid, ), ) @@ -496,7 +505,7 @@ class ManifestValidationTest : FunSpec({ inputs = mapOf( "string-input" to ItemValidationResult.Invalid("'name' is not allowed for this type."), "boolean-input" to ItemValidationResult.Invalid("'name' is not allowed for this type."), - "integer-input" to ItemValidationResult.Invalid("'name' is not allowed for this type."), + "integer-input" to ItemValidationResult.Invalid("'name' is only allowed for this type when also having 'named-values'."), "float-input" to ItemValidationResult.Invalid("'name' is not allowed for this type."), "list-input" to ItemValidationResult.Invalid("'name' is not allowed for this type."), ),