Skip to content

Commit

Permalink
Merge pull request #438 from serverlessworkflow/fix-dashboard-functio…
Browse files Browse the repository at this point in the history
…n-validation

Fixed the `custom function` validation when using the JSON editor of the Dashboard
  • Loading branch information
cdavernas authored Oct 23, 2024
2 parents 0648ecb + 8c8e2e6 commit c6b75bb
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ public Func<StandaloneCodeEditor, StandaloneEditorConstructionOptions> GetStanda
{
Other = "true",
Strings = "true",
Comments = "fasle"
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ protected async Task SetValidationSchema(string? version = null)
this._processingVersion = true;
try
{
var schema = $"https://raw.githubusercontent.com/serverlessworkflow/specification/{version}/schema/workflow.yaml#/$defs/task";
var schema = $"https://raw.githubusercontent.com/serverlessworkflow/serverlessworkflow.github.io/main/static/schemas/{version}/workflow.yaml#/$defs/task";
var type = $"create_{typeof(CustomFunction).Name.ToLower()}_{version}_schema";
await this.MonacoInterop.AddValidationSchemaAsync(schema, $"https://synapse.io/schemas/{type}.json", $"{type}*").ConfigureAwait(false);
this._textModelUri = this.MonacoEditorHelper.GetResourceUri(type);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public async Task<string> GetLatestVersion()
{
if (!string.IsNullOrEmpty(this._latestVersion)) return this._latestVersion;
var tags = await this.HttpClient.GetFromJsonAsync<IEnumerable<GitHubTag>>("https://api.github.com/repos/serverlessworkflow/specification/tags");
this._latestVersion = tags?.FirstOrDefault()?.Name;
this._latestVersion = tags?.FirstOrDefault()?.Name?.Substring(1);
return this._latestVersion ?? string.Empty;
}

Expand All @@ -57,7 +57,7 @@ public async Task<string> GetLatestVersion()
public async Task<string> GetSchema(string version)
{
if (_knownSchemas.TryGetValue(version, out string? value)) return value;
var address = $"https://raw.githubusercontent.com/serverlessworkflow/specification/{version}/schema/workflow.yaml";
var address = $"https://raw.githubusercontent.com/serverlessworkflow/serverlessworkflow.github.io/main/static/schemas/{version}/workflow.yaml";
var yamlSchema = await this.HttpClient.GetStringAsync(address);
this._knownSchemas.Add(version, this.YamlSerializer.ConvertToJson(yamlSchema));
return this._knownSchemas[version];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ import { LineCounter, parseDocument } from "https://esm.sh/yaml";
* @returns
*/
export function addValidationSchema(schema, schemaUri, schemaType) {
let isUrl = false;
try {
schema = JSON.parse(schema);
}
catch {
isUrl = true;
schema = { $ref: schema };
}
// JSON
Expand All @@ -24,7 +26,11 @@ export function addValidationSchema(schema, schemaUri, schemaType) {
schemas: [
...monaco.languages.json.jsonDefaults.diagnosticsOptions.schemas,
{
schema,
schema: isUrl ?
{
$ref: schema.$ref.replace('.yaml', '.json')
} :
schema,
uri: schemaUri,
fileMatch: [schemaType]
}
Expand Down

0 comments on commit c6b75bb

Please sign in to comment.