Skip to content

Fixed the custom function validation when using the JSON editor of the Dashboard #438

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading