Skip to content

Commit 5af23b7

Browse files
committed
[#10] Change attributes to kebab-casing
1 parent 0e1e17b commit 5af23b7

File tree

9 files changed

+41
-37
lines changed

9 files changed

+41
-37
lines changed

src/main/kotlin/it/krzeminski/githubactionstyping/parsing/TypesManifestParsing.kt

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package it.krzeminski.githubactionstyping.parsing
22

33
import com.charleskorn.kaml.Yaml
4+
import kotlinx.serialization.SerialName
45
import kotlinx.serialization.Serializable
56
import kotlinx.serialization.decodeFromString
67

@@ -13,9 +14,12 @@ data class TypesManifest(
1314
@Serializable
1415
data class ApiItem(
1516
val type: String? = null,
17+
@SerialName("allowed-values")
1618
val allowedValues: List<String>? = null,
1719
val separator: String? = null,
20+
@SerialName("named-values")
1821
val namedValues: Map<String, Int>? = null,
22+
@SerialName("list-item")
1923
val listItem: ApiItem? = null,
2024
)
2125

src/main/kotlin/it/krzeminski/githubactionstyping/validation/types/Boolean.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ import it.krzeminski.githubactionstyping.validation.ItemValidationResult
55

66
fun ApiItem.validateBoolean(): ItemValidationResult {
77
if (this.allowedValues != null) {
8-
return ItemValidationResult.Invalid("'allowedValues' is not allowed for this type.")
8+
return ItemValidationResult.Invalid("'allowed-values' is not allowed for this type.")
99
}
1010
if (this.separator != null) {
1111
return ItemValidationResult.Invalid("'separator' is not allowed for this type.")
1212
}
1313
if (this.listItem != null) {
14-
return ItemValidationResult.Invalid("'listItem' is not allowed for this type.")
14+
return ItemValidationResult.Invalid("'list-item' is not allowed for this type.")
1515
}
1616
if (this.namedValues != null) {
17-
return ItemValidationResult.Invalid("'namedValues' are currently supported only for integers.")
17+
return ItemValidationResult.Invalid("'named-values' are currently supported only for integers.")
1818
}
1919

2020
return ItemValidationResult.Valid

src/main/kotlin/it/krzeminski/githubactionstyping/validation/types/Enum.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ fun ApiItem.validateEnum(): ItemValidationResult {
1111
return ItemValidationResult.Invalid("'separator' is not allowed for this type.")
1212
}
1313
if (this.listItem != null) {
14-
return ItemValidationResult.Invalid("'listItem' is not allowed for this type.")
14+
return ItemValidationResult.Invalid("'list-item' is not allowed for this type.")
1515
}
1616
if (this.namedValues != null) {
17-
return ItemValidationResult.Invalid("'namedValues' are currently supported only for integers.")
17+
return ItemValidationResult.Invalid("'named-values' are currently supported only for integers.")
1818
}
1919
if (this.allowedValues.size < 2) {
2020
return ItemValidationResult.Invalid("There must be at least two allowed values.")

src/main/kotlin/it/krzeminski/githubactionstyping/validation/types/Float.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ import it.krzeminski.githubactionstyping.validation.ItemValidationResult
55

66
fun ApiItem.validateFloat(): ItemValidationResult {
77
if (this.allowedValues != null) {
8-
return ItemValidationResult.Invalid("'allowedValues' is not allowed for this type.")
8+
return ItemValidationResult.Invalid("'allowed-values' is not allowed for this type.")
99
}
1010
if (this.separator != null) {
1111
return ItemValidationResult.Invalid("'separator' is not allowed for this type.")
1212
}
1313
if (this.listItem != null) {
14-
return ItemValidationResult.Invalid("'listItem' is not allowed for this type.")
14+
return ItemValidationResult.Invalid("'list-item' is not allowed for this type.")
1515
}
1616
if (this.namedValues != null) {
17-
return ItemValidationResult.Invalid("'namedValues' are currently supported only for integers.")
17+
return ItemValidationResult.Invalid("'named-values' are currently supported only for integers.")
1818
}
1919

2020
return ItemValidationResult.Valid

src/main/kotlin/it/krzeminski/githubactionstyping/validation/types/Integer.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ import it.krzeminski.githubactionstyping.validation.ItemValidationResult
55

66
fun ApiItem.validateInteger(): ItemValidationResult {
77
if (this.allowedValues != null) {
8-
return ItemValidationResult.Invalid("'allowedValues' is not allowed for this type.")
8+
return ItemValidationResult.Invalid("'allowed-values' is not allowed for this type.")
99
}
1010
if (this.separator != null) {
1111
return ItemValidationResult.Invalid("'separator' is not allowed for this type.")
1212
}
1313
if (this.listItem != null) {
14-
return ItemValidationResult.Invalid("'listItem' is not allowed for this type.")
14+
return ItemValidationResult.Invalid("'list-item' is not allowed for this type.")
1515
}
1616

1717
return ItemValidationResult.Valid

src/main/kotlin/it/krzeminski/githubactionstyping/validation/types/List.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ fun ApiItem.validateList(): ItemValidationResult {
1212
return ItemValidationResult.Invalid("Separator must be specified.")
1313
}
1414
if (this.allowedValues != null) {
15-
return ItemValidationResult.Invalid("'allowedValues' is not allowed for this type.")
15+
return ItemValidationResult.Invalid("'allowed-values' is not allowed for this type.")
1616
}
1717
if (this.namedValues != null) {
18-
return ItemValidationResult.Invalid("'namedValues' are currently supported only for integers.")
18+
return ItemValidationResult.Invalid("'named-values' are currently supported only for integers.")
1919
}
2020
return when (this.listItem.type) {
2121
"string" -> this.listItem.validateString()

src/main/kotlin/it/krzeminski/githubactionstyping/validation/types/String.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ import it.krzeminski.githubactionstyping.validation.ItemValidationResult
55

66
fun ApiItem.validateString(): ItemValidationResult {
77
if (this.allowedValues != null) {
8-
return ItemValidationResult.Invalid("'allowedValues' is not allowed for this type.")
8+
return ItemValidationResult.Invalid("'allowed-values' is not allowed for this type.")
99
}
1010
if (this.separator != null) {
1111
return ItemValidationResult.Invalid("'separator' is not allowed for this type.")
1212
}
1313
if (this.listItem != null) {
14-
return ItemValidationResult.Invalid("'listItem' is not allowed for this type.")
14+
return ItemValidationResult.Invalid("'list-item' is not allowed for this type.")
1515
}
1616
if (this.namedValues != null) {
17-
return ItemValidationResult.Invalid("'namedValues' are currently supported only for integers.")
17+
return ItemValidationResult.Invalid("'named-values' are currently supported only for integers.")
1818
}
1919

2020
return ItemValidationResult.Valid

src/test/kotlin/it/krzeminski/githubactionstyping/validation/ManifestValidationTest.kt

+21-21
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ class ManifestValidationTest : FunSpec({
160160
)
161161
}
162162

163-
test("primitive types with 'allowedValues' attribute") {
163+
test("primitive types with 'allowed-values' attribute") {
164164
// given
165165
val manifest = TypesManifest(
166166
inputs = mapOf(
@@ -178,10 +178,10 @@ class ManifestValidationTest : FunSpec({
178178
result shouldBe ActionValidationResult(
179179
overallResult = ItemValidationResult.Invalid("Some typing is invalid."),
180180
inputs = mapOf(
181-
"string-input" to ItemValidationResult.Invalid("'allowedValues' is not allowed for this type."),
182-
"boolean-input" to ItemValidationResult.Invalid("'allowedValues' is not allowed for this type."),
183-
"integer-input" to ItemValidationResult.Invalid("'allowedValues' is not allowed for this type."),
184-
"float-input" to ItemValidationResult.Invalid("'allowedValues' is not allowed for this type."),
181+
"string-input" to ItemValidationResult.Invalid("'allowed-values' is not allowed for this type."),
182+
"boolean-input" to ItemValidationResult.Invalid("'allowed-values' is not allowed for this type."),
183+
"integer-input" to ItemValidationResult.Invalid("'allowed-values' is not allowed for this type."),
184+
"float-input" to ItemValidationResult.Invalid("'allowed-values' is not allowed for this type."),
185185
),
186186
)
187187
}
@@ -212,7 +212,7 @@ class ManifestValidationTest : FunSpec({
212212
)
213213
}
214214

215-
test("non-list types with 'listItem' attribute") {
215+
test("non-list types with 'list-item' attribute") {
216216
// given
217217
val manifest = TypesManifest(
218218
inputs = mapOf(
@@ -235,11 +235,11 @@ class ManifestValidationTest : FunSpec({
235235
result shouldBe ActionValidationResult(
236236
overallResult = ItemValidationResult.Invalid("Some typing is invalid."),
237237
inputs = mapOf(
238-
"string-input" to ItemValidationResult.Invalid("'listItem' is not allowed for this type."),
239-
"boolean-input" to ItemValidationResult.Invalid("'listItem' is not allowed for this type."),
240-
"integer-input" to ItemValidationResult.Invalid("'listItem' is not allowed for this type."),
241-
"float-input" to ItemValidationResult.Invalid("'listItem' is not allowed for this type."),
242-
"enum-input" to ItemValidationResult.Invalid("'listItem' is not allowed for this type."),
238+
"string-input" to ItemValidationResult.Invalid("'list-item' is not allowed for this type."),
239+
"boolean-input" to ItemValidationResult.Invalid("'list-item' is not allowed for this type."),
240+
"integer-input" to ItemValidationResult.Invalid("'list-item' is not allowed for this type."),
241+
"float-input" to ItemValidationResult.Invalid("'list-item' is not allowed for this type."),
242+
"enum-input" to ItemValidationResult.Invalid("'list-item' is not allowed for this type."),
243243
),
244244
)
245245
}
@@ -264,7 +264,7 @@ class ManifestValidationTest : FunSpec({
264264
)
265265
}
266266

267-
test("enum type without 'allowedValues' attribute") {
267+
test("enum type without 'allowed-values' attribute") {
268268
// given
269269
val manifest = TypesManifest(
270270
inputs = mapOf(
@@ -304,7 +304,7 @@ class ManifestValidationTest : FunSpec({
304304
)
305305
}
306306

307-
test("list type without 'listItem' attribute") {
307+
test("list type without 'list-item' attribute") {
308308
// given
309309
val manifest = TypesManifest(
310310
inputs = mapOf(
@@ -344,7 +344,7 @@ class ManifestValidationTest : FunSpec({
344344
)
345345
}
346346

347-
test("list type with 'allowedValues' attribute") {
347+
test("list type with 'allowed-values' attribute") {
348348
// given
349349
val manifest = TypesManifest(
350350
inputs = mapOf(
@@ -364,7 +364,7 @@ class ManifestValidationTest : FunSpec({
364364
result shouldBe ActionValidationResult(
365365
overallResult = ItemValidationResult.Invalid("Some typing is invalid."),
366366
inputs = mapOf(
367-
"list-input" to ItemValidationResult.Invalid("'allowedValues' is not allowed for this type."),
367+
"list-input" to ItemValidationResult.Invalid("'allowed-values' is not allowed for this type."),
368368
),
369369
)
370370
}
@@ -432,7 +432,7 @@ class ManifestValidationTest : FunSpec({
432432
"List item type: Allowed values must be specified.",
433433
),
434434
"list-of-integers-with-allowed-values-input" to ItemValidationResult.Invalid(
435-
"List item type: 'allowedValues' is not allowed for this type."
435+
"List item type: 'allowed-values' is not allowed for this type."
436436
),
437437
"list-of-unknown-type-input" to ItemValidationResult.Invalid(
438438
"List item type: Unknown type: 'for-sure-unknown-type'."
@@ -460,11 +460,11 @@ class ManifestValidationTest : FunSpec({
460460
result shouldBe ActionValidationResult(
461461
overallResult = ItemValidationResult.Invalid("Some typing is invalid."),
462462
inputs = mapOf(
463-
"string-input" to ItemValidationResult.Invalid("'namedValues' are currently supported only for integers."),
464-
"boolean-input" to ItemValidationResult.Invalid("'namedValues' are currently supported only for integers."),
465-
"float-input" to ItemValidationResult.Invalid("'namedValues' are currently supported only for integers."),
466-
"list-input" to ItemValidationResult.Invalid("'namedValues' are currently supported only for integers."),
467-
"enum-input" to ItemValidationResult.Invalid("'namedValues' are currently supported only for integers."),
463+
"string-input" to ItemValidationResult.Invalid("'named-values' are currently supported only for integers."),
464+
"boolean-input" to ItemValidationResult.Invalid("'named-values' are currently supported only for integers."),
465+
"float-input" to ItemValidationResult.Invalid("'named-values' are currently supported only for integers."),
466+
"list-input" to ItemValidationResult.Invalid("'named-values' are currently supported only for integers."),
467+
"enum-input" to ItemValidationResult.Invalid("'named-values' are currently supported only for integers."),
468468
),
469469
)
470470
}

src/test/kotlin/it/krzeminski/githubactionstyping/validation/ManifestsToReportTest.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class ManifestsToReportTest : FunSpec({
3030
type: boolean
3131
someEnum:
3232
type: enum
33-
allowedValues:
33+
allowed-values:
3434
- foo
3535
- bar
3636
""".trimIndent()

0 commit comments

Comments
 (0)