-
Notifications
You must be signed in to change notification settings - Fork 0
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
Tst/documentation generation upgrade #13
Changes from all commits
f58d2ee
7ba370e
c29b383
df5c1b9
5dae068
2d23e56
135d418
ba80e53
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,6 @@ jobs: | |
dotnet-version: | | ||
3.1.x | ||
6.0.x | ||
8.0.x | ||
|
||
- name: Cleaning | ||
run: dotnet clean | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,6 @@ jobs: | |
dotnet-version: | | ||
3.1.x | ||
6.0.x | ||
8.0.x | ||
|
||
- name: Cleaning | ||
run: dotnet clean | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System.Collections.Generic; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace EAVFW.Extensions.Manifest.SDK | ||
{ | ||
public class ActionDefinition | ||
{ | ||
[JsonPropertyName("text")] public string Text { get; set; } | ||
[JsonPropertyName("workflow")] public string Workflow { get; set; } | ||
|
||
/// <summary> | ||
/// Exclusively used to capture non-spec items | ||
/// </summary> | ||
[JsonExtensionData] | ||
public Dictionary<string, object> AdditionalFields { get; set; } | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text.Json; | ||
using System.Text.Json.Nodes; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace EAVFW.Extensions.Manifest.SDK | ||
{ | ||
public class AttributeConverter : JsonConverter<AttributeDefinitionBase> | ||
{ | ||
public override AttributeDefinitionBase Read( | ||
ref Utf8JsonReader reader, | ||
Type typeToConvert, | ||
JsonSerializerOptions options) | ||
{ | ||
switch (reader.TokenType) | ||
{ | ||
case JsonTokenType.String: | ||
return new AttributeStringDefinition { Value = reader.GetString() ?? "" }; | ||
case JsonTokenType.StartObject: | ||
var node = JsonNode.Parse(ref reader); | ||
var t = node.Deserialize<AttributeObjectDefinition>(); | ||
return t; | ||
default: | ||
throw new Exception($"{reader.TokenType} is not supported as AttributeDefinition"); | ||
} | ||
} | ||
|
||
public override void Write(Utf8JsonWriter writer, AttributeDefinitionBase value, JsonSerializerOptions options) | ||
{ | ||
var jsonString = value switch | ||
{ | ||
AttributeObjectDefinition attributeObjectDefinition => | ||
JsonSerializer.Serialize(attributeObjectDefinition), | ||
AttributeStringDefinition attributeStringDefinition => | ||
JsonSerializer.Serialize(attributeStringDefinition), | ||
_ => throw new ArgumentException($"{value.GetType()} is not supported") | ||
}; | ||
|
||
var jsonNode = JsonNode.Parse(jsonString); | ||
jsonNode?.WriteTo(writer, options); | ||
} | ||
} | ||
|
||
[JsonConverter(typeof(AttributeConverter))] | ||
public abstract class AttributeDefinitionBase | ||
{ | ||
} | ||
|
||
public class AttributeStringDefinition : AttributeDefinitionBase | ||
{ | ||
public string Value { get; set; } | ||
} | ||
|
||
public class AttributeObjectDefinition : AttributeDefinitionBase | ||
{ | ||
[JsonPropertyName("isPrimaryField")] public bool IsPrimaryField { get; set; } | ||
|
||
[JsonPropertyName("moduleSource")] public string ModuleSource { get; set; } | ||
|
||
[JsonPropertyName("moduleLocation")] public string ModuleLocation { get; set; } | ||
|
||
[JsonPropertyName("type")] public TypeDefinition AttributeType { get; set; } | ||
|
||
/// <summary> | ||
/// Exclusively used to capture non-spec items | ||
/// </summary> | ||
[JsonExtensionData] | ||
public Dictionary<string, JsonElement> AdditionalFields { get; set; } | ||
} | ||
|
||
public class TypeDefinition | ||
{ | ||
[JsonPropertyName("type")] public string Type { get; set; } | ||
[JsonPropertyName("referenceType")] public string ReferenceType { get; set; } | ||
|
||
[JsonPropertyName("options")] public Dictionary<string, JsonElement> Options { get; set; } | ||
|
||
/// <summary> | ||
/// Exclusively used to capture non-spec items | ||
/// </summary> | ||
[JsonExtensionData] | ||
public Dictionary<string, JsonElement> AdditionalFields { get; set; } | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System.Collections.Generic; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace EAVFW.Extensions.Manifest.SDK | ||
{ | ||
public class EntityDefinition | ||
{ | ||
[JsonPropertyName("pluralName")] public string PluralName { get; set; } | ||
[JsonPropertyName("description")] public string Description { get; set; } | ||
[JsonPropertyName("attributes")] public Dictionary<string, AttributeDefinitionBase> Attributes { get; set; } | ||
[JsonPropertyName("wizards")] public Dictionary<string, WizardDefinition> Wizards { get; set; } | ||
|
||
/// <summary> | ||
/// Exclusively used to capture non-spec items | ||
/// </summary> | ||
[JsonExtensionData] | ||
public Dictionary<string, object> AdditionalFields { get; set; } | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using System.Collections.Generic; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace EAVFW.Extensions.Manifest.SDK | ||
{ | ||
public class ManifestDefinition | ||
{ | ||
[JsonPropertyName("entities")] public Dictionary<string, EntityDefinition> Entities { get; set; } | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace EAVFW.Extensions.Manifest.SDK | ||
{ | ||
public class MessageDefinition | ||
{ | ||
[JsonPropertyName("title")] public string? Title { get; set; } | ||
Check warning on line 7 in sdk/DTO/MessageDefinition.cs GitHub Actions / Building
Check warning on line 7 in sdk/DTO/MessageDefinition.cs GitHub Actions / Building
Check warning on line 7 in sdk/DTO/MessageDefinition.cs GitHub Actions / Building
Check warning on line 7 in sdk/DTO/MessageDefinition.cs GitHub Actions / Building
Check warning on line 7 in sdk/DTO/MessageDefinition.cs GitHub Actions / Building
Check warning on line 7 in sdk/DTO/MessageDefinition.cs GitHub Actions / Building
Check warning on line 7 in sdk/DTO/MessageDefinition.cs GitHub Actions / Building
|
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
namespace EAVFW.Extensions.Manifest.SDK | ||
{ | ||
public struct StringOrBoolean | ||
{ | ||
public StringOrBoolean(string stringValue) | ||
{ | ||
StringValue = stringValue; | ||
IsBool = false; | ||
BooleanValue = default; | ||
} | ||
|
||
public StringOrBoolean(bool booleanValue) | ||
{ | ||
StringValue = default; | ||
IsBool = false; | ||
BooleanValue = booleanValue; | ||
} | ||
|
||
public string StringValue { get; } | ||
|
||
public bool BooleanValue { get; } | ||
|
||
public bool IsBool { get; } | ||
|
||
public override string ToString() | ||
{ | ||
return IsBool ? BooleanValue.ToString() : StringValue; | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System.Collections.Generic; | ||
using System.Text.Json; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace EAVFW.Extensions.Manifest.SDK | ||
{ | ||
public class TabDefinition | ||
{ | ||
[JsonPropertyName("columns")] public JsonElement Columns { get; set; } | ||
|
||
[JsonConverter(typeof(StringOrBooleanTabConverter))] | ||
[JsonPropertyName("visible")] | ||
public StringOrBoolean Visible { get; set; } | ||
|
||
[JsonPropertyName("onTransitionOut")] public TransitionDefinition OnTransitionOut { get; set; } | ||
|
||
[JsonPropertyName("onTransitionIn")] public TransitionDefinition OnTransitionIn { get; set; } | ||
|
||
[JsonPropertyName("actions")] public Dictionary<string, ActionDefinition> Actions { get; set; } | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System.Collections.Generic; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace EAVFW.Extensions.Manifest.SDK | ||
{ | ||
public class TransitionDefinition | ||
{ | ||
[JsonPropertyName("workflow")] public string Workflow { get; set; } | ||
|
||
[JsonPropertyName("message")] public MessageDefinition Message { get; set; } | ||
|
||
[JsonExtensionData] public Dictionary<string, object> AdditionalData { get; set; } = new Dictionary<string, object>(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace EAVFW.Extensions.Manifest.SDK | ||
{ | ||
public struct TriggerDefinition | ||
{ | ||
[JsonPropertyName("form")] public string Form { get; set; } | ||
|
||
[JsonPropertyName("ribbon")] public string Ribbon { get; set; } | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System.Collections.Generic; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace EAVFW.Extensions.Manifest.SDK | ||
{ | ||
public class WizardDefinition | ||
{ | ||
[JsonPropertyName("title")] public string Title { get; set; } | ||
|
||
[JsonPropertyName("triggers")] public Dictionary<string, TriggerDefinition> Triggers { get; set; } | ||
|
||
[JsonPropertyName("tabs")] public Dictionary<string, TabDefinition> Tabs { get; set; } | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System; | ||
using System.Text.Json; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace EAVFW.Extensions.Manifest.SDK | ||
{ | ||
public class StringOrBooleanTabConverter : JsonConverter<StringOrBoolean> | ||
{ | ||
public override StringOrBoolean Read( | ||
ref Utf8JsonReader reader, | ||
Type typeToConvert, | ||
JsonSerializerOptions options) | ||
{ | ||
return reader.TokenType switch | ||
{ | ||
JsonTokenType.String => new StringOrBoolean(reader.GetString() ?? ""), | ||
JsonTokenType.False => new StringOrBoolean(false), | ||
JsonTokenType.True => new StringOrBoolean(true), | ||
_ => new StringOrBoolean() | ||
}; | ||
} | ||
|
||
public override void Write(Utf8JsonWriter writer, StringOrBoolean value, JsonSerializerOptions options) | ||
{ | ||
if (value.IsBool) | ||
writer.WriteBooleanValue(value.BooleanValue); | ||
writer.WriteStringValue(value.StringValue); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What case do we have where attribute is not an object?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then the merge property is a string.
I build the first iteration on the non enriched version :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And the moduleSource and moduleLocation is a part of attributes if they are merged from a variable