Skip to content
This repository was archived by the owner on Jan 15, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"999999",
"--colors",
"-g",
"dialog:merge.*"
"dialog:merge.*missing schema.*"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

 "dialog:merge.*missing schema.*" [](http://example.com/codeflow?start=2&length=38)

This should not be there, but is OK since this is just for dev testing.

],
"cwd": "${workspaceFolder}/packages/dialog",
"internalConsoleOptions": "openOnSessionStart",
Expand Down
44 changes: 25 additions & 19 deletions common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 12 additions & 11 deletions packages/dialog/src/library/schemaMerger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -682,12 +682,7 @@ export class SchemaMerger {
// Final verification
this.verifySchema(finalSchema)
if (!this.failed) {
// Verify all refs work
const start = process.hrtime.bigint()
fullSchema = await parser.dereference(clone(finalSchema))
const end = process.hrtime.bigint()
const elapsed = Number(end - start) / 1000000000
this.vlog(`Expanding all $ref took ${elapsed} seconds`)
fullSchema = finalSchema
if (!this.checkOnly) {
this.log(`Writing ${this.currentFile}`)
await fs.writeJSON(this.currentFile, finalSchema, this.jsonOptions)
Expand Down Expand Up @@ -1954,14 +1949,19 @@ export class SchemaMerger {
const definition = schema.definitions[this.currentKind]
const verifyProperty = (val, path) => {
if (val.$ref) {
val = clone(val)
const ref: any = ptr.get(schema, val.$ref)
for (const prop in ref) {
if (!val[prop]) {
val[prop] = ref[prop]
if (!ref) {
this.mergingError(`${path} $ref ${val.$ref} does not exist`)
} else {
// Expand $ref to check locally
val = clone(val)
for (const prop in ref) {
if (!val[prop]) {
val[prop] = ref[prop]
}
}
delete val.$ref
}
delete val.$ref
}
if (!val.$schema) {
// Assume $schema is an external reference and ignore error checking
Expand Down Expand Up @@ -1995,6 +1995,7 @@ export class SchemaMerger {
}
walkJSON(definition, (val, _, path) => {
if (val.$schema && path) {
// Embedded non-component schema
return true
}
if (val.properties && (!path || !path.endsWith('properties'))) {
Expand Down
2 changes: 1 addition & 1 deletion packages/dialog/test/commands/dialog/merge.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ describe('dialog:merge', async () => {
console.log('\nStart missing schema reference')
const [merged, lines] = await merge(['schemas/*.schema', 'schemas/badSchemas/missingSchemaRef.schema'])
assert(!merged, 'Merging should have failed')
assert(countMatches(/error|warning/i, lines) === 1, 'Wrong number of errors or warnings')
assert(countMatches(/error|warning/i, lines) === 3, 'Wrong number of errors or warnings')
assert(countMatches('does not exist', lines) === 1, 'Did not detect missing schema ref')
})

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"$schema": "https://schemas.botframework.com/schemas/component/v1.0/component.schema",
"$role": [],
"properties": {
"foo": {
"$ref": "schema:#/definitions/foo"
Expand Down