Skip to content

Commit

Permalink
Fix Json Schema Generation; Re-generate all Schemas (#395)
Browse files Browse the repository at this point in the history
  • Loading branch information
hf-kklein authored Jan 2, 2024
1 parent 60c60bb commit efe49e5
Show file tree
Hide file tree
Showing 12 changed files with 3,263 additions and 727 deletions.
12 changes: 8 additions & 4 deletions BO4ETestProject/TestJsonSchemaGeneration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Linq;
using System.Text;
using BO4E.BO;
using FluentAssertions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json.Schema;

Expand Down Expand Up @@ -32,20 +33,23 @@ public void NegativeTest()
}



private const int LastDataRowOffset = 40;
private const int MaxSchemasPerHour = 10;
[TestMethod]
[DataRow(0)]
[DataRow(10)]
[DataRow(20)]
[DataRow(30)]
[DataRow(40)] // using these different data rows you to workaround the 10schema per hour limitation
[DataRow(LastDataRowOffset)] // using these different data rows you to workaround the 10schema per hour limitation (MaxSchemasPerHour)

public void TestJSchemaFileGenerationBo(int offset)
{
var relevantBusinessObjectTypes = typeof(BusinessObject).Assembly.GetTypes()
.Where(t => t.IsSubclassOf(typeof(BusinessObject)));
relevantBusinessObjectTypes.Count().Should().BeLessThan(LastDataRowOffset + MaxSchemasPerHour); // if this fails, add another data row to this test method
try
{
foreach (var type in typeof(BusinessObject).Assembly.GetTypes()
.Where(t => t.IsSubclassOf(typeof(BusinessObject))).Skip(offset).Take(10))
foreach (var type in relevantBusinessObjectTypes.Skip(offset).Take(MaxSchemasPerHour))
{
var schema = BusinessObject.GetJsonSchema(type);
Assert.IsNotNull(schema);
Expand Down
123 changes: 98 additions & 25 deletions json-schema-files/BO4E.BO.Anfrage.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,49 @@
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"ExterneReferenz": {
"type": ["object", "null"],
"type": [
"object",
"null"
],
"properties": {
"exRefName": {
"type": ["string", "null"]
"type": [
"string",
"null"
]
},
"exRefWert": {
"type": ["string", "null"]
"type": [
"string",
"null"
]
},
"timestamp": {
"type": ["string", "null"],
"type": [
"string",
"null"
],
"format": "date-time"
},
"guid": {
"type": ["string", "null"]
"type": [
"string",
"null"
]
}
}
},
"Zeitraum": {
"type": ["object", "null"],
"type": [
"object",
"null"
],
"properties": {
"einheit": {
"type": ["string", "null"],
"type": [
"string",
"null"
],
"enum": [
null,
"SEKUNDE",
Expand All @@ -39,65 +60,110 @@
]
},
"dauer": {
"type": ["number", "null"]
"type": [
"number",
"null"
]
},
"startdatum": {
"type": ["string", "null"],
"type": [
"string",
"null"
],
"format": "date-time"
},
"enddatum": {
"type": ["string", "null"],
"type": [
"string",
"null"
],
"format": "date-time"
},
"startzeitpunkt": {
"type": ["string", "null"],
"type": [
"string",
"null"
],
"format": "date-time"
},
"endzeitpunkt": {
"type": ["string", "null"],
"type": [
"string",
"null"
],
"format": "date-time"
},
"timestamp": {
"type": ["string", "null"],
"type": [
"string",
"null"
],
"format": "date-time"
},
"guid": {
"type": ["string", "null"]
"type": [
"string",
"null"
]
}
},
"required": ["startzeitpunkt", "endzeitpunkt"]
"required": [
"startzeitpunkt",
"endzeitpunkt"
]
}
},
"type": "object",
"properties": {
"boTyp": {
"type": ["string", "null"]
"type": [
"string",
"null"
]
},
"versionStruktur": {
"type": ["string", "null"]
"type": [
"string",
"null"
]
},
"timestamp": {
"type": ["string", "null"],
"type": [
"string",
"null"
],
"format": "date-time"
},
"externeReferenzen": {
"type": ["array", "null"],
"type": [
"array",
"null"
],
"items": {
"$ref": "#/definitions/ExterneReferenz"
}
},
"guid": {
"type": ["string", "null"]
"type": [
"string",
"null"
]
},
"lokationsId": {
"type": "string"
},
"lokationsTyp": {
"type": "string",
"enum": ["MALO", "MELO"]
"enum": [
"MALO",
"MELO"
]
},
"obiskennzahl": {
"type": ["string", "null"]
"type": [
"string",
"null"
]
},
"ZeitraumMesswertanfrage": {
"$ref": "#/definitions/Zeitraum"
Expand All @@ -123,7 +189,10 @@
]
},
"anfragetyp": {
"type": ["string", "null"],
"type": [
"string",
"null"
],
"enum": [
null,
"START_ABO",
Expand All @@ -142,5 +211,9 @@
]
}
},
"required": ["lokationsId", "lokationsTyp", "anfragekategorie"]
}
"required": [
"lokationsId",
"lokationsTyp",
"anfragekategorie"
]
}
Loading

0 comments on commit efe49e5

Please sign in to comment.