Skip to content

Commit

Permalink
Add JSONata to state machine definitions (#3909)
Browse files Browse the repository at this point in the history
* Add JSONata to state machine definitions
  • Loading branch information
kddejong authored Jan 13, 2025
1 parent 3b07bf7 commit 03e1857
Show file tree
Hide file tree
Showing 3 changed files with 330 additions and 3 deletions.
156 changes: 156 additions & 0 deletions src/cfnlint/data/schemas/other/step_functions/statemachine.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"additionalProperties": false,
"definitions": {
"choice": {
"$ref": "#/definitions/common",
"additionalProperties": false,
"definitions": {
"Assign": {
Expand Down Expand Up @@ -197,6 +198,9 @@
}
},
"properties": {
"Arguments": {
"type": "object"
},
"Choices": {
"items": {
"$ref": "#/definitions/choice/definitions/Operator"
Expand Down Expand Up @@ -224,12 +228,21 @@
"pattern": "^.{1,128}$",
"type": "string"
},
"Output": {
"type": [
"string",
"object"
]
},
"OutputPath": {
"type": [
"string",
"null"
]
},
"QueryLanguage": {
"$ref": "#/definitions/queryLanguage"
},
"Type": {
"enum": [
"Choice"
Expand All @@ -243,9 +256,67 @@
],
"type": "object"
},
"common": {
"allOf": [
{
"if": {
"properties": {
"QueryLanguage": {
"const": "JSONata"
}
},
"required": [
"QueryLanguage"
]
},
"then": {
"properties": {
"InputPath": false,
"OutputPath": false,
"Parameters": false,
"ResultPath": false,
"ResultSelector": false
}
}
},
{
"if": {
"oneOf": [
{
"properties": {
"QueryLanguage": {
"const": "JSONPath"
}
},
"required": [
"QueryLanguage"
]
},
{
"not": {
"required": [
"QueryLanguage"
]
}
}
]
},
"then": {
"properties": {
"Arguments": false,
"Output": false
}
}
}
]
},
"fail": {
"$ref": "#/definitions/common",
"additionalProperties": false,
"properties": {
"Arguments": {
"type": "object"
},
"Cause": {
"type": "string"
},
Expand All @@ -267,12 +338,21 @@
"null"
]
},
"Output": {
"type": [
"string",
"object"
]
},
"OutputPath": {
"type": [
"string",
"null"
]
},
"QueryLanguage": {
"$ref": "#/definitions/queryLanguage"
},
"Type": {
"enum": [
"Fail"
Expand All @@ -286,8 +366,12 @@
"type": "object"
},
"map": {
"$ref": "#/definitions/common",
"additionalProperties": false,
"properties": {
"Arguments": {
"type": "object"
},
"Assign": {
"type": "object"
},
Expand Down Expand Up @@ -394,6 +478,12 @@
"pattern": "^.{1,128}$",
"type": "string"
},
"Output": {
"type": [
"string",
"object"
]
},
"OutputPath": {
"type": [
"string",
Expand All @@ -403,6 +493,9 @@
"Parameters": {
"type": "object"
},
"QueryLanguage": {
"$ref": "#/definitions/queryLanguage"
},
"ResultPath": {
"type": [
"string",
Expand Down Expand Up @@ -474,8 +567,12 @@
"type": "object"
},
"parallel": {
"$ref": "#/definitions/common",
"additionalProperties": false,
"properties": {
"Arguments": {
"type": "object"
},
"Assign": {
"type": "object"
},
Expand Down Expand Up @@ -525,12 +622,21 @@
"pattern": "^.{1,128}$",
"type": "string"
},
"Output": {
"type": [
"string",
"object"
]
},
"OutputPath": {
"type": [
"string",
"null"
]
},
"QueryLanguage": {
"$ref": "#/definitions/queryLanguage"
},
"ResultPath": {
"type": [
"string",
Expand Down Expand Up @@ -587,8 +693,12 @@
"type": "object"
},
"pass": {
"$ref": "#/definitions/common",
"additionalProperties": false,
"properties": {
"Arguments": {
"type": "object"
},
"Assign": {
"type": "object"
},
Expand All @@ -610,6 +720,12 @@
"pattern": "^.{1,128}$",
"type": "string"
},
"Output": {
"type": [
"string",
"object"
]
},
"OutputPath": {
"type": [
"string",
Expand All @@ -619,6 +735,9 @@
"Parameters": {
"type": "object"
},
"QueryLanguage": {
"$ref": "#/definitions/queryLanguage"
},
"Result": {},
"ResultPath": {
"type": "string"
Expand All @@ -639,6 +758,14 @@
],
"type": "object"
},
"queryLanguage": {
"default": "JSONPath",
"enum": [
"JSONPath",
"JSONata"
],
"type": "string"
},
"state": {
"allOf": [
{
Expand Down Expand Up @@ -804,8 +931,12 @@
"type": "object"
},
"task": {
"$ref": "#/definitions/common",
"additionalProperties": false,
"properties": {
"Arguments": {
"type": "object"
},
"Assign": {
"type": "object"
},
Expand Down Expand Up @@ -862,6 +993,12 @@
"pattern": "^.{1,128}$",
"type": "string"
},
"Output": {
"type": [
"string",
"object"
]
},
"OutputPath": {
"type": [
"string",
Expand All @@ -871,6 +1008,9 @@
"Parameters": {
"type": "object"
},
"QueryLanguage": {
"$ref": "#/definitions/queryLanguage"
},
"Resource": {
"pattern": "^arn:aws:([a-z]|-)+:([a-z]|[0-9]|-)*:[0-9]*:([a-z]|-)+:[a-zA-Z0-9-_.]+(:(\\$LATEST|[a-zA-Z0-9-_\\.]+))?$",
"type": [
Expand Down Expand Up @@ -940,8 +1080,12 @@
"type": "object"
},
"wait": {
"$ref": "#/definitions/common",
"additionalProperties": false,
"properties": {
"Arguments": {
"type": "object"
},
"Assign": {
"type": "object"
},
Expand All @@ -963,12 +1107,21 @@
"pattern": "^.{1,128}$",
"type": "string"
},
"Output": {
"type": [
"string",
"object"
]
},
"OutputPath": {
"type": [
"string",
"null"
]
},
"QueryLanguage": {
"$ref": "#/definitions/queryLanguage"
},
"Seconds": {
"minimum": 0,
"type": "number"
Expand Down Expand Up @@ -1009,6 +1162,9 @@
"Comment": {
"type": "string"
},
"QueryLanguage": {
"$ref": "#/definitions/queryLanguage"
},
"StartAt": {
"type": "string"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,15 @@ def validate(
err = self._fix_message(err)

err.path.appendleft(k)
if not err.validator.startswith("fn_") and err.validator not in [
"cfnLint"
]:
if err.schema in [True, False]:
err.message = (
f"Additional properties are not allowed ({err.path[-1]!r} "
"was unexpected)"
)
if not err.validator or (
not err.validator.startswith("fn_")
and err.validator not in ["cfnLint"]
):
err.rule = self

yield self._clean_error(err)
Loading

0 comments on commit 03e1857

Please sign in to comment.