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

Commit 3865a82

Browse files
author
Chris McConnell
authored
Chrimc/utterance (#426)
* Enable template: as a $ref protocol. Add utterance to mappings. Simplify stringAsk. * Enable template: in requires. * Don't explore schema below $mapping.
1 parent d1a0847 commit 3865a82

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

packages/dialog/src/library/schema.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Licensed under the MIT License.
55
*/
66

7-
/* tslint:disable:no-unused */
7+
/* tslint:disable:no-unused */
88
export * from './schema'
99
import * as Validator from 'ajv'
1010
import * as os from 'os'
@@ -67,7 +67,7 @@ export class Schema {
6767
let name = ppath.basename(loc)
6868
return name.substring(0, name.indexOf('.'))
6969
}
70-
70+
7171
/**
7272
* Path to this schema definition.
7373
*/
@@ -174,7 +174,7 @@ export class Schema {
174174
*/
175175
entityTypes(): string[] {
176176
let found: string[] = []
177-
for(let entity of Object.keys(this.entities())) {
177+
for (let entity of Object.keys(this.entities())) {
178178
let [entityName, _] = entity.split(':')
179179
if (!found.includes(entityName)) {
180180
found.push(entityName)
@@ -187,7 +187,7 @@ export class Schema {
187187
* Return the roles or entity types found in schema.
188188
*/
189189
* roles(): Iterable<string> {
190-
for(let entity of Object.keys(this.entities())) {
190+
for (let entity of Object.keys(this.entities())) {
191191
let [entityName, role] = entity.split(':')
192192
yield role || entityName
193193
}
@@ -201,8 +201,11 @@ export class Schema {
201201
entities[mapping] = entity
202202
}
203203
}
204-
for (let prop of this.schemaProperties()) {
205-
prop.addEntities(entities)
204+
// Don't explore properties below an explicit mapping
205+
if (!this.schema.$mappings) {
206+
for (let prop of this.schemaProperties()) {
207+
prop.addEntities(entities)
208+
}
206209
}
207210
}
208211
}

packages/dialog/templates/currency.schema

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"type": "string"
1111
}
1212
},
13-
"$templates": []
13+
"$templates": [],
14+
"$mappings": [ "money" ]
1415
}
1516
}

0 commit comments

Comments
 (0)