Skip to content

Commit

Permalink
fix: allow name for named values in integer type (#208)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vampire authored Aug 27, 2024
1 parent 9e17622 commit 3858ba6
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 4 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ dependencies {
testImplementation("io.kotest:kotest-assertions-core")
}

kotlin {
jvmToolchain(21)
}

tasks.jar {
manifest.attributes["Main-Class"] = "MainKt"
}
Expand Down
Binary file modified dist/github-actions-typing/lib/github-actions-typing.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
),
)
Expand All @@ -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,
),
)
Expand Down Expand Up @@ -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."),
),
Expand Down

0 comments on commit 3858ba6

Please sign in to comment.