@redocly/openapi-language-server 0.9.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.ts +744 -0
- package/lib/index.js +1 -1
- package/package.json +2 -2
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,744 @@
|
|
|
1
|
+
declare module '@redocly/openapi-language-server/config' {
|
|
2
|
+
import { TextDocuments } from 'vscode-languageserver/browser';
|
|
3
|
+
import { TextDocument } from 'vscode-languageserver-textdocument';
|
|
4
|
+
import { URI } from 'vscode-uri';
|
|
5
|
+
import { type ResolvedConfig } from '@redocly/openapi-core';
|
|
6
|
+
export interface SupportedLanguage {
|
|
7
|
+
languageId: string;
|
|
8
|
+
filePattern: RegExp;
|
|
9
|
+
}
|
|
10
|
+
export const yamlLanguage: SupportedLanguage;
|
|
11
|
+
export const jsonLanguage: SupportedLanguage;
|
|
12
|
+
export interface FileSystemProvider {
|
|
13
|
+
readFile(uri: URI, encoding?: string): Promise<string>;
|
|
14
|
+
readDir(uri: URI): Promise<any>;
|
|
15
|
+
stat(uri: URI): Promise<{
|
|
16
|
+
isFile(): boolean;
|
|
17
|
+
isDirectory(): boolean;
|
|
18
|
+
}>;
|
|
19
|
+
exists(uri: URI): Promise<boolean>;
|
|
20
|
+
}
|
|
21
|
+
type ConfigFinder = (uri: string) => Promise<string | undefined>;
|
|
22
|
+
interface RemoteScorecardAndPlugins {
|
|
23
|
+
scorecard: ResolvedConfig['scorecard'];
|
|
24
|
+
plugins: string | undefined;
|
|
25
|
+
}
|
|
26
|
+
export class Configuration {
|
|
27
|
+
private _fs;
|
|
28
|
+
private _documentManager;
|
|
29
|
+
private _findConfig;
|
|
30
|
+
private _getRootWorkspaceFolderURI;
|
|
31
|
+
private _scorecardStatus;
|
|
32
|
+
private _remoteScorecardAndPlugins;
|
|
33
|
+
constructor();
|
|
34
|
+
supportedLanguages: SupportedLanguage[];
|
|
35
|
+
registerFileSystemProvider(fsProvider: FileSystemProvider): void;
|
|
36
|
+
registerDocumentsProvider(documentProvider: TextDocuments<TextDocument>): void;
|
|
37
|
+
registerConfigFinder(configFinder: ConfigFinder): void;
|
|
38
|
+
registerRootWorkspaceFolderURIGetter(rootWorkspaceFolderURIGetter: () => Promise<string>): void;
|
|
39
|
+
registerRemoteScorecardAndPlugins(remoteScorecardAndPlugins: RemoteScorecardAndPlugins | undefined): void;
|
|
40
|
+
get remoteScorecardAndPlugins(): RemoteScorecardAndPlugins | undefined;
|
|
41
|
+
get fs(): FileSystemProvider;
|
|
42
|
+
get documents(): TextDocuments<TextDocument>;
|
|
43
|
+
get findConfig(): ConfigFinder;
|
|
44
|
+
get getRootWorkspaceFolderURI(): () => Promise<string>;
|
|
45
|
+
setScorecardStatus(status: 'pending' | 'enabled' | 'disabled'): void;
|
|
46
|
+
get scorecardStatus(): "pending" | "enabled" | "disabled";
|
|
47
|
+
}
|
|
48
|
+
export const languageServerConfig: Configuration;
|
|
49
|
+
export {};
|
|
50
|
+
|
|
51
|
+
}
|
|
52
|
+
declare module '@redocly/openapi-language-server/esbuild' {
|
|
53
|
+
export {};
|
|
54
|
+
|
|
55
|
+
}
|
|
56
|
+
declare module '@redocly/openapi-language-server/index' {
|
|
57
|
+
import { CompletionItem, type CompletionParams, type DefinitionParams, type DidChangeWatchedFilesParams, HoverParams, LocationLink } from 'vscode-languageserver/browser';
|
|
58
|
+
import { TextDocument } from 'vscode-languageserver-textdocument';
|
|
59
|
+
import { loadOpenAPIConfig, isConfigFile, isIgnoreFile, getConfigData } from '@redocly/openapi-language-server/server/openapi-config';
|
|
60
|
+
import { clearPluginsCache, getPluginFiles, isPluginFile } from '@redocly/openapi-language-server/server/plugins';
|
|
61
|
+
import { isEntityFile } from '@redocly/openapi-language-server/server/documents';
|
|
62
|
+
import { revalidateAllDocuments } from '@redocly/openapi-language-server/server/validation/index';
|
|
63
|
+
export { revalidateAllDocuments, loadOpenAPIConfig, clearPluginsCache, isConfigFile, isIgnoreFile, getConfigData, getPluginFiles, isPluginFile, isEntityFile, };
|
|
64
|
+
export { languageServerConfig } from '@redocly/openapi-language-server/config';
|
|
65
|
+
export { getDocumentByURI, isYamlFile, getPathsByDependency } from '@redocly/openapi-language-server/server/documents';
|
|
66
|
+
export { getContextData, getSpecVersion } from '@redocly/openapi-language-server/server/context-core';
|
|
67
|
+
export { parseUri, uriToAbsFSPath, isHttpPath } from '@redocly/openapi-language-server/server/path';
|
|
68
|
+
export { removeCirculars } from '@redocly/openapi-language-server/server/utils';
|
|
69
|
+
export * from '@redocly/openapi-language-server/server/types/context-core';
|
|
70
|
+
export * from '@redocly/openapi-language-server/server/types/hover';
|
|
71
|
+
export { type DefinitionData, type BundleData, bundleOpenAPI, getBundles } from '@redocly/openapi-language-server/server/bundle';
|
|
72
|
+
export class OpenapiLanguageServer {
|
|
73
|
+
onCompletion(params: CompletionParams): Promise<CompletionItem[]>;
|
|
74
|
+
onCompletionResolve(item: CompletionItem): Promise<CompletionItem>;
|
|
75
|
+
onHover(params: HoverParams): Promise<import("@redocly/openapi-language-server/server/types/hover").HoverWithMetadata | null>;
|
|
76
|
+
validateOpenAPI(textDocument: TextDocument): Promise<import("vscode-languageserver/browser").PublishDiagnosticsParams[]>;
|
|
77
|
+
onDidChangeWatchedFiles(params: DidChangeWatchedFilesParams): Promise<(Promise<import("vscode-languageserver/browser").PublishDiagnosticsParams[]> | Promise<Promise<import("vscode-languageserver/browser").PublishDiagnosticsParams[]>>)[] | undefined>;
|
|
78
|
+
onDidConfigChange(uri: string): Promise<(Promise<import("vscode-languageserver/browser").PublishDiagnosticsParams[]> | Promise<Promise<import("vscode-languageserver/browser").PublishDiagnosticsParams[]>>)[]>;
|
|
79
|
+
onDidChangeConfiguration(): Promise<(Promise<import("vscode-languageserver/browser").PublishDiagnosticsParams[]> | Promise<Promise<import("vscode-languageserver/browser").PublishDiagnosticsParams[]>>)[]>;
|
|
80
|
+
onDefinition(params: DefinitionParams): Promise<LocationLink[]>;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
}
|
|
84
|
+
declare module '@redocly/openapi-language-server/server/__tests__/context-core.test' {
|
|
85
|
+
export {};
|
|
86
|
+
|
|
87
|
+
}
|
|
88
|
+
declare module '@redocly/openapi-language-server/server/__tests__/documents.test' {
|
|
89
|
+
export {};
|
|
90
|
+
|
|
91
|
+
}
|
|
92
|
+
declare module '@redocly/openapi-language-server/server/__tests__/external-resolver.test' {
|
|
93
|
+
export {};
|
|
94
|
+
|
|
95
|
+
}
|
|
96
|
+
declare module '@redocly/openapi-language-server/server/__tests__/formatters/components/title.test' {
|
|
97
|
+
export {};
|
|
98
|
+
|
|
99
|
+
}
|
|
100
|
+
declare module '@redocly/openapi-language-server/server/__tests__/formatters/hover-formatter.test' {
|
|
101
|
+
export {};
|
|
102
|
+
|
|
103
|
+
}
|
|
104
|
+
declare module '@redocly/openapi-language-server/server/__tests__/openapi-config.test' {
|
|
105
|
+
export {};
|
|
106
|
+
|
|
107
|
+
}
|
|
108
|
+
declare module '@redocly/openapi-language-server/server/__tests__/path-completion.test' {
|
|
109
|
+
export {};
|
|
110
|
+
|
|
111
|
+
}
|
|
112
|
+
declare module '@redocly/openapi-language-server/server/__tests__/path-resolver-context.test' {
|
|
113
|
+
export {};
|
|
114
|
+
|
|
115
|
+
}
|
|
116
|
+
declare module '@redocly/openapi-language-server/server/__tests__/path.test' {
|
|
117
|
+
export {};
|
|
118
|
+
|
|
119
|
+
}
|
|
120
|
+
declare module '@redocly/openapi-language-server/server/__tests__/plugins.test' {
|
|
121
|
+
export {};
|
|
122
|
+
|
|
123
|
+
}
|
|
124
|
+
declare module '@redocly/openapi-language-server/server/__tests__/test-utils' {
|
|
125
|
+
/** Converts path to OS-native format (slashes, drive letter). Use rootFromBase when path is '/' or '' to resolve the actual filesystem root (e.g. C:\ on Windows). */
|
|
126
|
+
export const toOSPath: (p: string, rootFromBase?: string) => string;
|
|
127
|
+
export const toOSPathFields: <T extends object>(obj: T, pathKeys?: (keyof T)[], options?: {
|
|
128
|
+
rootFromBase?: string;
|
|
129
|
+
}) => T;
|
|
130
|
+
export const toOSPathFieldsList: <T extends object>(items: T[], pathKeys?: (keyof T)[], options?: {
|
|
131
|
+
rootFromBase?: string;
|
|
132
|
+
}) => T[];
|
|
133
|
+
|
|
134
|
+
}
|
|
135
|
+
declare module '@redocly/openapi-language-server/server/__tests__/utils.test' {
|
|
136
|
+
export {};
|
|
137
|
+
|
|
138
|
+
}
|
|
139
|
+
declare module '@redocly/openapi-language-server/server/bundle' {
|
|
140
|
+
import { type NormalizedProblem, type NormalizedNodeType } from '@redocly/openapi-core';
|
|
141
|
+
import { TextDocument } from 'vscode-languageserver-textdocument';
|
|
142
|
+
export type DefinitionData = {
|
|
143
|
+
name: string;
|
|
144
|
+
uri: string;
|
|
145
|
+
};
|
|
146
|
+
export type BundleData = DefinitionData & {
|
|
147
|
+
definition: Record<string, any>;
|
|
148
|
+
rootType: NormalizedNodeType;
|
|
149
|
+
refTypes: [string, NormalizedNodeType][];
|
|
150
|
+
htmlTempalteStyles?: string | null;
|
|
151
|
+
errors?: NormalizedProblem[];
|
|
152
|
+
};
|
|
153
|
+
export function bundleOpenAPI(textDocument: TextDocument, errors: NormalizedProblem[]): Promise<void>;
|
|
154
|
+
export function getBundles(): BundleData[];
|
|
155
|
+
export function getRefTypes(path: string): NormalizedNodeType | undefined | null;
|
|
156
|
+
|
|
157
|
+
}
|
|
158
|
+
declare module '@redocly/openapi-language-server/server/completion/yaml/KeyCompletion' {
|
|
159
|
+
import { CompletionItem, CompletionItemKind, InsertTextFormat, Command } from 'vscode-languageserver/browser';
|
|
160
|
+
import type { CompletionItemOptions } from '@redocly/openapi-language-server/server/types/completion';
|
|
161
|
+
export interface KeyCompletionOptions extends CompletionItemOptions {
|
|
162
|
+
insertTextFormat?: InsertTextFormat;
|
|
163
|
+
data?: any;
|
|
164
|
+
}
|
|
165
|
+
export class KeyCompletion implements CompletionItem {
|
|
166
|
+
kind: CompletionItemKind;
|
|
167
|
+
label: string;
|
|
168
|
+
insertText: string;
|
|
169
|
+
filterText: string;
|
|
170
|
+
sortText?: string;
|
|
171
|
+
command?: Command;
|
|
172
|
+
insertTextFormat: InsertTextFormat;
|
|
173
|
+
data?: any;
|
|
174
|
+
constructor({ kind, label, insertText, insertTextFormat, filterText, sortText, data, }: KeyCompletionOptions);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
}
|
|
178
|
+
declare module '@redocly/openapi-language-server/server/completion/yaml/LocalFileCompletion' {
|
|
179
|
+
import { ValueCompletion, ValueCompletionOptions } from '@redocly/openapi-language-server/server/completion/yaml/ValueCompletion';
|
|
180
|
+
export class LocalFileCompletion extends ValueCompletion {
|
|
181
|
+
constructor(completionOptions: ValueCompletionOptions);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
}
|
|
185
|
+
declare module '@redocly/openapi-language-server/server/completion/yaml/LocalFolderCompletion' {
|
|
186
|
+
import { Command } from 'vscode-languageserver/browser';
|
|
187
|
+
import { ValueCompletion, ValueCompletionOptions } from '@redocly/openapi-language-server/server/completion/yaml/ValueCompletion';
|
|
188
|
+
export class LocalFolderCompletion extends ValueCompletion {
|
|
189
|
+
command: Command;
|
|
190
|
+
constructor(completionOptions: ValueCompletionOptions);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
}
|
|
194
|
+
declare module '@redocly/openapi-language-server/server/completion/yaml/ValueCompletion' {
|
|
195
|
+
import { YAMLScalar } from '@redocly/yaml-language-server-parser';
|
|
196
|
+
import { CompletionItem, CompletionItemKind, TextEdit, InsertReplaceEdit, Position, Command } from 'vscode-languageserver/browser';
|
|
197
|
+
import type { CompletionItemOptions } from '@redocly/openapi-language-server/server/types/completion';
|
|
198
|
+
export interface ValueCompletionDataOptions {
|
|
199
|
+
position?: Position;
|
|
200
|
+
node?: YAMLScalar;
|
|
201
|
+
lineOffset?: number;
|
|
202
|
+
}
|
|
203
|
+
export interface ValueCompletionOptions extends CompletionItemOptions {
|
|
204
|
+
value?: string;
|
|
205
|
+
data: ValueCompletionDataOptions;
|
|
206
|
+
}
|
|
207
|
+
export class ValueCompletion implements CompletionItem {
|
|
208
|
+
kind: CompletionItemKind;
|
|
209
|
+
label: string;
|
|
210
|
+
insertText: string;
|
|
211
|
+
filterText: string;
|
|
212
|
+
sortText?: string;
|
|
213
|
+
command?: Command;
|
|
214
|
+
textEdit?: TextEdit | InsertReplaceEdit;
|
|
215
|
+
constructor({ kind, label, value, textEdit, filterText, sortText, data, }: ValueCompletionOptions);
|
|
216
|
+
getTextEdit(node: YAMLScalar, position: Position, lineOffset: number): TextEdit | InsertReplaceEdit;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
}
|
|
220
|
+
declare module '@redocly/openapi-language-server/server/completion/yaml/__tests__/KeyCompletion.test' {
|
|
221
|
+
export {};
|
|
222
|
+
|
|
223
|
+
}
|
|
224
|
+
declare module '@redocly/openapi-language-server/server/completion/yaml/__tests__/insert-snippet-utils.test' {
|
|
225
|
+
export {};
|
|
226
|
+
|
|
227
|
+
}
|
|
228
|
+
declare module '@redocly/openapi-language-server/server/completion/yaml/common' {
|
|
229
|
+
export const fieldNames: {
|
|
230
|
+
example: string;
|
|
231
|
+
default: string;
|
|
232
|
+
enum: string;
|
|
233
|
+
ref: string;
|
|
234
|
+
};
|
|
235
|
+
export const userEnumCompletionKeys: string[];
|
|
236
|
+
|
|
237
|
+
}
|
|
238
|
+
declare module '@redocly/openapi-language-server/server/completion/yaml/completion' {
|
|
239
|
+
import { CompletionItem, Position } from 'vscode-languageserver/browser';
|
|
240
|
+
import { type DocumentUri } from 'vscode-languageserver-textdocument';
|
|
241
|
+
import type * as yamlAst from '@redocly/yaml-language-server-parser';
|
|
242
|
+
import { ValueCompletion } from '@redocly/openapi-language-server/server/completion/yaml/ValueCompletion';
|
|
243
|
+
import { YamlCompletionContext } from '@redocly/openapi-language-server/server/completion/yaml/context';
|
|
244
|
+
export function getCompletionKeys(completionContext: YamlCompletionContext): CompletionItem[];
|
|
245
|
+
export function getCompletionValues(uri: DocumentUri, completionContext: YamlCompletionContext<yamlAst.YAMLScalar>): Promise<ValueCompletion[]>;
|
|
246
|
+
export function getCompletion(uri: DocumentUri, position: Position): Promise<CompletionItem[]>;
|
|
247
|
+
export function resolveCompletion(item: CompletionItem): CompletionItem;
|
|
248
|
+
|
|
249
|
+
}
|
|
250
|
+
declare module '@redocly/openapi-language-server/server/completion/yaml/context' {
|
|
251
|
+
import { type DocumentUri, type Position } from 'vscode-languageserver-textdocument';
|
|
252
|
+
import { YAMLNode } from '@redocly/yaml-language-server-parser';
|
|
253
|
+
import { URI } from 'vscode-uri';
|
|
254
|
+
import { type NodePath } from '@redocly/openapi-language-server/server/types/context-core';
|
|
255
|
+
import { type ExtendedNormalizedNodeType } from '@redocly/openapi-language-server/server/types/completion';
|
|
256
|
+
export interface YamlCompletionContext<NodeType = YAMLNode> {
|
|
257
|
+
currentAst: YAMLNode;
|
|
258
|
+
node: NodeType;
|
|
259
|
+
nodePath: NodePath;
|
|
260
|
+
position: Position;
|
|
261
|
+
lineText: string;
|
|
262
|
+
lineOffset: number;
|
|
263
|
+
openApiType: ExtendedNormalizedNodeType | null;
|
|
264
|
+
}
|
|
265
|
+
export interface RefPathResolverContext {
|
|
266
|
+
docAbsolutePath: URI;
|
|
267
|
+
docAbsoluteDirPath: URI;
|
|
268
|
+
refPath: string;
|
|
269
|
+
refDirPath: URI;
|
|
270
|
+
refDirAbsolutePath: URI;
|
|
271
|
+
isAbsolutePath: boolean;
|
|
272
|
+
root: string;
|
|
273
|
+
}
|
|
274
|
+
export function createCompletionContext<NodeType = YAMLNode>(uri: DocumentUri, position: Position): Promise<YamlCompletionContext<NodeType>>;
|
|
275
|
+
export function createRefPathResolverContext(uri: DocumentUri, refPath: string): Promise<RefPathResolverContext>;
|
|
276
|
+
|
|
277
|
+
}
|
|
278
|
+
declare module '@redocly/openapi-language-server/server/completion/yaml/insert-snippet-utils' {
|
|
279
|
+
import { type NormalizedNodeType } from '@redocly/openapi-core';
|
|
280
|
+
export type PartialNodeType = Pick<NormalizedNodeType, 'items' | 'required'>;
|
|
281
|
+
function getKeyValue(key: string, type?: PartialNodeType): string;
|
|
282
|
+
function getBeforeKeyValue(key: string, value: string, beforeKey: string, type?: PartialNodeType): string;
|
|
283
|
+
function getAfterKeyValue(key: string): "" | ": ";
|
|
284
|
+
function getBeforeKey(lineText?: string): "" | " " | "\n ";
|
|
285
|
+
function getAfterValue(beforeKey: string, properties?: NormalizedNodeType['properties']): "" | "\n " | "\n ";
|
|
286
|
+
function getInsertSnippet(key: string, data?: {
|
|
287
|
+
properties?: NormalizedNodeType['properties'];
|
|
288
|
+
lineText: string;
|
|
289
|
+
} & PartialNodeType, addNewLine?: boolean): string;
|
|
290
|
+
export { getInsertSnippet, getAfterKeyValue, getAfterValue, getKeyValue, getBeforeKey, getBeforeKeyValue, };
|
|
291
|
+
|
|
292
|
+
}
|
|
293
|
+
declare module '@redocly/openapi-language-server/server/completion/yaml/paths' {
|
|
294
|
+
import { DocumentUri } from 'vscode-languageserver-textdocument';
|
|
295
|
+
import { YAMLScalar } from '@redocly/yaml-language-server-parser';
|
|
296
|
+
import { SupportedLanguage } from '@redocly/openapi-language-server/config';
|
|
297
|
+
import { LocalFolderCompletion } from '@redocly/openapi-language-server/server/completion/yaml/LocalFolderCompletion';
|
|
298
|
+
import { LocalFileCompletion } from '@redocly/openapi-language-server/server/completion/yaml/LocalFileCompletion';
|
|
299
|
+
import { YamlCompletionContext, RefPathResolverContext } from '@redocly/openapi-language-server/server/completion/yaml/context';
|
|
300
|
+
export const LOCAL_FILES_SUPPORTED_SUGGESTIONS: SupportedLanguage[];
|
|
301
|
+
export enum FsNodeType {
|
|
302
|
+
File = 0,
|
|
303
|
+
Folder = 1
|
|
304
|
+
}
|
|
305
|
+
export interface RefFileStat {
|
|
306
|
+
type: FsNodeType;
|
|
307
|
+
name: string;
|
|
308
|
+
}
|
|
309
|
+
export interface RefPathOption extends RefFileStat {
|
|
310
|
+
value: string;
|
|
311
|
+
matchBy: string;
|
|
312
|
+
sortBy: string;
|
|
313
|
+
}
|
|
314
|
+
export function getToTopOption(pathResolverContext: RefPathResolverContext): RefPathOption;
|
|
315
|
+
export function getChildrenOfPath(files: string[], config: {
|
|
316
|
+
supportedFiles: SupportedLanguage[];
|
|
317
|
+
}, pathResolverContext: RefPathResolverContext): Promise<RefFileStat[]>;
|
|
318
|
+
export function getRefPathOptions(fileStats: RefFileStat[], pathResolverContext: RefPathResolverContext): RefPathOption[];
|
|
319
|
+
export function getLocalFsRefs(uri: DocumentUri, completionContext: YamlCompletionContext<YAMLScalar>): Promise<(LocalFolderCompletion | LocalFileCompletion)[]>;
|
|
320
|
+
|
|
321
|
+
}
|
|
322
|
+
declare module '@redocly/openapi-language-server/server/context-core' {
|
|
323
|
+
import { type SpecVersion, type SpecMajorVersion, type NormalizedNodeType } from '@redocly/openapi-core';
|
|
324
|
+
import * as yamlAst from '@redocly/yaml-language-server-parser';
|
|
325
|
+
import { type Position } from 'vscode-languageserver/browser';
|
|
326
|
+
import { type ContextData, type ExistingValues, type OpenApiVersion, type TextDocumentWithLineOffset, type NodeWithPath, type NodePath, NodeWithItems } from '@redocly/openapi-language-server/server/types/context-core';
|
|
327
|
+
export function getContextData(uri: string, position: Position): Promise<ContextData>;
|
|
328
|
+
export function getSpecVersion(uri: string): Promise<OpenApiVersion<"oas2" | "oas3_0" | "oas3_1" | "oas3_2" | "async2" | "async3" | "arazzo1" | "overlay1" | "openrpc1">>;
|
|
329
|
+
export function getAstNodeByPath(currentAst: yamlAst.YAMLNode | null, path: (number | string)[]): yamlAst.YAMLNode | null;
|
|
330
|
+
export function getAstNodeByPosition(start: NodeWithPath, position: Position, document: TextDocumentWithLineOffset, isContextData?: boolean): NodeWithPath;
|
|
331
|
+
export function getNodeLineIndent(node: yamlAst.YAMLNode | null | undefined, document: TextDocumentWithLineOffset): number;
|
|
332
|
+
export function getTypesByNodePath(types: any, nodePath: NodePath, currentAst: NodeWithItems): {
|
|
333
|
+
currentType: NormalizedNodeType | null;
|
|
334
|
+
parentType: NormalizedNodeType | null;
|
|
335
|
+
endPath?: string | number;
|
|
336
|
+
};
|
|
337
|
+
export function getRootTypes(ast: NodeWithItems, uri: string): Promise<NormalizedNodeType | null>;
|
|
338
|
+
export function getDescriptionVersion(ast: yamlAst.YAMLNode): OpenApiVersion<SpecVersion>;
|
|
339
|
+
export function getDescriptionMajorVersion(ast: yamlAst.YAMLNode): OpenApiVersion<SpecMajorVersion>;
|
|
340
|
+
export function getChildNodes(node?: yamlAst.YAMLNode | null): yamlAst.YAMLNode[];
|
|
341
|
+
export function getExistingValues(node: yamlAst.YAMLSequence, values?: ExistingValues, indent?: number): ExistingValues;
|
|
342
|
+
|
|
343
|
+
}
|
|
344
|
+
declare module '@redocly/openapi-language-server/server/documents' {
|
|
345
|
+
import { DocumentUri } from 'vscode-languageserver/browser';
|
|
346
|
+
import { TextDocument } from 'vscode-languageserver-textdocument';
|
|
347
|
+
import * as yamlAst from '@redocly/yaml-language-server-parser';
|
|
348
|
+
export type DocumentStats = {
|
|
349
|
+
dependencyPaths: Set<string>;
|
|
350
|
+
durationMS: number;
|
|
351
|
+
};
|
|
352
|
+
export type DependencyStats = {
|
|
353
|
+
documentPath: string;
|
|
354
|
+
durationMS: number;
|
|
355
|
+
};
|
|
356
|
+
export function updateDependencyMap(path: string, stats: DocumentStats): Map<string, DocumentStats>;
|
|
357
|
+
export function getPathsByDependency(depPath: string): DependencyStats[];
|
|
358
|
+
export function getDocumentLanguageId(uri: DocumentUri): string;
|
|
359
|
+
export function getDocumentByURI(uri: DocumentUri): Promise<TextDocument>;
|
|
360
|
+
export function isJsonFile(uri: DocumentUri): boolean;
|
|
361
|
+
export function isYamlFile(uri: DocumentUri): boolean;
|
|
362
|
+
export function isEntityFile({ uri, ast, textDocument, }: {
|
|
363
|
+
uri: DocumentUri;
|
|
364
|
+
ast?: yamlAst.YAMLNode;
|
|
365
|
+
textDocument?: TextDocument;
|
|
366
|
+
}): boolean;
|
|
367
|
+
|
|
368
|
+
}
|
|
369
|
+
declare module '@redocly/openapi-language-server/server/external-resolver' {
|
|
370
|
+
import { BaseResolver, Source } from '@redocly/openapi-core';
|
|
371
|
+
export class ExternalResolver extends BaseResolver {
|
|
372
|
+
resolveExternalRef(base: string | null, ref: string): string;
|
|
373
|
+
loadExternalRef(absoluteRef: string): Promise<Source>;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
}
|
|
377
|
+
declare module '@redocly/openapi-language-server/server/fixtures/dir1/file1' {
|
|
378
|
+
|
|
379
|
+
}
|
|
380
|
+
declare module '@redocly/openapi-language-server/server/formatters/components/title' {
|
|
381
|
+
export function documentationTitle({ nodePath, propertyTypeName, typeName, documentationLink, }: {
|
|
382
|
+
nodePath: string[];
|
|
383
|
+
propertyTypeName?: string | number;
|
|
384
|
+
typeName: string | undefined;
|
|
385
|
+
documentationLink?: string;
|
|
386
|
+
}): string;
|
|
387
|
+
|
|
388
|
+
}
|
|
389
|
+
declare module '@redocly/openapi-language-server/server/formatters/hover-formatter' {
|
|
390
|
+
import type { ContextData } from '@redocly/openapi-language-server/server/types/context-core';
|
|
391
|
+
export function formatHover(contextData: ContextData | null): string;
|
|
392
|
+
|
|
393
|
+
}
|
|
394
|
+
declare module '@redocly/openapi-language-server/server/handlers/on-hover-handler' {
|
|
395
|
+
import { HoverParams } from 'vscode-languageserver';
|
|
396
|
+
import type { HoverWithMetadata } from '@redocly/openapi-language-server/server/types/hover';
|
|
397
|
+
export function onHover(params: HoverParams): Promise<HoverWithMetadata | null>;
|
|
398
|
+
|
|
399
|
+
}
|
|
400
|
+
declare module '@redocly/openapi-language-server/server/handlers/yaml-definition-handler' {
|
|
401
|
+
import { LocationLink } from 'vscode-languageserver';
|
|
402
|
+
import type { DefinitionParams } from 'vscode-languageserver';
|
|
403
|
+
export function handleDefinition({ position, textDocument, }: DefinitionParams): Promise<LocationLink[] | void>;
|
|
404
|
+
|
|
405
|
+
}
|
|
406
|
+
declare module '@redocly/openapi-language-server/server/hints' {
|
|
407
|
+
import { CompletionItem } from 'vscode-languageserver/browser';
|
|
408
|
+
import { ExtendedNormalizedNodeType } from '@redocly/openapi-language-server/server/types/completion';
|
|
409
|
+
export const START_SEQ_LABEL = "newItem";
|
|
410
|
+
export const START_MAP_LABEL = "propertyName";
|
|
411
|
+
export const ADD_NEW_LINE = "newLine";
|
|
412
|
+
export function hasHints(type: ExtendedNormalizedNodeType): boolean;
|
|
413
|
+
export function getAdditionalCompletionItem(name: string): CompletionItem[];
|
|
414
|
+
|
|
415
|
+
}
|
|
416
|
+
declare module '@redocly/openapi-language-server/server/openapi-config' {
|
|
417
|
+
import { type Config } from '@redocly/openapi-core';
|
|
418
|
+
type LoadOpenAPIConfigResult = {
|
|
419
|
+
config: Config;
|
|
420
|
+
loadFailed: boolean;
|
|
421
|
+
};
|
|
422
|
+
export function loadOpenAPIConfig(uri: string | undefined, opts?: {
|
|
423
|
+
createEventHandleLoadConfigError?: (message: string) => void;
|
|
424
|
+
}): Promise<LoadOpenAPIConfigResult>;
|
|
425
|
+
export function getConfigData(url?: string): Promise<Config>;
|
|
426
|
+
export function isConfigFile(uri: string): Promise<boolean>;
|
|
427
|
+
export function isRootConfigFile(uri: string): Promise<boolean>;
|
|
428
|
+
export function isIgnoreFile(uri: string): boolean;
|
|
429
|
+
export {};
|
|
430
|
+
|
|
431
|
+
}
|
|
432
|
+
declare module '@redocly/openapi-language-server/server/openapi-extensions' {
|
|
433
|
+
import { mapTypeToComponent } from '@redocly/openapi-core';
|
|
434
|
+
import { ExtendedNormalizedNodeType } from '@redocly/openapi-language-server/server/types/completion';
|
|
435
|
+
const typeExtensions: {
|
|
436
|
+
Schema: {
|
|
437
|
+
name: string;
|
|
438
|
+
value: {
|
|
439
|
+
type: string;
|
|
440
|
+
name: string;
|
|
441
|
+
};
|
|
442
|
+
}[];
|
|
443
|
+
PathItem: {
|
|
444
|
+
name: string;
|
|
445
|
+
value: {
|
|
446
|
+
type: string;
|
|
447
|
+
name: string;
|
|
448
|
+
};
|
|
449
|
+
}[];
|
|
450
|
+
Parameter: {
|
|
451
|
+
name: string;
|
|
452
|
+
value: {
|
|
453
|
+
type: string;
|
|
454
|
+
name: string;
|
|
455
|
+
};
|
|
456
|
+
}[];
|
|
457
|
+
Response: {
|
|
458
|
+
name: string;
|
|
459
|
+
value: {
|
|
460
|
+
type: string;
|
|
461
|
+
name: string;
|
|
462
|
+
};
|
|
463
|
+
}[];
|
|
464
|
+
Example: {
|
|
465
|
+
name: string;
|
|
466
|
+
value: {
|
|
467
|
+
type: string;
|
|
468
|
+
name: string;
|
|
469
|
+
};
|
|
470
|
+
}[];
|
|
471
|
+
RequestBody: {
|
|
472
|
+
name: string;
|
|
473
|
+
value: {
|
|
474
|
+
type: string;
|
|
475
|
+
name: string;
|
|
476
|
+
};
|
|
477
|
+
}[];
|
|
478
|
+
Header: {
|
|
479
|
+
name: string;
|
|
480
|
+
value: {
|
|
481
|
+
type: string;
|
|
482
|
+
name: string;
|
|
483
|
+
};
|
|
484
|
+
}[];
|
|
485
|
+
SecuritySchema: {
|
|
486
|
+
name: string;
|
|
487
|
+
value: {
|
|
488
|
+
type: string;
|
|
489
|
+
name: string;
|
|
490
|
+
};
|
|
491
|
+
}[];
|
|
492
|
+
Link: {
|
|
493
|
+
name: string;
|
|
494
|
+
value: {
|
|
495
|
+
type: string;
|
|
496
|
+
name: string;
|
|
497
|
+
};
|
|
498
|
+
}[];
|
|
499
|
+
Callback: {
|
|
500
|
+
name: string;
|
|
501
|
+
value: {
|
|
502
|
+
type: string;
|
|
503
|
+
name: string;
|
|
504
|
+
};
|
|
505
|
+
}[];
|
|
506
|
+
};
|
|
507
|
+
function extendOASType(type: ExtendedNormalizedNodeType): ExtendedNormalizedNodeType;
|
|
508
|
+
export { typeExtensions, extendOASType, mapTypeToComponent };
|
|
509
|
+
|
|
510
|
+
}
|
|
511
|
+
declare module '@redocly/openapi-language-server/server/path' {
|
|
512
|
+
import { DocumentUri } from 'vscode-languageserver/browser';
|
|
513
|
+
import { URI } from 'vscode-uri';
|
|
514
|
+
export function arePathsEqual(path1: string, path2: string): boolean;
|
|
515
|
+
export function parseUri(path: string): URI;
|
|
516
|
+
export function absPathToUri(absPath: string): string;
|
|
517
|
+
export function uriToAbsFSPath(uri: DocumentUri): string;
|
|
518
|
+
export function isHttpPath(path: string): boolean;
|
|
519
|
+
export function uriBaseName(uri: DocumentUri): string;
|
|
520
|
+
export function getFileExtension(uri: DocumentUri): string;
|
|
521
|
+
export function noTrailingSlash(path: string): string;
|
|
522
|
+
export function getClosestExistingDir(uri: URI, baseDir?: string): Promise<URI>;
|
|
523
|
+
|
|
524
|
+
}
|
|
525
|
+
declare module '@redocly/openapi-language-server/server/plugins' {
|
|
526
|
+
import { type Config } from '@redocly/openapi-core';
|
|
527
|
+
export { clearPluginsCache } from '@redocly/openapi-core';
|
|
528
|
+
export function getPluginFiles(config: Config): Promise<string[]>;
|
|
529
|
+
export function isPluginFile(filePath: string, pluginFiles: string[]): boolean;
|
|
530
|
+
|
|
531
|
+
}
|
|
532
|
+
declare module '@redocly/openapi-language-server/server/sort' {
|
|
533
|
+
export function getSortText(typeName: string | null, label?: string): string;
|
|
534
|
+
export enum SortTypes {
|
|
535
|
+
FileCompletion = "FileCompletion",
|
|
536
|
+
FolderCompletion = "FolderCompletion",
|
|
537
|
+
LocalComponentCompletion = "LocalComponentCompletion",
|
|
538
|
+
NewLine = "newLine",
|
|
539
|
+
PropertyName = "propertyName",
|
|
540
|
+
NewItem = "newItem",
|
|
541
|
+
PathMap = "PathMap",
|
|
542
|
+
MediaTypeMap = "MediaTypeMap",
|
|
543
|
+
Root = "Root",
|
|
544
|
+
RootOpenapi = "Root_openapi",
|
|
545
|
+
RootInfo = "Root_info",
|
|
546
|
+
RootJsonSchemaDialect = "Root_jsonSchemaDialect",
|
|
547
|
+
RootServers = "Root_servers",
|
|
548
|
+
RootPaths = "Root_paths",
|
|
549
|
+
RootWebhooks = "Root_webhooks",
|
|
550
|
+
RootComponents = "Root_components",
|
|
551
|
+
RootSecurity = "Root_security",
|
|
552
|
+
RootTags = "Root_tags",
|
|
553
|
+
RootExternalDocs = "Root_externalDocs",
|
|
554
|
+
Info = "Info",
|
|
555
|
+
InfoTitle = "Info_title",
|
|
556
|
+
InfoSummary = "Info_summary",
|
|
557
|
+
InfoDescription = "Info_description",
|
|
558
|
+
InfoTermsOfService = "Info_termsOfService",
|
|
559
|
+
InfoContact = "Info_contact",
|
|
560
|
+
ContactName = "Contact_name",
|
|
561
|
+
ContactUrl = "Contact_url",
|
|
562
|
+
ContactEmail = "Contact_email",
|
|
563
|
+
InfoLicense = "Info_license",
|
|
564
|
+
LicenseName = "License_name",
|
|
565
|
+
LicenseIdentifier = "License_identifier",
|
|
566
|
+
LicenseUrl = "License_url",
|
|
567
|
+
InfoVersion = "Info_version",
|
|
568
|
+
jsonSchemaDialect = "jsonSchemaDialect",
|
|
569
|
+
ServerList = "Server_List",
|
|
570
|
+
ServerUrl = "Server_url",
|
|
571
|
+
ServerDescription = "Server_description",
|
|
572
|
+
ServerVariables = "Server_variables",
|
|
573
|
+
Default = "Default"
|
|
574
|
+
}
|
|
575
|
+
export const sortLabelObject: Record<string, string>;
|
|
576
|
+
|
|
577
|
+
}
|
|
578
|
+
declare module '@redocly/openapi-language-server/server/types/completion' {
|
|
579
|
+
import { CompletionItemKind, TextEdit, InsertReplaceEdit } from 'vscode-languageserver/browser';
|
|
580
|
+
import { type NormalizedNodeType } from '@redocly/openapi-core';
|
|
581
|
+
type ExtendedNormalizedNodeType = Omit<NormalizedNodeType, 'properties'> & {
|
|
582
|
+
isExample?: true;
|
|
583
|
+
enum?: string[];
|
|
584
|
+
type?: string;
|
|
585
|
+
properties?: NormalizedNodeType['properties'];
|
|
586
|
+
};
|
|
587
|
+
interface CompletionItemOptions {
|
|
588
|
+
label: string;
|
|
589
|
+
kind?: CompletionItemKind;
|
|
590
|
+
sortText?: string;
|
|
591
|
+
textEdit?: TextEdit | InsertReplaceEdit;
|
|
592
|
+
insertText?: string;
|
|
593
|
+
filterText?: string;
|
|
594
|
+
}
|
|
595
|
+
export type { ExtendedNormalizedNodeType, CompletionItemOptions };
|
|
596
|
+
|
|
597
|
+
}
|
|
598
|
+
declare module '@redocly/openapi-language-server/server/types/context-core' {
|
|
599
|
+
import yamlAst from '@redocly/yaml-language-server-parser';
|
|
600
|
+
import type { TextDocument } from 'vscode-languageserver-textdocument';
|
|
601
|
+
import type { NormalizedNodeType, SpecMajorVersion } from '@redocly/openapi-core';
|
|
602
|
+
export enum ContextErrorCodes {
|
|
603
|
+
FILE_TYPE_NOT_SUPPORTED = 0
|
|
604
|
+
}
|
|
605
|
+
export type ContextError = {
|
|
606
|
+
error: {
|
|
607
|
+
code: ContextErrorCodes;
|
|
608
|
+
message: string;
|
|
609
|
+
};
|
|
610
|
+
};
|
|
611
|
+
export type ExistingValues = {
|
|
612
|
+
[key: string]: {
|
|
613
|
+
value: string | null;
|
|
614
|
+
startOffset: number;
|
|
615
|
+
endOffset: number | null;
|
|
616
|
+
indent: number;
|
|
617
|
+
type?: 'scalar' | 'map' | 'sequence';
|
|
618
|
+
rawValue?: string;
|
|
619
|
+
};
|
|
620
|
+
};
|
|
621
|
+
export type ContextData = {
|
|
622
|
+
nodePath: (string | number)[];
|
|
623
|
+
endPath?: string | number;
|
|
624
|
+
type: NormalizedNodeType | null;
|
|
625
|
+
existingValues: ExistingValues;
|
|
626
|
+
types: NormalizedNodeType | null;
|
|
627
|
+
descriptionVersion: SpecMajorVersion | null;
|
|
628
|
+
};
|
|
629
|
+
export type OpenApiVersion<T> = {
|
|
630
|
+
version: T;
|
|
631
|
+
isDefault: boolean;
|
|
632
|
+
};
|
|
633
|
+
export type NodePath = (string | number)[];
|
|
634
|
+
export type NodeWithPath = {
|
|
635
|
+
node: yamlAst.YAMLNode | null;
|
|
636
|
+
nodePath: NodePath;
|
|
637
|
+
};
|
|
638
|
+
export type NodeWithItems = yamlAst.YAMLNode & {
|
|
639
|
+
items?: yamlAst.YAMLNode[];
|
|
640
|
+
};
|
|
641
|
+
export type TextDocumentWithLineOffset = TextDocument & {
|
|
642
|
+
_lineOffsets: number[];
|
|
643
|
+
};
|
|
644
|
+
|
|
645
|
+
}
|
|
646
|
+
declare module '@redocly/openapi-language-server/server/types/hover' {
|
|
647
|
+
import type { Hover } from 'vscode-languageserver';
|
|
648
|
+
export type HoverMetadata = {
|
|
649
|
+
nodePath: (string | number)[];
|
|
650
|
+
endPath?: string | number;
|
|
651
|
+
typeName?: string;
|
|
652
|
+
descriptionVersion: string | null;
|
|
653
|
+
};
|
|
654
|
+
export type HoverWithMetadata = Hover & {
|
|
655
|
+
metadata?: HoverMetadata;
|
|
656
|
+
};
|
|
657
|
+
|
|
658
|
+
}
|
|
659
|
+
declare module '@redocly/openapi-language-server/server/utils' {
|
|
660
|
+
import { YAMLNode } from '@redocly/yaml-language-server-parser';
|
|
661
|
+
import { type ResolvedConfig } from '@redocly/openapi-core';
|
|
662
|
+
import { type TextDocument } from 'vscode-languageserver-textdocument';
|
|
663
|
+
type Func<T> = (textDocument: TextDocument) => T | Promise<T>;
|
|
664
|
+
export function debounceDocument<T>(func: Func<T>, wait?: number, immediate?: boolean): Func<Promise<T>>;
|
|
665
|
+
export function removeCirculars(object: any): any;
|
|
666
|
+
export function isRefField(field: string): boolean;
|
|
667
|
+
export function getConfigDirURI(configPath: string | undefined, fallbackURI: string): string;
|
|
668
|
+
export function getRootFilePath(apiRoot: string, rootFolderURI: string): Promise<string>;
|
|
669
|
+
export function getCurrentApiAlias(apis: ResolvedConfig['apis'], rootFilePath: string, rootFolderURI: string): Promise<string | undefined>;
|
|
670
|
+
export function isString<T>(value: T): boolean;
|
|
671
|
+
export function isFunction<T>(f: T): boolean;
|
|
672
|
+
export function isPromise<T>(value: T): boolean;
|
|
673
|
+
export function isYamlMap(node: YAMLNode | null): boolean;
|
|
674
|
+
export function isYamlMapping(node: YAMLNode | null): boolean;
|
|
675
|
+
export function isYamlSequence(node: YAMLNode | null): boolean;
|
|
676
|
+
export function surroundByNodeQuotes(valueToSurround: string, options: Record<string, any> & {
|
|
677
|
+
singleQuoted?: boolean;
|
|
678
|
+
}): string;
|
|
679
|
+
export {};
|
|
680
|
+
|
|
681
|
+
}
|
|
682
|
+
declare module '@redocly/openapi-language-server/server/validation/__tests__/__fixtures__/plugins' {
|
|
683
|
+
export { plugins_default as default };
|
|
684
|
+
var plugins_default: (typeof myRulesPlugin)[];
|
|
685
|
+
function myRulesPlugin(): {
|
|
686
|
+
id: string;
|
|
687
|
+
rules: {
|
|
688
|
+
oas3: {
|
|
689
|
+
'opid-not-test': typeof OperationIdNotTest;
|
|
690
|
+
};
|
|
691
|
+
};
|
|
692
|
+
};
|
|
693
|
+
function OperationIdNotTest(): {
|
|
694
|
+
Operation: {
|
|
695
|
+
enter(operation: any, ctx: any): void;
|
|
696
|
+
};
|
|
697
|
+
};
|
|
698
|
+
|
|
699
|
+
}
|
|
700
|
+
declare module '@redocly/openapi-language-server/server/validation/__tests__/index-debounce.test' {
|
|
701
|
+
export {};
|
|
702
|
+
|
|
703
|
+
}
|
|
704
|
+
declare module '@redocly/openapi-language-server/server/validation/__tests__/index.test' {
|
|
705
|
+
export {};
|
|
706
|
+
|
|
707
|
+
}
|
|
708
|
+
declare module '@redocly/openapi-language-server/server/validation/__tests__/scorecard.test' {
|
|
709
|
+
export {};
|
|
710
|
+
|
|
711
|
+
}
|
|
712
|
+
declare module '@redocly/openapi-language-server/server/validation/index' {
|
|
713
|
+
import { type NormalizedProblem } from '@redocly/openapi-core';
|
|
714
|
+
import { type PublishDiagnosticsParams } from 'vscode-languageserver/browser';
|
|
715
|
+
import { TextDocument } from 'vscode-languageserver-textdocument';
|
|
716
|
+
export const validateOpenAPI: (textDocument: TextDocument) => Promise<PublishDiagnosticsParams[]> | Promise<Promise<PublishDiagnosticsParams[]>>;
|
|
717
|
+
export function isSpecFile(fileContent: unknown): boolean;
|
|
718
|
+
export function revalidateAllDocuments(): (Promise<PublishDiagnosticsParams[]> | Promise<Promise<PublishDiagnosticsParams[]>>)[];
|
|
719
|
+
export function handleUnexpectedError(fileURI: string, error: any, diagnosticsParams?: PublishDiagnosticsParams[]): PublishDiagnosticsParams[];
|
|
720
|
+
export function getValidationErrorsForBundle(problems: NormalizedProblem[]): NormalizedProblem[];
|
|
721
|
+
|
|
722
|
+
}
|
|
723
|
+
declare module '@redocly/openapi-language-server/server/validation/scorecard' {
|
|
724
|
+
import { type ScorecardConfig } from '@redocly/config';
|
|
725
|
+
import { BaseResolver, type NormalizedProblem, type Document, type Plugin, type IgnoreConfig, type Config } from '@redocly/openapi-core';
|
|
726
|
+
type ScorecardTarget = NonNullable<ScorecardConfig['targets']>[number];
|
|
727
|
+
export function validateScorecard(document: Document, externalRefResolver: BaseResolver, scorecardConfig: ScorecardConfig, configPath?: string, pluginsCodeOrPlugins?: string | Plugin[], apiConfigMetadata?: Record<string, unknown>): Promise<(NormalizedProblem & {
|
|
728
|
+
scorecardLevel?: string;
|
|
729
|
+
})[]>;
|
|
730
|
+
export function evaluatePluginsFromCode(pluginsCode?: string): Promise<Plugin[]>;
|
|
731
|
+
export function resolveConfigForTarget(apiPath: string, targetRules: Record<string, unknown> | undefined, scorecardLevels: ScorecardConfig['levels'], plugins: Array<string | Plugin> | undefined, configPath: string, ignore: IgnoreConfig | undefined): Promise<Record<string, Config>>;
|
|
732
|
+
export function getTarget(targets: ScorecardConfig['targets'], metadata: Record<string, unknown>): ScorecardTarget | undefined;
|
|
733
|
+
export {};
|
|
734
|
+
|
|
735
|
+
}
|
|
736
|
+
declare module '@redocly/openapi-language-server/vitest.config' {
|
|
737
|
+
const _default: import("vite").UserConfig;
|
|
738
|
+
export default _default;
|
|
739
|
+
|
|
740
|
+
}
|
|
741
|
+
declare module '@redocly/openapi-language-server' {
|
|
742
|
+
import main = require('@redocly/openapi-language-server/index');
|
|
743
|
+
export = main;
|
|
744
|
+
}
|
package/lib/index.js
CHANGED
|
@@ -72,7 +72,7 @@ Did you mean: ${e.suggest[0]} ?`:`
|
|
|
72
72
|
Did you mean:
|
|
73
73
|
- ${e.suggest.join(`
|
|
74
74
|
- `)}`}function $R(e){return e.scorecardLevel?`
|
|
75
|
-
Scorecard level: ${e.scorecardLevel}`:""}function il(e,t){e.forEach(n=>{let r;switch(n.severity){case"error":r=We.DiagnosticSeverity.Error;break;case"warn":r=We.DiagnosticSeverity.Warning;break;default:r=We.DiagnosticSeverity.Warning}let i=NR(n.location[0]),o=Et(i.source.absoluteRef),s=We.Position.create(i.start.line-1,i.start.col-1),a=i.end?We.Position.create(i.end.line-1,i.end.col-1):s,c=n.message+` Rule: ${n.ruleId}.`+zR(n)+$R(n),u=We.Diagnostic.create(We.Range.create(s,a),c,r,void 0,"Redocly OpenAPI");my(o,u,t)})}function YR(e){return e.filter(({severity:t})=>t==="error").map(t=>({...t,location:t.location.map(n=>({...n,source:{...n.source,_ast:null}}))}))}var ds=qe(rn(),1);var me=qe(rn(),1);function Re(e,t){return e?t?rs[e+"_"+t]||t:rs[e]||rs.Default:rs.Default}var VR=["newLine","MediaTypeMap","PathMap","propertyName","newItem","Root_openapi","Root","Info","Root_info","Info_title","Info_summary","Info_description","Info_termsOfService","Info_contact","Contact_name","Contact_url","Contact_email","Info_license","License_name","License_identifier","License_url","Info_version","Root_jsonSchemaDialect","jsonSchemaDialect","Root_servers","Server_List","Server_url","Server_description","Server_variables","Root_paths","Root_webhooks","Root_components","Root_security","Root_tags","Root_externalDocs","LocalComponentCompletion","FolderCompletion","FileCompletion","Default"],rs=VR.reduce((e,t,n)=>(e[t]=String.fromCharCode(n),e),{});var on="newItem",Kr="propertyName",ur="newLine";function is(e){return!!(e?.name&&hy[e.name])}function sl(e){return hy[e]||[]}var hy={[ur]:[{label:"newLine",kind:me.CompletionItemKind.Constructor,data:{},sortText:Re(ur)}],[Kr]:[{label:Kr,kind:me.CompletionItemKind.Constructor,data:{properties:{}},sortText:Re(Kr)}],ServerVariable_Map:[{label:"newVariableName",kind:me.CompletionItemKind.Property,data:{properties:{}},sortText:Re("ServerVariable_Map")}],ResponsesMap:[{label:"200",kind:me.CompletionItemKind.Property,data:{properties:{}}},{label:"201",kind:me.CompletionItemKind.Property,data:{properties:{}}},{label:"204",kind:me.CompletionItemKind.Property,data:{properties:{}}},{label:"301",kind:me.CompletionItemKind.Property,data:{properties:{}}},{label:"303",kind:me.CompletionItemKind.Property,data:{properties:{}}},{label:"400",kind:me.CompletionItemKind.Property,data:{properties:{}}},{label:"401",kind:me.CompletionItemKind.Property,data:{properties:{}}},{label:"403",kind:me.CompletionItemKind.Property,data:{properties:{}}},{label:"404",kind:me.CompletionItemKind.Property,data:{properties:{}}},{label:"500",kind:me.CompletionItemKind.Property,data:{properties:{}}},{label:"503",kind:me.CompletionItemKind.Property,data:{properties:{}}}],PathMap:[{label:"/newPath",kind:me.CompletionItemKind.Property,data:{properties:{}},sortText:Re("PathMap")}],MediaTypeMap:[{label:"mime/type",kind:me.CompletionItemKind.Property,data:{properties:{}},sortText:Re("MediaTypeMap")},{label:"application/json",kind:me.CompletionItemKind.Property,data:{properties:{}},sortText:Re("MediaTypeMap")},{label:"application/octet-stream",kind:me.CompletionItemKind.Property,data:{properties:{}},sortText:Re("MediaTypeMap")},{label:"multipart/form-data",kind:me.CompletionItemKind.Property,data:{properties:{}},sortText:Re("MediaTypeMap")},{label:"application/x-www-form-urlencoded",kind:me.CompletionItemKind.Property,data:{properties:{}},sortText:Re("MediaTypeMap")},{label:"application/xml",kind:me.CompletionItemKind.Property,data:[],sortText:Re("MediaTypeMap")}]};import{Oas2Types as KR,Oas3Types as GR,Oas3_1Types as QR,Oas3_2Types as yy,AsyncApi2Types as JR,AsyncApi3Types as XR,Arazzo1Types as ZR,ConfigTypes as eD,normalizeTypes as cl,getMajorSpecVersion as tD,createEntityTypes as nD}from"@redocly/openapi-core";var dt=qe(qn(),1);var al=new Map;async function ul(e,t){let n=await Je(e),r=n.getText(),i=dt.safeLoad(r,{filename:e}),{nodePath:o}=os({node:i,nodePath:[]},t,n,!0),s=await ll(i,e),{version:a}=dl(i),{currentType:c,parentType:u,endPath:d}=ss(s,o,i),m=Gr(i),v=c?.name?c:u;return{nodePath:o,endPath:d,type:v,existingValues:m,types:s,descriptionVersion:a}}async function rD(e){let n=(await Je(e)).getText(),r=dt.safeLoad(n,{filename:e});return pl(r)}function by(e,t){if(!e)return null;let n=e,r=!0;return t.forEach(i=>{if(r=!1,tl(n)&&n.items&&n.items[i])n=n.items[i],r=!0;else if(py(n)){let o=as(n);for(let s of o)if(el(s)&&s.key?.value===i){n=s?.value,r=!0;break}}}),r?n:(console.warn("Cannot find node by path",t),null)}function iD(e,t){for(let n=0;n<t.length;n++)if(n===t.length-1||t[n+1]>e)return n;return t.length-1}function os(e,t,n,r=!1){let{node:i,nodePath:o=[]}=e,s=n.offsetAt(t),a=as(i);if(a.length===0||oD(i)||!r&&sD(i,n,t))return e;let c=aD(a,s);return os({nodePath:cD(o,i,a[c],c),node:a[c]},t,n,r)}function oD(e){return e?.kind===dt.Kind.MAPPING&&!e?.value}function sD(e,t,n){let r=t.getText({start:t.positionAt(t._lineOffsets[n.line]),end:n}),i=uD(e,t),o=r?.match(/^\s+/)?.[0]?.length||0;return(/^\s*[\w\-\$\/\{\}]+$/.test(r)?o:n.character)===i}function aD(e,t){for(let n=1;n<e.length;n++){let r=e[n];if(r&&r.startPosition>t)return n-1}return e.length-1}function cD(e,t,n,r){return tl(t)?[...e,r]:el(n)&&n?.key?.value&&typeof n.key.value=="string"?[...e,n.key.value]:e}function uD(e,t){let n=e?.startPosition??0,r=iD(n,t._lineOffsets);if(r>=0){let i=t._lineOffsets[r];return n-i}return 0}function ss(e,t,n){let r=e,i,o=new Array(t.length).fill(null);t.forEach((a,c)=>{let u;if(e?.name&&e?.name!==r?.name&&(r=e,i=a),e&&e?.properties&&!Object.keys(e?.properties).length&&e?.items){if(e.items.properties)u=e.items;else if($r(e.items)){let d=lD(n,typeof t[0]=="number"?t[0]:0);u=e.items(d,a)}}else if(e?.properties&&e.properties[a])u=e.properties[a],$r(u)&&(u=u(null,a));else if(e?.additionalProperties&&!$r(e?.additionalProperties))u=e.additionalProperties;else if($r(e?.additionalProperties)&&a){let d=e.additionalProperties(null,a);d&&(u=d)}u&&(e=u,o[c]=u)}),e?.name&&r?.name&&e?.name!==r?.name&&(i=void 0);let s=o.every(a=>!!a);return{currentType:s||t[0]==="openapi"||t.length===0?e:null,parentType:s?r:null,endPath:i}}function lD(e,t){let n={};if(e.kind===dt.Kind.SEQ&&e.items?.[t]){let r=e.items?.[t]?.mappings??[];for(let i of r)i.key?.value&&(n[i.key?.value]=i.value?.value)}return n}async function ll(e,t){if(await mn(t)||await mn(Oe(t)))return cl(eD).ConfigRoot;if(gn({uri:t,ast:e})||gn({uri:Oe(t),ast:e})){let{entityTypes:o}=nD(Ei,Ni),s=cl(o);if(e?.kind===dt.Kind.SEQ)return s.EntityFileArray;let a=pD(e);return a&&s[a]?s[a]:s.EntityFileDefault}let{types:n,isDefault:r}=fD(e);if(!e)return n;let i=r?rl(t):n;return r&&!rl(t)&&e?null:i||n}function pD(e){let t="type";return e?.mappings?.find(n=>n.key?.value===t&&n.value?.value)?.value?.value}function dD(e){if(al.has(e))return al.get(e);let t=cl(gD(e)).Root;return al.set(e,t),t}function pl(e){let t,n=!1;if(e?.kind===dt.Kind.MAP)for(let r of e.mappings){let i=r.key?.value,o=String(r?.value?.value);if(i==="openapi"&&o.startsWith("3.2")){t="oas3_2";break}if(i==="openapi"&&o.startsWith("3.1")){t="oas3_1";break}if(i==="openapi"&&o.startsWith("3.0")){t="oas3_0";break}if(i==="swagger"&&o==="2.0"){t="oas2";break}if(i==="asyncapi"&&o.startsWith("2."))return{version:"async2",isDefault:!1};if(i==="asyncapi"&&o.startsWith("3."))return{version:"async3",isDefault:!1};if(i==="arazzo")return{version:"arazzo1",isDefault:!1}}return t||(t="oas3_2",n=!0),{version:t,isDefault:n}}function dl(e){let{version:t,isDefault:n}=pl(e);return{version:tD(t),isDefault:n}}function fD(e){let{version:t,isDefault:n}=pl(e);return{types:dD(t),isDefault:n}}function as(e){switch(e?.kind){case dt.Kind.MAPPING:return[e.key,e.value];case dt.Kind.MAP:return e.mappings;case dt.Kind.SEQ:return e?.items;default:return[]}}function gD(e){switch(e){case"oas3_2":return yy;case"oas3_1":return QR;case"oas3_0":return GR;case"oas2":return KR;case"async2":return JR;case"async3":return XR;case"arazzo1":return ZR;default:return yy}}function Gr(e,t,n){if(typeof t>"u"&&(t={}),typeof n>"u"&&(n=0),!e)return{};let r=e?.mappings||e?.items;if(r){let i=0;for(let o of r)o?.value===null||!o?.value?.value?t[o?.key?.value||i]={value:ly(o?.value)?o?.value:null,startOffset:o?.key?.value?o.startPosition+o.key.value.length+1:null,endOffset:null,indent:n}:t[o?.key?.value||i]={value:o?.value?.value,rawValue:o?.value?.rawValue||null,startOffset:o?.value?.startPosition||null,endOffset:o?.value?.endPosition||null,indent:n},Object.keys(o?.value||o||{}).includes("items")?(t[o?.key?.value||i]={type:"sequence",startOffset:o.startPosition,endOffset:o.endPosition,indent:n,value:null},Gr(o?.value||o,t[o?.key?.value||i],n+1)):Object.keys(o?.value||o||{}).includes("mappings")&&(t[o?.key?.value||i]={type:"map",startOffset:o.startPosition,endOffset:o.endPosition,indent:n,value:null},Gr(o?.value||o,t[o?.key?.value||i],n+1)),i++}return t}import{mapTypeToComponent as vy}from"@redocly/openapi-core";var fl={Schema:[{name:"$ref",value:{type:"string",name:"Schema"}}],PathItem:[{name:"$ref",value:{type:"string",name:"PathItem"}}],Parameter:[{name:"$ref",value:{type:"string",name:"Parameter"}}],Response:[{name:"$ref",value:{type:"string",name:"Response"}}],Example:[{name:"$ref",value:{type:"string",name:"Example"}}],RequestBody:[{name:"$ref",value:{type:"string",name:"RequestBody"}}],Header:[{name:"$ref",value:{type:"string",name:"Header"}}],SecuritySchema:[{name:"$ref",value:{type:"string",name:"SecuritySchema"}}],Link:[{name:"$ref",value:{type:"string",name:"Link"}}],Callback:[{name:"$ref",value:{type:"string",name:"Callback"}}]};function Py(e){let t=fl[e.name];if(t&&e.properties)for(let n of t)e.properties[n.name]=n.value;return e}var cs=qe(rn(),1),ft=class{constructor({kind:t,label:n,value:r,textEdit:i,filterText:o,sortText:s,data:a}){this.kind=t||cs.CompletionItemKind.Value,this.label=n;let{node:c,lineOffset:u,position:d}=a;this.insertText=r??n,this.filterText=o||this.insertText,this.sortText=s,this.textEdit=i||(c?.value&&d&&u?this.getTextEdit(c,d,u):void 0)}getTextEdit(t,n,r){let i=t.startPosition-r,o=t.singleQuoted||t.doubleQuoted?2:0,s=i+t.value.length+o;return cs.TextEdit.replace({start:{line:n.line,character:i},end:{line:n.line,character:s}},this.insertText)}};var lr=qe(rn(),1),Rn=class{constructor({kind:t,label:n,insertText:r,insertTextFormat:i,filterText:o,sortText:s,data:a}){this.insertTextFormat=i||n.includes("$")?lr.InsertTextFormat.PlainText:lr.InsertTextFormat.Snippet,this.kind=t||lr.CompletionItemKind.Property,this.label=n,this.data=a||{},this.insertText=r??n,this.filterText=o||this.insertText,this.sortText=s,this.command=this.kind===lr.CompletionItemKind.Property?{title:"Suggested values",command:"editor.action.triggerSuggest"}:void 0}};var Qr={example:"example",default:"default",enum:"enum",ref:"$ref"},us=[Qr.default,Qr.example];var Ry=qe(qn(),1);var ke={};ms(ke,{default:()=>Cy.default});hs(ke,qe(gl()));var Cy=qe(gl());function hD(e,t,n){let r=t.slice(0,t.length-1),{currentType:i}=ss(e,r,n);if(i?.name){let[o]=fl[i.name]||[];return o?.value}return null}function yD(e,t,n){let r=t[t.length-1];if(cy(r))return hD(e,t,n);let{currentType:i}=ss(e,t,n);return i?is(i)?i:i?.name&&(i?.name.includes("Map")||i?.name.includes("Named"))?{name:Kr,properties:{}}:i:null}async function Dy(e,t){let n=await Je(e),r=n.getText(),i=(0,Ry.safeLoad)(r,{filename:e}),{node:o,nodePath:s}=os({node:i,nodePath:[]},t,n),a=await ll(i,e),c=yD(a,s,i),u=n._lineOffsets[t.line],d=n.getText({start:n.positionAt(u),end:t});return{currentAst:i,node:o,nodePath:s,position:t,lineText:d,lineOffset:u,openApiType:c}}async function Ty(e,t){let n=K.resolvePath(Ue(e)),r=K.dirname(n),i=await Pl(K.joinPath(r,t),r.path),o=K.resolvePath(r,i.path);return{refPath:t,refDirPath:i,refDirAbsolutePath:o,isAbsolutePath:t?(0,ke.isAbsolute)(t):!1,docAbsolutePath:n,docAbsoluteDirPath:r,root:"/"}}var wy=qe(rn(),1);var ls=class extends ft{constructor(t){super(t),this.kind=wy.CompletionItemKind.Folder,this.command={title:"Complete path",command:"editor.action.triggerSuggest",arguments:[]}}};var Sy=qe(rn(),1);var ps=class extends ft{constructor(t){super(t),this.kind=Sy.CompletionItemKind.File}};var vD=ae.supportedLanguages.concat({languageId:"markdown",filePattern:/\.md$/});function PD(e){let{refPath:t,docAbsoluteDirPath:n,isAbsolutePath:r,root:i}=e,o=(0,ke.resolve)(n.path,t,".."),s=r?o:(0,ke.relative)(n.path,o),a=s&&s!==i?"/":"";return{name:"../",type:1,matchBy:t,sortBy:Re("FolderCompletion"),value:`${s}${a}`}}async function xD(e,t,n){let r=[],{refDirAbsolutePath:i,docAbsolutePath:o}=n;for(let s of e)try{let a=K.resolvePath(i,s),c=await ae.fs.stat(a);c.isFile()&&a.path!==o.path&&t.supportedFiles.some(u=>u.filePattern.test(s))&&r.push({name:s,type:0}),c.isDirectory()&&r.push({name:s,type:1})}catch{continue}return r}function ky(e,t){let{docAbsoluteDirPath:n,isAbsolutePath:r,refDirAbsolutePath:i,root:o,refPath:s}=t,a=[];return i.path!==o&&a.push(PD(t)),a.concat(e.map(({name:c,type:u})=>{let d=(0,ke.resolve)(i.path,c),m=(0,ke.relative)(n.path,d),v=s.includes(ke.sep)?s.slice(0,s.lastIndexOf(ke.sep)+1):s+ke.sep,y=r?d:m;if(u===0)return{type:u,name:c,value:y,sortBy:`${Re("FileCompletion")}${c}`,matchBy:`${v}${c}`};let T=`${c}/`;return{type:u,name:T,value:`${y}${m?"/":""}`,sortBy:`${Re("FolderCompletion")}${c}`,matchBy:`${v}${c}`}}))}function Ay(e,t){let{node:n,lineOffset:r,position:i}=t;return e.map(o=>{let{name:s,value:a,matchBy:c,sortBy:u,type:d}=o,m={label:s,filterText:Yr(c,n),sortText:u,value:a,data:{lineOffset:r,position:i,node:n}};return d===1?new ls(m):new ps(m)})}async function Ey(e,t){let{node:n}=t,r=n.value??"",i=await Ty(e,r),{refDirAbsolutePath:o}=i,s=[];try{s=await ae.fs.readDir(o)}catch{return Ay(ky([],i),t)}let a=await xD(s,{supportedFiles:vD},i);return Ay(ky(a,i),t)}import{isEmptyObject as _D,isPlainObject as CD}from"@redocly/openapi-core";function Ny(e,t){let n=t?.items;return CD(n)?"- "+Ny(e,n):t?.required?Object.values(t.required).map((r,i)=>`${r}: \${${i+1}}`).join(`
|
|
75
|
+
Scorecard level: ${e.scorecardLevel}`:""}function il(e,t){e.forEach(n=>{let r;switch(n.severity){case"error":r=We.DiagnosticSeverity.Error;break;case"warn":r=We.DiagnosticSeverity.Warning;break;default:r=We.DiagnosticSeverity.Warning}let i=NR(n.location[0]),o=Et(i.source.absoluteRef),s=We.Position.create(i.start.line-1,i.start.col-1),a=i.end?We.Position.create(i.end.line-1,i.end.col-1):s,c=n.message+zR(n)+$R(n),u=We.Diagnostic.create(We.Range.create(s,a),c,r,`Rule: ${n.ruleId}`,"Redocly OpenAPI");n.reference&&(u.codeDescription={href:n.reference}),my(o,u,t)})}function YR(e){return e.filter(({severity:t})=>t==="error").map(t=>({...t,location:t.location.map(n=>({...n,source:{...n.source,_ast:null}}))}))}var ds=qe(rn(),1);var me=qe(rn(),1);function Re(e,t){return e?t?rs[e+"_"+t]||t:rs[e]||rs.Default:rs.Default}var VR=["newLine","MediaTypeMap","PathMap","propertyName","newItem","Root_openapi","Root","Info","Root_info","Info_title","Info_summary","Info_description","Info_termsOfService","Info_contact","Contact_name","Contact_url","Contact_email","Info_license","License_name","License_identifier","License_url","Info_version","Root_jsonSchemaDialect","jsonSchemaDialect","Root_servers","Server_List","Server_url","Server_description","Server_variables","Root_paths","Root_webhooks","Root_components","Root_security","Root_tags","Root_externalDocs","LocalComponentCompletion","FolderCompletion","FileCompletion","Default"],rs=VR.reduce((e,t,n)=>(e[t]=String.fromCharCode(n),e),{});var on="newItem",Kr="propertyName",ur="newLine";function is(e){return!!(e?.name&&hy[e.name])}function sl(e){return hy[e]||[]}var hy={[ur]:[{label:"newLine",kind:me.CompletionItemKind.Constructor,data:{},sortText:Re(ur)}],[Kr]:[{label:Kr,kind:me.CompletionItemKind.Constructor,data:{properties:{}},sortText:Re(Kr)}],ServerVariable_Map:[{label:"newVariableName",kind:me.CompletionItemKind.Property,data:{properties:{}},sortText:Re("ServerVariable_Map")}],ResponsesMap:[{label:"200",kind:me.CompletionItemKind.Property,data:{properties:{}}},{label:"201",kind:me.CompletionItemKind.Property,data:{properties:{}}},{label:"204",kind:me.CompletionItemKind.Property,data:{properties:{}}},{label:"301",kind:me.CompletionItemKind.Property,data:{properties:{}}},{label:"303",kind:me.CompletionItemKind.Property,data:{properties:{}}},{label:"400",kind:me.CompletionItemKind.Property,data:{properties:{}}},{label:"401",kind:me.CompletionItemKind.Property,data:{properties:{}}},{label:"403",kind:me.CompletionItemKind.Property,data:{properties:{}}},{label:"404",kind:me.CompletionItemKind.Property,data:{properties:{}}},{label:"500",kind:me.CompletionItemKind.Property,data:{properties:{}}},{label:"503",kind:me.CompletionItemKind.Property,data:{properties:{}}}],PathMap:[{label:"/newPath",kind:me.CompletionItemKind.Property,data:{properties:{}},sortText:Re("PathMap")}],MediaTypeMap:[{label:"mime/type",kind:me.CompletionItemKind.Property,data:{properties:{}},sortText:Re("MediaTypeMap")},{label:"application/json",kind:me.CompletionItemKind.Property,data:{properties:{}},sortText:Re("MediaTypeMap")},{label:"application/octet-stream",kind:me.CompletionItemKind.Property,data:{properties:{}},sortText:Re("MediaTypeMap")},{label:"multipart/form-data",kind:me.CompletionItemKind.Property,data:{properties:{}},sortText:Re("MediaTypeMap")},{label:"application/x-www-form-urlencoded",kind:me.CompletionItemKind.Property,data:{properties:{}},sortText:Re("MediaTypeMap")},{label:"application/xml",kind:me.CompletionItemKind.Property,data:[],sortText:Re("MediaTypeMap")}]};import{Oas2Types as KR,Oas3Types as GR,Oas3_1Types as QR,Oas3_2Types as yy,AsyncApi2Types as JR,AsyncApi3Types as XR,Arazzo1Types as ZR,ConfigTypes as eD,normalizeTypes as cl,getMajorSpecVersion as tD,createEntityTypes as nD}from"@redocly/openapi-core";var dt=qe(qn(),1);var al=new Map;async function ul(e,t){let n=await Je(e),r=n.getText(),i=dt.safeLoad(r,{filename:e}),{nodePath:o}=os({node:i,nodePath:[]},t,n,!0),s=await ll(i,e),{version:a}=dl(i),{currentType:c,parentType:u,endPath:d}=ss(s,o,i),m=Gr(i),v=c?.name?c:u;return{nodePath:o,endPath:d,type:v,existingValues:m,types:s,descriptionVersion:a}}async function rD(e){let n=(await Je(e)).getText(),r=dt.safeLoad(n,{filename:e});return pl(r)}function by(e,t){if(!e)return null;let n=e,r=!0;return t.forEach(i=>{if(r=!1,tl(n)&&n.items&&n.items[i])n=n.items[i],r=!0;else if(py(n)){let o=as(n);for(let s of o)if(el(s)&&s.key?.value===i){n=s?.value,r=!0;break}}}),r?n:(console.warn("Cannot find node by path",t),null)}function iD(e,t){for(let n=0;n<t.length;n++)if(n===t.length-1||t[n+1]>e)return n;return t.length-1}function os(e,t,n,r=!1){let{node:i,nodePath:o=[]}=e,s=n.offsetAt(t),a=as(i);if(a.length===0||oD(i)||!r&&sD(i,n,t))return e;let c=aD(a,s);return os({nodePath:cD(o,i,a[c],c),node:a[c]},t,n,r)}function oD(e){return e?.kind===dt.Kind.MAPPING&&!e?.value}function sD(e,t,n){let r=t.getText({start:t.positionAt(t._lineOffsets[n.line]),end:n}),i=uD(e,t),o=r?.match(/^\s+/)?.[0]?.length||0;return(/^\s*[\w\-\$\/\{\}]+$/.test(r)?o:n.character)===i}function aD(e,t){for(let n=1;n<e.length;n++){let r=e[n];if(r&&r.startPosition>t)return n-1}return e.length-1}function cD(e,t,n,r){return tl(t)?[...e,r]:el(n)&&n?.key?.value&&typeof n.key.value=="string"?[...e,n.key.value]:e}function uD(e,t){let n=e?.startPosition??0,r=iD(n,t._lineOffsets);if(r>=0){let i=t._lineOffsets[r];return n-i}return 0}function ss(e,t,n){let r=e,i,o=new Array(t.length).fill(null);t.forEach((a,c)=>{let u;if(e?.name&&e?.name!==r?.name&&(r=e,i=a),e&&e?.properties&&!Object.keys(e?.properties).length&&e?.items){if(e.items.properties)u=e.items;else if($r(e.items)){let d=lD(n,typeof t[0]=="number"?t[0]:0);u=e.items(d,a)}}else if(e?.properties&&e.properties[a])u=e.properties[a],$r(u)&&(u=u(null,a));else if(e?.additionalProperties&&!$r(e?.additionalProperties))u=e.additionalProperties;else if($r(e?.additionalProperties)&&a){let d=e.additionalProperties(null,a);d&&(u=d)}u&&(e=u,o[c]=u)}),e?.name&&r?.name&&e?.name!==r?.name&&(i=void 0);let s=o.every(a=>!!a);return{currentType:s||t[0]==="openapi"||t.length===0?e:null,parentType:s?r:null,endPath:i}}function lD(e,t){let n={};if(e.kind===dt.Kind.SEQ&&e.items?.[t]){let r=e.items?.[t]?.mappings??[];for(let i of r)i.key?.value&&(n[i.key?.value]=i.value?.value)}return n}async function ll(e,t){if(await mn(t)||await mn(Oe(t)))return cl(eD).ConfigRoot;if(gn({uri:t,ast:e})||gn({uri:Oe(t),ast:e})){let{entityTypes:o}=nD(Ei,Ni),s=cl(o);if(e?.kind===dt.Kind.SEQ)return s.EntityFileArray;let a=pD(e);return a&&s[a]?s[a]:s.EntityFileDefault}let{types:n,isDefault:r}=fD(e);if(!e)return n;let i=r?rl(t):n;return r&&!rl(t)&&e?null:i||n}function pD(e){let t="type";return e?.mappings?.find(n=>n.key?.value===t&&n.value?.value)?.value?.value}function dD(e){if(al.has(e))return al.get(e);let t=cl(gD(e)).Root;return al.set(e,t),t}function pl(e){let t,n=!1;if(e?.kind===dt.Kind.MAP)for(let r of e.mappings){let i=r.key?.value,o=String(r?.value?.value);if(i==="openapi"&&o.startsWith("3.2")){t="oas3_2";break}if(i==="openapi"&&o.startsWith("3.1")){t="oas3_1";break}if(i==="openapi"&&o.startsWith("3.0")){t="oas3_0";break}if(i==="swagger"&&o==="2.0"){t="oas2";break}if(i==="asyncapi"&&o.startsWith("2."))return{version:"async2",isDefault:!1};if(i==="asyncapi"&&o.startsWith("3."))return{version:"async3",isDefault:!1};if(i==="arazzo")return{version:"arazzo1",isDefault:!1}}return t||(t="oas3_2",n=!0),{version:t,isDefault:n}}function dl(e){let{version:t,isDefault:n}=pl(e);return{version:tD(t),isDefault:n}}function fD(e){let{version:t,isDefault:n}=pl(e);return{types:dD(t),isDefault:n}}function as(e){switch(e?.kind){case dt.Kind.MAPPING:return[e.key,e.value];case dt.Kind.MAP:return e.mappings;case dt.Kind.SEQ:return e?.items;default:return[]}}function gD(e){switch(e){case"oas3_2":return yy;case"oas3_1":return QR;case"oas3_0":return GR;case"oas2":return KR;case"async2":return JR;case"async3":return XR;case"arazzo1":return ZR;default:return yy}}function Gr(e,t,n){if(typeof t>"u"&&(t={}),typeof n>"u"&&(n=0),!e)return{};let r=e?.mappings||e?.items;if(r){let i=0;for(let o of r)o?.value===null||!o?.value?.value?t[o?.key?.value||i]={value:ly(o?.value)?o?.value:null,startOffset:o?.key?.value?o.startPosition+o.key.value.length+1:null,endOffset:null,indent:n}:t[o?.key?.value||i]={value:o?.value?.value,rawValue:o?.value?.rawValue||null,startOffset:o?.value?.startPosition||null,endOffset:o?.value?.endPosition||null,indent:n},Object.keys(o?.value||o||{}).includes("items")?(t[o?.key?.value||i]={type:"sequence",startOffset:o.startPosition,endOffset:o.endPosition,indent:n,value:null},Gr(o?.value||o,t[o?.key?.value||i],n+1)):Object.keys(o?.value||o||{}).includes("mappings")&&(t[o?.key?.value||i]={type:"map",startOffset:o.startPosition,endOffset:o.endPosition,indent:n,value:null},Gr(o?.value||o,t[o?.key?.value||i],n+1)),i++}return t}import{mapTypeToComponent as vy}from"@redocly/openapi-core";var fl={Schema:[{name:"$ref",value:{type:"string",name:"Schema"}}],PathItem:[{name:"$ref",value:{type:"string",name:"PathItem"}}],Parameter:[{name:"$ref",value:{type:"string",name:"Parameter"}}],Response:[{name:"$ref",value:{type:"string",name:"Response"}}],Example:[{name:"$ref",value:{type:"string",name:"Example"}}],RequestBody:[{name:"$ref",value:{type:"string",name:"RequestBody"}}],Header:[{name:"$ref",value:{type:"string",name:"Header"}}],SecuritySchema:[{name:"$ref",value:{type:"string",name:"SecuritySchema"}}],Link:[{name:"$ref",value:{type:"string",name:"Link"}}],Callback:[{name:"$ref",value:{type:"string",name:"Callback"}}]};function Py(e){let t=fl[e.name];if(t&&e.properties)for(let n of t)e.properties[n.name]=n.value;return e}var cs=qe(rn(),1),ft=class{constructor({kind:t,label:n,value:r,textEdit:i,filterText:o,sortText:s,data:a}){this.kind=t||cs.CompletionItemKind.Value,this.label=n;let{node:c,lineOffset:u,position:d}=a;this.insertText=r??n,this.filterText=o||this.insertText,this.sortText=s,this.textEdit=i||(c?.value&&d&&u?this.getTextEdit(c,d,u):void 0)}getTextEdit(t,n,r){let i=t.startPosition-r,o=t.singleQuoted||t.doubleQuoted?2:0,s=i+t.value.length+o;return cs.TextEdit.replace({start:{line:n.line,character:i},end:{line:n.line,character:s}},this.insertText)}};var lr=qe(rn(),1),Rn=class{constructor({kind:t,label:n,insertText:r,insertTextFormat:i,filterText:o,sortText:s,data:a}){this.insertTextFormat=i||n.includes("$")?lr.InsertTextFormat.PlainText:lr.InsertTextFormat.Snippet,this.kind=t||lr.CompletionItemKind.Property,this.label=n,this.data=a||{},this.insertText=r??n,this.filterText=o||this.insertText,this.sortText=s,this.command=this.kind===lr.CompletionItemKind.Property?{title:"Suggested values",command:"editor.action.triggerSuggest"}:void 0}};var Qr={example:"example",default:"default",enum:"enum",ref:"$ref"},us=[Qr.default,Qr.example];var Ry=qe(qn(),1);var ke={};ms(ke,{default:()=>Cy.default});hs(ke,qe(gl()));var Cy=qe(gl());function hD(e,t,n){let r=t.slice(0,t.length-1),{currentType:i}=ss(e,r,n);if(i?.name){let[o]=fl[i.name]||[];return o?.value}return null}function yD(e,t,n){let r=t[t.length-1];if(cy(r))return hD(e,t,n);let{currentType:i}=ss(e,t,n);return i?is(i)?i:i?.name&&(i?.name.includes("Map")||i?.name.includes("Named"))?{name:Kr,properties:{}}:i:null}async function Dy(e,t){let n=await Je(e),r=n.getText(),i=(0,Ry.safeLoad)(r,{filename:e}),{node:o,nodePath:s}=os({node:i,nodePath:[]},t,n),a=await ll(i,e),c=yD(a,s,i),u=n._lineOffsets[t.line],d=n.getText({start:n.positionAt(u),end:t});return{currentAst:i,node:o,nodePath:s,position:t,lineText:d,lineOffset:u,openApiType:c}}async function Ty(e,t){let n=K.resolvePath(Ue(e)),r=K.dirname(n),i=await Pl(K.joinPath(r,t),r.path),o=K.resolvePath(r,i.path);return{refPath:t,refDirPath:i,refDirAbsolutePath:o,isAbsolutePath:t?(0,ke.isAbsolute)(t):!1,docAbsolutePath:n,docAbsoluteDirPath:r,root:"/"}}var wy=qe(rn(),1);var ls=class extends ft{constructor(t){super(t),this.kind=wy.CompletionItemKind.Folder,this.command={title:"Complete path",command:"editor.action.triggerSuggest",arguments:[]}}};var Sy=qe(rn(),1);var ps=class extends ft{constructor(t){super(t),this.kind=Sy.CompletionItemKind.File}};var vD=ae.supportedLanguages.concat({languageId:"markdown",filePattern:/\.md$/});function PD(e){let{refPath:t,docAbsoluteDirPath:n,isAbsolutePath:r,root:i}=e,o=(0,ke.resolve)(n.path,t,".."),s=r?o:(0,ke.relative)(n.path,o),a=s&&s!==i?"/":"";return{name:"../",type:1,matchBy:t,sortBy:Re("FolderCompletion"),value:`${s}${a}`}}async function xD(e,t,n){let r=[],{refDirAbsolutePath:i,docAbsolutePath:o}=n;for(let s of e)try{let a=K.resolvePath(i,s),c=await ae.fs.stat(a);c.isFile()&&a.path!==o.path&&t.supportedFiles.some(u=>u.filePattern.test(s))&&r.push({name:s,type:0}),c.isDirectory()&&r.push({name:s,type:1})}catch{continue}return r}function ky(e,t){let{docAbsoluteDirPath:n,isAbsolutePath:r,refDirAbsolutePath:i,root:o,refPath:s}=t,a=[];return i.path!==o&&a.push(PD(t)),a.concat(e.map(({name:c,type:u})=>{let d=(0,ke.resolve)(i.path,c),m=(0,ke.relative)(n.path,d),v=s.includes(ke.sep)?s.slice(0,s.lastIndexOf(ke.sep)+1):s+ke.sep,y=r?d:m;if(u===0)return{type:u,name:c,value:y,sortBy:`${Re("FileCompletion")}${c}`,matchBy:`${v}${c}`};let T=`${c}/`;return{type:u,name:T,value:`${y}${m?"/":""}`,sortBy:`${Re("FolderCompletion")}${c}`,matchBy:`${v}${c}`}}))}function Ay(e,t){let{node:n,lineOffset:r,position:i}=t;return e.map(o=>{let{name:s,value:a,matchBy:c,sortBy:u,type:d}=o,m={label:s,filterText:Yr(c,n),sortText:u,value:a,data:{lineOffset:r,position:i,node:n}};return d===1?new ls(m):new ps(m)})}async function Ey(e,t){let{node:n}=t,r=n.value??"",i=await Ty(e,r),{refDirAbsolutePath:o}=i,s=[];try{s=await ae.fs.readDir(o)}catch{return Ay(ky([],i),t)}let a=await xD(s,{supportedFiles:vD},i);return Ay(ky(a,i),t)}import{isEmptyObject as _D,isPlainObject as CD}from"@redocly/openapi-core";function Ny(e,t){let n=t?.items;return CD(n)?"- "+Ny(e,n):t?.required?Object.values(t.required).map((r,i)=>`${r}: \${${i+1}}`).join(`
|
|
76
76
|
`):""}function RD(e,t,n,r){if(e===on)return"";if(r?.items||r?.required){let i=`
|
|
77
77
|
`;return n.includes(`
|
|
78
78
|
`)&&(i+=" "),i}return n.includes(`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redocly/openapi-language-server",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"description": "Redocly OpenAPI language server",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"@redocly/openapi-core": "2.31.2"
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
|
14
|
-
"@types/node": "
|
|
14
|
+
"@types/node": "24.1.0",
|
|
15
15
|
"@vitest/coverage-v8": "4.0.10",
|
|
16
16
|
"esbuild": "0.27.0",
|
|
17
17
|
"npm-dts": "1.3.12",
|