Skip to content
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

Feature/improve error checks for gltf #119

Merged
merged 9 commits into from
Jan 15, 2019

Conversation

yutopp
Copy link
Contributor

@yutopp yutopp commented Jan 8, 2019

@yutopp yutopp added the WIP label Jan 8, 2019
@yutopp yutopp force-pushed the feature/improve_error_checks_for_gltf branch from 17164ea to 5361546 Compare January 9, 2019 14:18
@@ -111,10 +111,6 @@ public JsonSchemaValidationException Validate<T>(JsonSchemaValidationContext c,
}

var value = o as string;
if (value.All(x => Char.IsWhiteSpace(x)))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

json schema allows empty string

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

null check ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I'll add null checks for all validators.

}

return null;
return GenericValidator<T>.Validate(Required, Properties, c, o);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check for all fields not only required one.

@@ -47,7 +47,8 @@ public static void SerializeObject(this IFormatter f, object value)
}
else
{
typeof(FormatterExtensionsSerializer).GetMethod("Serialize").MakeGenericMethod(value.GetType()).Invoke(null, new object[] { f, value });
typeof(FormatterExtensionsSerializer).GetMethod("Serialize")
.MakeGenericMethod(value.GetType()).Invoke(null, new object[] { f, value });
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only add a newline.

@@ -92,7 +93,7 @@ static class GenericSerializer<T>
var mi = typeof(IFormatter).GetMethod("Value", new Type[] { t });
if (mi != null)
{
// premitives
// primitives
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo

return null; // There are no json schema for items, success
}

var v = Items.Validator;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check items if there is a validator.

@yutopp yutopp requested a review from ousttrue January 9, 2019 14:25
@yutopp yutopp removed the WIP label Jan 9, 2019
@saturday06
Copy link
Contributor

saturday06 commented Jan 9, 2019

Relax default restrictions in JsonSchema for some cases

  • Allow strings which is filled by whitespaces
  • Allow empty Array/List

Please write these exceptions to VRM specification document. When finished, I apply these changes to VRM Validator .

@yutopp yutopp force-pushed the feature/improve_error_checks_for_gltf branch from 5361546 to 579d533 Compare January 11, 2019 09:41
@yutopp
Copy link
Contributor Author

yutopp commented Jan 11, 2019

Thank you for your comment. I think that json schema is not affected by this changes. Types of Json schema, string and list([]), requires only not null values as default. Thus current implementation requires extra constraints.
However, if there are some fields which depend on this behaviour, I am going to append constraints explicitly to json schema.

NOTE: Current implementation exclude fields which have empty/containing only whitespaces string and 0-length list.
For example, considering a json string {"name": ""}. Current implementation outputs {} because the value is an empty string. On the other hand, this implementation outputs {"name": ""}.

@0b5vr
Copy link
Contributor

0b5vr commented Jan 11, 2019

GLTF spec requires an item at least per array fields (see below) and it was an improvement of the schema between 1.0 and 2.0 (see below)

GLTF 1.0:

https://github.com/KhronosGroup/glTF/blob/27988cbe931308c7b57bdfae3e4ca9e1a34292e1/specification/1.0/schema/mesh.schema.json#L11-L18

GLTF 2.0:

https://github.com/KhronosGroup/glTF/blob/27988cbe931308c7b57bdfae3e4ca9e1a34292e1/specification/2.0/schema/mesh.schema.json#L8-L15

I know we are not bound to this rule but I think we should follow this way.

@yutopp
Copy link
Contributor Author

yutopp commented Jan 15, 2019

Yes, you are right.

Your concerns are cleared. Fields which have constraints like MinItems are not affected by this PR, because it changes only default behaviour of JsonSchema.

@yutopp
Copy link
Contributor Author

yutopp commented Jan 15, 2019

Applying changes for glTF/VRM schames will be done by another PR.

@ousttrue ousttrue merged commit a41617f into master Jan 15, 2019
@yutopp yutopp deleted the feature/improve_error_checks_for_gltf branch January 15, 2019 10:12
@yutopp yutopp added this to the v0.49 milestone Jan 17, 2019
@yutopp
Copy link
Contributor Author

yutopp commented Jan 17, 2019

Changes for glTF/VRM: #123

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants