Skip to content
This repository was archived by the owner on Jan 15, 2025. It is now read-only.

Commit 1c4ddb8

Browse files
author
Chris McConnell
authored
Sibling $ref required removed from definition. (#944)
* Sibling $ref required removed from definition. * Update readme.
1 parent 9437cc1 commit 1c4ddb8

File tree

8 files changed

+1521
-4
lines changed

8 files changed

+1521
-4
lines changed

.vscode/launch.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,14 @@
194194
],
195195
"args": [
196196
"dialog:merge",
197-
"schemas/*.schema",
197+
"libraries/**/*.schema",
198+
"tests/**/*.schema",
198199
"-o",
199-
"schemas/app.schema"
200+
"tests/tests.schema",
201+
"--verbose"
200202
],
201203
"internalConsoleOptions": "openOnSessionStart",
202-
"cwd": "${workspaceFolder}/packages/dialog/test/commands/dialog"
204+
"cwd": "${workspaceFolder}/../botbuilder-dotnet/"
203205
},
204206
{
205207
"type": "node",

packages/dialog/src/commands/dialog/merge.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {Command, flags} from '@microsoft/bf-cli-command'
77
import SchemaMerger from '../../library/schemaMerger'
88

99
export default class DialogMerge extends Command {
10-
static description = 'Merge <kind>.schema and <kind>[.<locale>].uischema definitions from a project and its dependencies into a single .schema for describing .dialog files and a per locale .uischema for describing how Composer shows them. For C#, ensures all nuget declarative resources are included in the same location.'
10+
static description = 'Merge `<kind>.schema` and `<kind>[.<locale>].uischema` definitions from a project and its dependencies into a single .schema for describing .dialog files and a per locale .uischema for describing how Composer shows them. For C#, ensures all nuget declarative resources are included in the same location.'
1111

1212
static args = [
1313
{name: 'patterns', required: true, description: 'Any number of glob regex patterns to match .csproj, .nuspec or package.json files.'},

packages/dialog/src/library/schemaMerger.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1349,6 +1349,8 @@ export default class SchemaMerger {
13491349

13501350
// Bundle remote references into schema while pruning to minimally needed definitions.
13511351
// Remote references will be found under definitions/<pathBasename> which must be unique.
1352+
// There is special code to handle requires siblings to $ref where we remove the requires from
1353+
// the bundled definition. This is similar to what JSON schema 8 does.
13521354
private async bundle(schema: any): Promise<void> {
13531355
const current = this.currentFile
13541356
let sources: string[] = []
@@ -1390,6 +1392,11 @@ export default class SchemaMerger {
13901392
} else if (!elt.$bundled) {
13911393
elt.$ref = ref
13921394
elt.$bundled = true
1395+
if (elt.required) {
1396+
// Strip required from destination
1397+
// This is to support a required sibling to $ref
1398+
delete definition.required
1399+
}
13931400
if (!definition.$bundled) {
13941401
// First outside reference mark it to keep and follow internal $ref
13951402
definition.$bundled = true
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"$schema": "https://schemas.botframework.com/schemas/component/v1.0/component.schema",
3+
"$role": [ "implements(Microsoft.IDialog)", "extends(Microsoft.SendActivity)" ],
4+
"title": "Send Activity to Ask a question",
5+
"description": "This is an action which sends an activity to the user when a response is expected",
6+
"type": "object",
7+
"properties": {
8+
"expectedProperties": {
9+
"$ref": "schema:#/definitions/arrayExpression",
10+
"title": "Expected Properties",
11+
"description": "Properties expected from the user.",
12+
"items": {
13+
"type": "string",
14+
"title": "Name",
15+
"description": "Name of the property"
16+
},
17+
"examples": [
18+
[
19+
"age",
20+
"name"
21+
]
22+
]
23+
},
24+
"defaultOperation": {
25+
"$ref": "schema:#/definitions/stringExpression",
26+
"title": "Default Operation",
27+
"description": "Sets the default operation that will be used when no operation is recognized in the response to this Ask.",
28+
"examples": [
29+
"Add()",
30+
"Remove()"
31+
]
32+
}
33+
}
34+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"$schema": "https://schemas.botframework.com/schemas/component/v1.0/component.schema",
3+
"title": "Microsoft ActivityTemplates",
4+
"description": "Components which are ActivityTemplate, which is string template, an activity, or a implementation of ActivityTemplate",
5+
"$role": "interface",
6+
"oneOf": [
7+
{
8+
"type": "string"
9+
},
10+
{
11+
"$ref": "https://schemas.botframework.com/schemas/protocol/botframework.json#/definitions/Activity",
12+
"required": [
13+
"type"
14+
]
15+
}
16+
]
17+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"$schema": "https://schemas.botframework.com/schemas/component/v1.0/component.schema",
3+
"$role": "implements(Microsoft.IDialog)",
4+
"title": "Send an activity",
5+
"description": "Respond with an activity.",
6+
"type": "object",
7+
"properties": {
8+
"id": {
9+
"type": "string",
10+
"title": "Id",
11+
"description": "Optional id for the dialog"
12+
},
13+
"disabled": {
14+
"$ref": "schema:#/definitions/stringExpression",
15+
"title": "Disabled",
16+
"description": "Optional condition which if true will disable this action.",
17+
"examples": [
18+
"user.age > 3"
19+
]
20+
},
21+
"activity": {
22+
"$kind": "Microsoft.IActivityTemplate",
23+
"title": "Activity",
24+
"description": "Activity to send."
25+
}
26+
}
27+
}

0 commit comments

Comments
 (0)