Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Criterion Object and Criterion Expression Type Object #335

Unanswered
markus-96 asked this question in Q&A
Discussion options

Hi, I am trying to understand the Criterion Object and the Criterion Expression Type Object and how they should look like.

A Criterion Object has a field type that can be either a string or a Criterion Expression Type Object. This means, that a valid Criterion Object can be one of the following in JSON notation:

{
 "condition": "hi",
 "context": "$response.body",
 "type": "simple"
}

or:

{
 "context": "$response.body",
 "condition": "hi",
 "type": {
 "type": "jsonpath",
 "version": "draft-goessner-dispatch-jsonpath-00"
 }
}

but not this:

{
 "condition": "hi",
 "context": "$response.body",
 "type": "jsonpath",
 "version": "draft-goessner-dispatch-jsonpath-00"
}

However, the provided schema.json says that the second option is not ok but the third one is. It is said that the schema.json is not the source of truth, but the spec is, could this be one case for this statement?

With that in mind, I would describe a Criterion Object as follows:

{
 "$comment": "https://spec.openapis.org/arazzo/v1.0#criterion-object",
 "$defs": {
 "criterion-expression-type": {
 "description": "An object used to describe the type and version of an expression used within a Criterion Object",
 "patternProperties": {
 "^x-": true
 },
 "properties": {
 "type": {
 "$ref": "#/$defs/criterion-expression-type-enum",
 "description": "The type of condition to be applied"
 },
 "version": {
 "description": "A short hand string representing the version of the expression type"
 }
 },
 "required": [
 "type",
 "version"
 ],
 "if": {
 "properties": {
 "type": {
 "const": "jsonpath"
 }
 }
 },
 "then": {
 "properties": {
 "version": {
 "$ref": "#/$defs/criterion-json-path-version-enum"
 }
 }
 },
 "else": {
 "properties": {
 "version": {
 "$ref": "#/$defs/criterion-x-path-version-enum"
 }
 }
 },
 "type": "object"
 },
 "criterion-expression-type-enum": {
 "enum": [
 "jsonpath",
 "xpath"
 ],
 "type": "string"
 },
 "criterion-json-path-version-enum": {
 "const": "draft-goessner-dispatch-jsonpath-00",
 "enum": [
 "draft-goessner-dispatch-jsonpath-00"
 ],
 "type": "string"
 },
 "criterion-type-enum": {
 "description": "type of criterion",
 "enum": [
 "simple",
 "regex",
 "jsonpath",
 "xpath"
 ],
 "type": "string"
 },
 "criterion-x-path-version-enum": {
 "enum": [
 "xpath-10",
 "xpath-20",
 "xpath-30"
 ],
 "type": "string"
 }
 },
 "dependentRequired": {
 "type": [
 "context"
 ]
 },
 "description": "An object used to specify the context, conditions, and condition types that can be used to prove or satisfy assertions specified in Step Object successCriteria, Success Action Object criteria, and Failure Action Object criteria",
 "patternProperties": {
 "^x-": true
 },
 "properties": {
 "context": {
 "description": "A runtime expression used to set the context for the condition to be applied on",
 "type": "string"
 },
 "condition": {
 "description": "The condition to apply",
 "type": "string"
 },
 "type": {
 "default": "simple",
 "description": "The type of condition to be applied",
 "oneOf": [
 {
 "$ref": "#/$defs/criterion-type-enum"
 },
 {
 "$ref": "#/$defs/criterion-expression-type"
 }
 ]
 }
 },
 "required": [
 "condition"
 ],
 "type": "object",
 "unevaluatedProperties": false
}
You must be logged in to vote

Replies: 1 comment

Comment options

@markus-96 nice spot. Thanks.

I've created an issue from this discussion. See #336 for more details

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /