-
Notifications
You must be signed in to change notification settings - Fork 254
Load schema content contributed by other extensions #451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| /*--------------------------------------------------------------------------------------------- | ||
| * Copyright (c) Red Hat, Inc. All rights reserved. | ||
| * Licensed under the MIT License. See License.txt in the project root for license information. | ||
| *--------------------------------------------------------------------------------------------*/ | ||
| import * as vscode from 'vscode'; | ||
| import { getDocUri, activate } from './helper'; | ||
| import * as assert from 'assert'; | ||
|
|
||
| describe('Tests for JSON Schema content provider', () => { | ||
| const SCHEMA = 'myschema'; | ||
| const schemaJSON = JSON.stringify({ | ||
| type: 'object', | ||
| properties: { | ||
| version: { | ||
| type: 'string', | ||
| description: 'A stringy string string', | ||
| enum: ['test'], | ||
| }, | ||
| }, | ||
| }); | ||
|
|
||
| function onRequestSchema1URI(resource: string): string | undefined { | ||
| if (resource.endsWith('completion.yaml') || resource.endsWith('basic.yaml')) { | ||
| return `${SCHEMA}://schema/porter`; | ||
| } | ||
| return undefined; | ||
| } | ||
|
|
||
| function onRequestSchema1Content(): string | undefined { | ||
| return schemaJSON; | ||
| } | ||
|
|
||
| it('should handle "json-schema" url', async () => { | ||
| const docUri = getDocUri('completion/completion.yaml'); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you run this test against windows you might need
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, test on windows passed successfully
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok |
||
| const client = await activate(docUri); | ||
| client._customSchemaContributors = {}; | ||
| client.registerContributor(SCHEMA, onRequestSchema1URI, onRequestSchema1Content); | ||
| const customUri = vscode.Uri.parse(`json-schema://some/url/schema.json#${SCHEMA}://some/path/schema.json`); | ||
| const doc = await vscode.workspace.openTextDocument(customUri); | ||
| const editor = await vscode.window.showTextDocument(doc); | ||
| assert.strictEqual(editor.document.getText(), JSON.stringify(JSON.parse(schemaJSON), null, 2)); | ||
| client._customSchemaContributors = {}; | ||
| }); | ||
| }); | ||
Uh oh!
There was an error while loading. Please reload this page.