Skip to content

Commit 1a2081b

Browse files
authored
feat(monaco-language-apidom): allow override ApiDOM Context (#4290)
Refs #4216
1 parent da81530 commit 1a2081b

File tree

6 files changed

+824
-1736
lines changed

6 files changed

+824
-1736
lines changed

docs/customization/plug-points/editor-monaco-language-apidom.md

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,43 @@
11
# editor-monaco plug points
22

3+
## Configuring web worker capabilities
4+
5+
Worker accepts configuration for a language service via ApiDOM Context configuration object.
6+
By default, this configuration looks like this:
7+
8+
```js
9+
{
10+
validatorProviders: [],
11+
completionProviders: [],
12+
performanceLogs: false,
13+
logLevel: apidomLS.LogLevel.WARN,
14+
defaultLanguageContent: {
15+
namespace: 'asyncapi',
16+
},
17+
completionContext: {
18+
maxNumberOfItems: 100,
19+
enableLSPFilter: false,
20+
},
21+
}
22+
```
23+
24+
If you want to override the default ApiDOM Context configuration object, you need to pass `apiDOMContext` option to the `EditorMonacoLanguageApiDOM` plugin.
25+
26+
```js
27+
EditorMonacoLanguageApiDOM({
28+
createData: {
29+
apiDOMContext: {
30+
completionContext: {
31+
enableLSPFilter: true, // enables "strict" word filtering (instead of default Monaco fuzzy matching; https://github.com/swagger-api/apidom/pull/2954)
32+
},
33+
},
34+
},
35+
});
36+
```
37+
38+
> NOTE: note that the provided ApiDOM Context configuration object is merged with default ApiDOM Context configuration object
39+
using [deep-extend](https://www.npmjs.com/package/deep-extend) npm package.
40+
341
## Extending web worker capabilities
442

543
`editor-monaco-language-apidom` comes with implementation of `apidom` language.
@@ -10,14 +48,14 @@ The plugin comes with `apidom.worker` utilizing ApiDOM capabilities.
1048

1149
Dynamic extension happens during runtime, and we recommend to use it only for simple use-cases.
1250

13-
First thing we need to do is to pass a `customApiDOMWorkerPath` option to the `EditorMonaco` plugin.
51+
First thing we need to do is to pass a `customApiDOMWorkerPath` option to the `EditorMonacoLanguageApiDOM` plugin.
1452

1553
```js
1654
EditorMonacoLanguageApiDOM({
1755
createData: {
1856
customApiDOMWorkerPath: 'https://example.com/index.js',
1957
},
20-
})
58+
});
2159
```
2260
`customApiDOMWorkerPath` is a URL (absolute or relative) of extending script. When the `apidom.worker`
2361
is bootstrapping it, it imports this URL using [importScripts](https://developer.mozilla.org/en-US/docs/Web/API/WorkerGlobalScope/importScripts).
@@ -103,15 +141,15 @@ it will be fetching data on demand from authorized REST endpoint.
103141

104142
### Dynamic extension
105143

106-
`EditorMonaco` plugin configuration.
144+
`EditorMonacoLanguageApiDOM` plugin configuration.
107145

108146
```js
109147
EditorMonacoLanguageApiDOM({
110148
createData: {
111149
authToken: 'c32d8b45-92fe-44f6-8b61-42c2107dfe87',
112150
customApiDOMWorkerPath: 'https://example.com/index.js',
113151
},
114-
})
152+
});
115153
```
116154

117155
**https://example.com/index.js**

0 commit comments

Comments
 (0)