Skip to content

Commit 6243266

Browse files
Copilothawkeyexl
andcommitted
Add note about mutually exclusive properties in schema reference
Co-authored-by: hawkeyexl <[email protected]>
1 parent c33fe92 commit 6243266

File tree

12 files changed

+148
-20
lines changed

12 files changed

+148
-20
lines changed

.scripts/buildSchemaReferencesV3.js

Lines changed: 81 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,23 @@ async function main() {
3636
let fields = [
3737
"## Fields",
3838
"",
39+
];
40+
41+
// Add warning about mutually exclusive properties if the schema has top-level anyOf/oneOf
42+
if (schema.anyOf || schema.oneOf) {
43+
const mutuallyExclusiveProps = extractMutuallyExclusiveActionProperties(schema);
44+
if (mutuallyExclusiveProps.length > 0) {
45+
fields.push("> **Note:** The following action properties are mutually exclusive. You can only use one of these in a single step:");
46+
fields.push("> ");
47+
fields.push("> `" + mutuallyExclusiveProps.join("`, `") + "`");
48+
fields.push("");
49+
}
50+
}
51+
52+
fields = fields.concat([
3953
"Field | Type | Description | Default",
4054
":-- | :-- | :-- | :--",
41-
];
55+
]);
4256

4357
// Handle top-level anyOf/oneOf schemas (like screenshot which can be string, object, or boolean)
4458
if (schema.anyOf || schema.oneOf) {
@@ -756,4 +770,70 @@ function getArraySubTypes(property, depth) {
756770
}
757771

758772
return subTypes;
773+
}
774+
775+
/**
776+
* Extract action property names from the schema that are mutually exclusive
777+
* (typically at the top level of an anyOf)
778+
*/
779+
function extractMutuallyExclusiveActionProperties(schema) {
780+
const actionProps = [];
781+
782+
// Check if the schema has a top-level anyOf or oneOf
783+
if (!schema.anyOf && !schema.oneOf) {
784+
return actionProps;
785+
}
786+
787+
const variants = schema.anyOf || schema.oneOf;
788+
789+
// For each variant, find the action property (usually in required array)
790+
for (const variant of variants) {
791+
// Handle typical allOf structure in step schema
792+
// where common properties are in one block and action-specific in another
793+
if (variant.allOf) {
794+
for (const allOfItem of variant.allOf) {
795+
if (allOfItem.required && allOfItem.required.length > 0) {
796+
// Find the action property that's required
797+
for (const requiredProp of allOfItem.required) {
798+
// Skip common properties that can be used with any action
799+
if (['stepId', 'description', 'outputs', 'variables'].includes(requiredProp)) {
800+
continue;
801+
}
802+
if (!actionProps.includes(requiredProp)) {
803+
actionProps.push(requiredProp);
804+
}
805+
}
806+
}
807+
808+
// Also check the properties directly if they're specific action types
809+
if (allOfItem.properties) {
810+
for (const propName of Object.keys(allOfItem.properties)) {
811+
// Skip common properties that can be used with any action
812+
if (['stepId', 'description', 'outputs', 'variables'].includes(propName)) {
813+
continue;
814+
}
815+
// Add property if it seems to be an action (has $schema or title)
816+
const prop = allOfItem.properties[propName];
817+
if ((prop.$schema || prop.title) && !actionProps.includes(propName)) {
818+
actionProps.push(propName);
819+
}
820+
}
821+
}
822+
}
823+
}
824+
// Handle direct required properties in the variant
825+
else if (variant.required) {
826+
for (const requiredProp of variant.required) {
827+
// Skip common properties
828+
if (['stepId', 'description', 'outputs', 'variables'].includes(requiredProp)) {
829+
continue;
830+
}
831+
if (!actionProps.includes(requiredProp)) {
832+
actionProps.push(requiredProp);
833+
}
834+
}
835+
}
836+
}
837+
838+
return actionProps;
759839
}

docs/references/schemas/checkLink.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55

66
## Fields
77

8+
> **Note:** The following action properties are mutually exclusive. You can only use one of these in a single step:
9+
>
10+
> `url`
11+
812
Field | Type | Description | Default
913
:-- | :-- | :-- | :--
1014
checkLink | string | Check if an HTTP or HTTPS URL returns an acceptable status code from a GET request. |

docs/references/schemas/config.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Configuration options for Doc Detective operations.
88
Field | Type | Description | Default
99
:-- | :-- | :-- | :--
1010
configId | string | Optional. Identifier for the configuration. |
11+
configPath | string | ReadOnly. Path to the configuration file. |
1112
input | string | Optional. Path(s) to test specifications and documentation source files. May be paths to specific files or to directories to scan for files. |
1213
input | array of string | Optional. Path(s) to test specifications and documentation source files. May be paths to specific files or to directories to scan for files. |
1314
output | string | Optional. Path of the directory in which to store the output of Doc Detective commands. If a file path is specified, Doc Detective attempts to honor the file name specified, but file path behavior is controlled by the configured reporters. | `.`
@@ -28,6 +29,10 @@ integrations.openApi | array of unknown | Optional. No description provided. |
2829
telemetry | object | Optional. Options around sending telemetry for Doc Detective usage. | ``{"send":true}``
2930
telemetry.send | boolean | Required. If `true`, sends Doc Detective telemetry. | `true`
3031
telemetry.userId | string | Optional. Identifier for the organization, group, or individual running Doc Detective. |
32+
environment | object | ReadOnly. Environment information for the system running Doc Detective. |
33+
environment.workingDirectory | string | Optional. The current working directory of the process running Doc Detective. |
34+
environment.platform | string | Required. The operating system type running Doc Detective.<br/><br/>Accepted values: `linux`, `mac`, `windows` |
35+
environment.arch | string | Optional. The processor architecture of the system running Doc Detective.<br/><br/>Accepted values: `arm32`, `arm64`, `x32`, `x64` |
3136

