-
Notifications
You must be signed in to change notification settings - Fork 12.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(editor): Display schema preview for unexecuted nodes (#12901)
- Loading branch information
Showing
17 changed files
with
1,558 additions
and
345 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { request } from '@/utils/apiUtils'; | ||
import type { JSONSchema7 } from 'json-schema'; | ||
|
||
export type GetSchemaPreviewOptions = { | ||
nodeType: string; | ||
version: number; | ||
resource?: string; | ||
operation?: string; | ||
}; | ||
|
||
const padVersion = (version: number) => { | ||
return version.toString().split('.').concat(['0', '0']).slice(0, 3).join('.'); | ||
}; | ||
|
||
export const getSchemaPreview = async ( | ||
baseUrl: string, | ||
options: GetSchemaPreviewOptions, | ||
): Promise<JSONSchema7> => { | ||
const { nodeType, version, resource, operation } = options; | ||
const versionString = padVersion(version); | ||
const path = ['schemas', nodeType, versionString, resource, operation].filter(Boolean).join('/'); | ||
return await request({ | ||
method: 'GET', | ||
baseURL: baseUrl, | ||
endpoint: `${path}.json`, | ||
withCredentials: false, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.