public async Task<string> GenerateSwaggerAsync() { try { var schema = JsonSchema4.FromJson(JsonSchema.Text); var service = new SwaggerService(); service.Definitions[schema.TypeName ?? "MyType"] = schema; return service.ToJson(); } catch (Exception exception) { MessageBox.Show(exception.Message, "Error loading the JSON Schema"); return string.Empty; // TODO: What to do on error? } }
internal string FromAssemblyType(string assemblyPath, string className) { var assembly = Assembly.LoadFrom(assemblyPath); var type = assembly.GetType(className); var service = new SwaggerService(); var schema = JsonSchema4.FromType(type); service.Definitions[type.Name] = schema; return service.ToJson(); }