3237
## Examples
3338

@@ -111,3 +116,12 @@ telemetry.userId | string | Optional. Identifier for the organization, group, or
111116
]
112117
}
113118
```
119+
120+
```json
121+
{
122+
"environment": {
123+
"platform": "windows",
124+
"arch": "x64"
125+
}
126+
}
127+
```

docs/references/schemas/goTo.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55

66
## Fields
77

8+
> **Note:** The following action properties are mutually exclusive. You can only use one of these in a single step:
9+
>
10+
> `url`
11+
812
Field | Type | Description | Default
913
:-- | :-- | :-- | :--
1014
goTo | string | Navigate to an HTTP or HTTPS URL. Can be a full URL or a path. If a path is provided, navigates relative to the current URL, if any. |

docs/references/schemas/runCode.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ Assemble and run code.
55

66
## Fields
77

8+
> **Note:** The following action properties are mutually exclusive. You can only use one of these in a single step:
9+
>
10+
> `code`, `language`
11+
812
Field | Type | Description | Default
913
:-- | :-- | :-- | :--
1014
language | string | Required. Language of the code to run.<br/><br/>Accepted values: `python`, `bash`, `javascript` |

docs/references/schemas/runShell.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ Perform a native shell command.
55

66
## Fields
77

8+
> **Note:** The following action properties are mutually exclusive. You can only use one of these in a single step:
9+
>
10+
> `command`
11+
812
Field | Type | Description | Default
913
:-- | :-- | :-- | :--
1014
runShell | string | No description provided. |

docs/references/schemas/specification.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Field | Type | Description | Default
99
:-- | :-- | :-- | :--
1010
specId | string | Optional. Unique identifier for the test specification. |
1111
description | string | Optional. Description of the test specification. |
12+
specPath | string | Optional. Path to the test specification. |
1213
contentPath | string | Optional. Path to the content that the specification is associated with. |
1314
runOn | array of object | Optional. Contexts to run the test in. Overrides contexts defined at the config and spec levels. |
1415
openApi | array of unknown | Optional. No description provided. |

docs/references/schemas/step.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ A step in a test.
55

66
## Fields
77

8+
> **Note:** The following action properties are mutually exclusive. You can only use one of these in a single step:
9+
>
10+
> `checkLink`, `click`, `find`, `goTo`, `httpRequest`, `runShell`, `runCode`, `type`, `screenshot`, `record`, `stopRecord`, `loadVariables`, `wait`
11+
812
Field | Type | Description | Default
913
:-- | :-- | :-- | :--
1014
stepId | string | Optional. ID of the step. |

docs/references/schemas/test.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ A Doc Detective test.
55

66
## Fields
77

8+
> **Note:** The following action properties are mutually exclusive. You can only use one of these in a single step:
9+
>
10+
> `steps`, `contexts`
11+
812
Field | Type | Description | Default
913
:-- | :-- | :-- | :--
1014
testId | string | Optional. Unique identifier for the test. |
@@ -15,7 +19,12 @@ runOn | array of object | Optional. Contexts to run the test in. Overrides conte
1519
openApi | array of unknown | Optional. No description provided. |
1620
before | string | Optional. Path to a test specification to perform before this test, while maintaining this test's context. Useful for setting up testing environments. Only the `steps` property is used from the first test in the setup spec. |
1721
after | string | Optional. Path to a test specification to perform after this test, while maintaining this test's context. Useful for cleaning up testing environments. Only the `steps` property is used from the first test in the cleanup spec. |
18-
steps | array of object | Required. Steps to perform as part of the test. Performed in the sequence defined. If one or more actions fail, the test fails. By default, if a step fails, the test stops and the remaining steps are not executed. |
22+
steps | array of object | Optional. Steps to perform as part of the test. Performed in the sequence defined. If one or more actions fail, the test fails. By default, if a step fails, the test stops and the remaining steps are not executed. |
23+
contexts | array of object | ReadOnly. Resolved contexts to run the test in. This is a resolved version of the `runOn` property. It is not user-defined and should not be used in test specifications. |
24+
contexts[].platform | string | Optional. Platform to run the test on. This is a resolved version of the `platforms` property. |
25+
contexts[].browser | object | Optional. Browser configuration. |
26+
contexts[].openApi | array of unknown | Optional. No description provided. |
27+
contexts[].steps | array of <br/>one of:<br/>- unknown<br/>- unknown<br/>- unknown<br/>- unknown<br/>- unknown<br/>- unknown<br/>- unknown<br/>- unknown<br/>- unknown<br/>- unknown<br/>- unknown<br/>- unknown<br/>- unknown | Optional. Steps to perform as part of the test. Performed in the sequence defined. If one or more actions fail, the test fails. By default, if a step fails, the test stops and the remaining steps are not executed. |
1928

2029
## Examples
2130

docs/references/schemas/typeKeys.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ Type keys. To type special keys, begin and end the string with `$` and use the s
55

66
## Fields
77

8+
> **Note:** The following action properties are mutually exclusive. You can only use one of these in a single step:
9+
>
10+
> `keys`
11+
812
Field | Type | Description | Default
913
:-- | :-- | :-- | :--
1014
typeKeys | string | No description provided. |

0 commit comments

Comments
 (0)