Skip to content

Commit c6b75bb

Browse files
authored
Merge pull request #438 from serverlessworkflow/fix-dashboard-function-validation
Fixed the `custom function` validation when using the JSON editor of the Dashboard
2 parents 0648ecb + 8c8e2e6 commit c6b75bb

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

src/dashboard/Synapse.Dashboard/Components/MonacoEditor/MonacoEditorHelper.cs

-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ public Func<StandaloneCodeEditor, StandaloneEditorConstructionOptions> GetStanda
4242
{
4343
Other = "true",
4444
Strings = "true",
45-
Comments = "fasle"
4645
}
4746
};
4847
}

src/dashboard/Synapse.Dashboard/Pages/Functions/Create/Store.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ protected async Task SetValidationSchema(string? version = null)
528528
this._processingVersion = true;
529529
try
530530
{
531-
var schema = $"https://raw.githubusercontent.com/serverlessworkflow/specification/{version}/schema/workflow.yaml#/$defs/task";
531+
var schema = $"https://raw.githubusercontent.com/serverlessworkflow/serverlessworkflow.github.io/main/static/schemas/{version}/workflow.yaml#/$defs/task";
532532
var type = $"create_{typeof(CustomFunction).Name.ToLower()}_{version}_schema";
533533
await this.MonacoInterop.AddValidationSchemaAsync(schema, $"https://synapse.io/schemas/{type}.json", $"{type}*").ConfigureAwait(false);
534534
this._textModelUri = this.MonacoEditorHelper.GetResourceUri(type);

src/dashboard/Synapse.Dashboard/Services/SpecificationSchemaManager.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public async Task<string> GetLatestVersion()
4545
{
4646
if (!string.IsNullOrEmpty(this._latestVersion)) return this._latestVersion;
4747
var tags = await this.HttpClient.GetFromJsonAsync<IEnumerable<GitHubTag>>("https://api.github.com/repos/serverlessworkflow/specification/tags");
48-
this._latestVersion = tags?.FirstOrDefault()?.Name;
48+
this._latestVersion = tags?.FirstOrDefault()?.Name?.Substring(1);
4949
return this._latestVersion ?? string.Empty;
5050
}
5151

@@ -57,7 +57,7 @@ public async Task<string> GetLatestVersion()
5757
public async Task<string> GetSchema(string version)
5858
{
5959
if (_knownSchemas.TryGetValue(version, out string? value)) return value;
60-
var address = $"https://raw.githubusercontent.com/serverlessworkflow/specification/{version}/schema/workflow.yaml";
60+
var address = $"https://raw.githubusercontent.com/serverlessworkflow/serverlessworkflow.github.io/main/static/schemas/{version}/workflow.yaml";
6161
var yamlSchema = await this.HttpClient.GetStringAsync(address);
6262
this._knownSchemas.Add(version, this.YamlSerializer.ConvertToJson(yamlSchema));
6363
return this._knownSchemas[version];

src/dashboard/Synapse.Dashboard/wwwroot/js/monaco-editor-interop-extension.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ import { LineCounter, parseDocument } from "https://esm.sh/yaml";
99
* @returns
1010
*/
1111
export function addValidationSchema(schema, schemaUri, schemaType) {
12+
let isUrl = false;
1213
try {
1314
schema = JSON.parse(schema);
1415
}
1516
catch {
17+
isUrl = true;
1618
schema = { $ref: schema };
1719
}
1820
// JSON
@@ -24,7 +26,11 @@ export function addValidationSchema(schema, schemaUri, schemaType) {
2426
schemas: [
2527
...monaco.languages.json.jsonDefaults.diagnosticsOptions.schemas,
2628
{
27-
schema,
29+
schema: isUrl ?
30+
{
31+
$ref: schema.$ref.replace('.yaml', '.json')
32+
} :
33+
schema,
2834
uri: schemaUri,
2935
fileMatch: [schemaType]
3036
}

0 commit comments

Comments
 (0)