|
@@ -39,8 +39,8 @@ namespace SharpGLTF.SchemaReflection
|
|
|
|
|
|
|
|
private static SchemaType _UseType(this SchemaType.Context ctx, JSONSCHEMA schema, bool isRequired = true)
|
|
private static SchemaType _UseType(this SchemaType.Context ctx, JSONSCHEMA schema, bool isRequired = true)
|
|
|
{
|
|
{
|
|
|
- if (ctx == null) throw new ArgumentNullException(nameof(ctx));
|
|
|
|
|
- if (schema == null) throw new ArgumentNullException(nameof(schema));
|
|
|
|
|
|
|
+ ArgumentNullException.ThrowIfNull(ctx);
|
|
|
|
|
+ ArgumentNullException.ThrowIfNull(schema);
|
|
|
|
|
|
|
|
if (schema is NJsonSchema.JsonSchemaProperty prop)
|
|
if (schema is NJsonSchema.JsonSchemaProperty prop)
|
|
|
{
|
|
{
|
|
@@ -116,6 +116,7 @@ namespace SharpGLTF.SchemaReflection
|
|
|
|
|
|
|
|
var etype = ctx.UseEnum(name, isNullable);
|
|
var etype = ctx.UseEnum(name, isNullable);
|
|
|
|
|
|
|
|
|
|
+ etype.Identifier = _GetSchemaIdentifier(schema);
|
|
|
etype.Description = schema.Description;
|
|
etype.Description = schema.Description;
|
|
|
|
|
|
|
|
foreach (var kvp in dict) etype.SetValue(kvp.Key, (int)kvp.Value);
|
|
foreach (var kvp in dict) etype.SetValue(kvp.Key, (int)kvp.Value);
|
|
@@ -140,6 +141,7 @@ namespace SharpGLTF.SchemaReflection
|
|
|
{
|
|
{
|
|
|
var classDecl = ctx.UseClass(schema.Title);
|
|
var classDecl = ctx.UseClass(schema.Title);
|
|
|
|
|
|
|
|
|
|
+ classDecl.Identifier = _GetSchemaIdentifier(schema);
|
|
|
classDecl.Description = schema.Description;
|
|
classDecl.Description = schema.Description;
|
|
|
|
|
|
|
|
// process base class
|
|
// process base class
|
|
@@ -192,6 +194,26 @@ namespace SharpGLTF.SchemaReflection
|
|
|
throw new NotImplementedException();
|
|
throw new NotImplementedException();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private static string _GetSchemaIdentifier(JSONSCHEMA schema)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (schema.ExtensionData != null)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (schema.ExtensionData.TryGetValue("$id", out var value) && value is string id)
|
|
|
|
|
+ {
|
|
|
|
|
+ return id;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!string.IsNullOrWhiteSpace(schema.DocumentPath))
|
|
|
|
|
+ {
|
|
|
|
|
+ return System.IO.Path.GetFileName(schema.DocumentPath);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return null;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private static bool _IsBlittableType(JSONSCHEMA schema)
|
|
private static bool _IsBlittableType(JSONSCHEMA schema)
|
|
|
{
|
|
{
|
|
|
if (schema == null) return false;
|
|
if (schema == null) return false;
|