Skip to content

Commit 7b1d7f0

Browse files
committed
Add required validation for authentication and language mapping options
1 parent 5ff420b commit 7b1d7f0

File tree

4 files changed

+52
-9
lines changed

4 files changed

+52
-9
lines changed

docs/static/schema/configuration.schema.json

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,10 @@
133133
"AccessToken": {
134134
"type": "string"
135135
}
136-
}
136+
},
137+
"required": [
138+
"AuthenticationMode"
139+
]
137140
},
138141
"Collection": {
139142
"description": "URI of the TFS collection (e.g., \"http://tfsserver:8080/tfs/DefaultCollection\"). Must be a valid absolute URL pointing to the TFS collection.",
@@ -162,7 +165,11 @@
162165
"IterationPath": {
163166
"type": "string"
164167
}
165-
}
168+
},
169+
"required": [
170+
"AreaPath",
171+
"IterationPath"
172+
]
166173
},
167174
"Name": {
168175
"description": "missing XML code comments",
@@ -214,7 +221,10 @@
214221
"AccessToken": {
215222
"type": "string"
216223
}
217-
}
224+
},
225+
"required": [
226+
"AuthenticationMode"
227+
]
218228
},
219229
"Collection": {
220230
"description": "URI of the TFS collection (e.g., \"http://tfsserver:8080/tfs/DefaultCollection\"). Must be a valid absolute URL pointing to the TFS collection.",
@@ -243,7 +253,11 @@
243253
"IterationPath": {
244254
"type": "string"
245255
}
246-
}
256+
},
257+
"required": [
258+
"AreaPath",
259+
"IterationPath"
260+
]
247261
},
248262
"Name": {
249263
"description": "missing XML code comments",
@@ -295,7 +309,10 @@
295309
"AccessToken": {
296310
"type": "string"
297311
}
298-
}
312+
},
313+
"required": [
314+
"AuthenticationMode"
315+
]
299316
},
300317
"Collection": {
301318
"description": "URI of the TFS collection (e.g., \"http://tfsserver:8080/tfs/DefaultCollection\"). Must be a valid absolute URL pointing to the TFS collection.",
@@ -324,7 +341,11 @@
324341
"IterationPath": {
325342
"type": "string"
326343
}
327-
}
344+
},
345+
"required": [
346+
"AreaPath",
347+
"IterationPath"
348+
]
328349
},
329350
"Name": {
330351
"description": "missing XML code comments",
@@ -376,7 +397,10 @@
376397
"AccessToken": {
377398
"type": "string"
378399
}
379-
}
400+
},
401+
"required": [
402+
"AuthenticationMode"
403+
]
380404
},
381405
"Collection": {
382406
"description": "URI of the TFS collection (e.g., \"http://tfsserver:8080/tfs/DefaultCollection\"). Must be a valid absolute URL pointing to the TFS collection.",
@@ -405,7 +429,11 @@
405429
"IterationPath": {
406430
"type": "string"
407431
}
408-
}
432+
},
433+
"required": [
434+
"AreaPath",
435+
"IterationPath"
436+
]
409437
},
410438
"Name": {
411439
"description": "missing XML code comments",
@@ -428,7 +456,10 @@
428456
"type": "string"
429457
}
430458
}
431-
}
459+
},
460+
"required": [
461+
"Query"
462+
]
432463
},
433464
"ReflectedWorkItemIdField": {
434465
"description": "Name of the custom field used to store the reflected work item ID for tracking migrated items. Typically \"Custom.ReflectedWorkItemId\".",

src/MigrationTools.Clients.TfsObjectModel/EndPoints/Infrastructure/TfsTeamProjectAuthentication.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Linq;
4+
using System.ComponentModel.DataAnnotations;
45
using System.Text;
56
using System.Threading.Tasks;
67
using Microsoft.Extensions.Options;
@@ -16,6 +17,7 @@ namespace MigrationTools.Endpoints.Infrastructure
1617
public class TfsAuthenticationOptions : IValidateOptions<TfsAuthenticationOptions>
1718
{
1819
[JsonConverter(typeof(StringEnumConverter))]
20+
[Required]
1921
public AuthenticationMode AuthenticationMode { get; set; }
2022

2123
[JsonProperty( NullValueHandling = NullValueHandling.Ignore)]

src/MigrationTools.Clients.TfsObjectModel/Endpoints/TfsLanguageMapOptions.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
using System.Linq;
33
using Microsoft.Extensions.Options;
44
using Serilog;
5+
using Newtonsoft.Json;
6+
using Newtonsoft.Json.Converters;
7+
using System.ComponentModel.DataAnnotations;
58

69
namespace MigrationTools.Endpoints
710
{
@@ -14,12 +17,14 @@ public class TfsLanguageMapOptions : IValidateOptions<TfsLanguageMapOptions>
1417
/// Gets or sets the field name for the area path in the TFS system language (e.g., "Area" for English, "Zone" for French).
1518
/// </summary>
1619
/// <default>Area</default>
20+
[Required]
1721
public string AreaPath { get; set; }
1822

1923
/// <summary>
2024
/// Gets or sets the field name for the iteration path in the TFS system language (e.g., "Iteration" for English, "Itération" for French).
2125
/// </summary>
2226
/// <default>Iteration</default>
27+
[Required]
2328
public string IterationPath { get; set; }
2429

2530
public ValidateOptionsResult Validate(string name, TfsLanguageMapOptions options)

src/MigrationTools.ConsoleDataGenerator/DataSerialization.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,11 @@ private static JSchema BuildInlineObjectSchemaFromType(Type t, string descriptio
523523
{
524524
var ps = BuildSchemaForType(p.PropertyType);
525525
schema.Properties[p.Name] = ps;
526+
// Capture required attribute for nested complex types
527+
if (p.GetCustomAttributes(typeof(System.ComponentModel.DataAnnotations.RequiredAttribute), inherit: true).Any())
528+
{
529+
schema.Required.Add(p.Name);
530+
}
526531
}
527532
return schema;
528533
}

0 commit comments

Comments
 (0)