fix generator

This commit is contained in:
ousttrue 2021-07-02 19:49:01 +09:00
parent fa460f0031
commit a1b8ef429e
4 changed files with 16 additions and 7 deletions

View File

@ -190,6 +190,10 @@ namespace UniGLTF.JsonSchema
var key = prop.Key.GetString();
var propJsonPath = $"{jsonPath}.{key}";
var propSchema = Parse(prop.Value, propJsonPath);
if (string.IsNullOrEmpty(propSchema.title))
{
propSchema.title = key.ToUpperCamel();
}
if (propSchema is null)
{
if (source.baseSchema is null)

View File

@ -48,9 +48,9 @@ namespace UniGLTF.JsonSchema.Schemas
public static $0 $2(JsonNode parsed)
{
var value = new $1();
foreach(var (k, v) in parsed.ObjectItems())
foreach(var kv in parsed.ObjectItems())
{
value.Add($3);
value.Add(kv.Key.GetString(), $3);
}
return value;
}
@ -58,7 +58,7 @@ public static $0 $2(JsonNode parsed)
.Replace("$0", ValueType)
.Replace("$1", ValueType)
.Replace("$2", callName)
.Replace("$3", AdditionalProperties.GenerateDeserializerCall(itemCallName, "v"))
.Replace("$3", AdditionalProperties.GenerateDeserializerCall(itemCallName, "kv.Value"))
);
}
@ -83,13 +83,13 @@ public static void {callName}(JsonFormatter f, {ValueType} value)
{{
f.BeginMap();
foreach(var (k, v) in value)
foreach(var kv in value)
{{
f.Key(k);
f.Key(kv.Key);
"
);
writer.Write($"{AdditionalProperties.GenerateSerializerCall(itemCallName, "v")};\n");
writer.Write($"{AdditionalProperties.GenerateSerializerCall(itemCallName, "kv.Value")};\n");
writer.Write(@"
}

View File

@ -25,6 +25,11 @@ namespace UniGLTF.JsonSchema.Schemas
throw new NotImplementedException();
}
if (string.IsNullOrEmpty(prop.Title))
{
prop.Title = kv.Key.ToUpperCamel();
}
var key = kv.Key;
Properties.Add(key, prop);
}

View File

@ -2309,7 +2309,7 @@ public static Expressions Deserialize_Expressions(JsonNode parsed)
return value;
}
public static Preset __expressions_Deserialize_Preset(JsonNode parsed)
public static Preset __expressions_Deserialize_Preset(JsonNode parsed)
{
var value = new Preset();