-
Notifications
You must be signed in to change notification settings - Fork 64
Add $schema to cgmanifest.json
#608
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
Conversation
|
Please, request review when PR is ready. Thanks. |
Context: https://www.jsonschemavalidator.net/ Context: https://github.com/JamieMagee/verify-cgmanifest Context: https://json.schemastore.org/component-detection-manifest.json Context: dotnet/android-libraries#608 There is a [JSON Schema][0] for `CGManifest.json`. Update `xaprepare` so that `CGManifest.json` conforms to the JSON schema. This involves three sets of changes: * Add a `$schema` property. * Add a `version` property; I can't find any actual documentation for this schema, but the [sample manifest][1] uses `"version": 1`, so use the same version. * "camelCase" all the JSON property names. From the [JamieMagee/verify-cgmanifest README.md][2] > Component Detection will accept object properties in PascalCase, > but JSON schema does not have a case-insensitive mode. > Camel case is the most common way to write object properties in > JSON. With these changes, our generated `bin/Build$(Configuration)/CGManifest.json` reports no errors when using <https://www.jsonschemavalidator.net>. [0]: https://json.schemastore.org/component-detection-manifest.json [1]: https://github.com/JamieMagee/verify-cgmanifest/blob/2adfb450cd1f2170c3df120036f4a531285167ef/cgmanifest.sample.json [2]: https://github.com/JamieMagee/verify-cgmanifest/blob/2adfb450cd1f2170c3df120036f4a531285167ef/README.md
Context: https://www.jsonschemavalidator.net/ Context: https://github.com/JamieMagee/verify-cgmanifest Context: https://json.schemastore.org/component-detection-manifest.json Context: dotnet/android-libraries#608 There is a [JSON Schema][0] for `CGManifest.json`. Update `xaprepare` so that `CGManifest.json` conforms to the JSON schema. This involves three sets of changes: * Add a `$schema` property. * Add a `version` property; I can't find any actual documentation for this schema, but the [sample manifest][1] uses `"version": 1`, so use the same version. * "camelCase" all the JSON property names. From the [JamieMagee/verify-cgmanifest README.md][2]: > Component Detection will accept object properties in PascalCase, > but JSON schema does not have a case-insensitive mode. > Camel case is the most common way to write object properties in > JSON. With these changes, our generated `bin/Build$(Configuration)/CGManifest.json` reports no errors when using <https://www.jsonschemavalidator.net>. [0]: https://json.schemastore.org/component-detection-manifest.json [1]: https://github.com/JamieMagee/verify-cgmanifest/blob/2adfb450cd1f2170c3df120036f4a531285167ef/cgmanifest.sample.json [2]: https://github.com/JamieMagee/verify-cgmanifest/blob/2adfb450cd1f2170c3df120036f4a531285167ef/README.md
Context: https://www.jsonschemavalidator.net/ Context: https://github.com/JamieMagee/verify-cgmanifest Context: https://json.schemastore.org/component-detection-manifest.json Context: dotnet/android-libraries#608 There is a [JSON Schema][0] for `CGManifest.json`. Update `tools/java-source-utils/CGManifest.json` so that it conforms to the JSON schema. This involves three sets of changes: * Add a `$schema` property. * Add a `version` property; I can't find any actual documentation for this schema, but the [sample manifest][1] uses `"version": 1`, so use the same version. * "camelCase" all the JSON property names. From the [JamieMagee/verify-cgmanifest README.md][2]: > Component Detection will accept object properties in PascalCase, > but JSON schema does not have a case-insensitive mode. > Camel case is the most common way to write object properties in > JSON. With these changes, `CGManifest.json` reports no errors when using <https://www.jsonschemavalidator.net>. Co-authored-by: Jamie Magee <[email protected]> [0]: https://json.schemastore.org/component-detection-manifest.json [1]: https://github.com/JamieMagee/verify-cgmanifest/blob/2adfb450cd1f2170c3df120036f4a531285167ef/cgmanifest.sample.json [2]: https://github.com/JamieMagee/verify-cgmanifest/blob/2adfb450cd1f2170c3df120036f4a531285167ef/README.md
Context: https://www.jsonschemavalidator.net/ Context: https://github.com/JamieMagee/verify-cgmanifest Context: https://json.schemastore.org/component-detection-manifest.json Context: dotnet/android-libraries#608 There is a [JSON Schema][0] for `CGManifest.json`. Update `xaprepare` so that `CGManifest.json` conforms to the JSON schema. This involves three sets of changes: * Add a `$schema` property. * Add a `version` property; I can't find any actual documentation for this schema, but the [sample manifest][1] uses `"version": 1`, so use the same version. * "camelCase" all the JSON property names. From the [JamieMagee/verify-cgmanifest README.md][2]: > Component Detection will accept object properties in PascalCase, > but JSON schema does not have a case-insensitive mode. > Camel case is the most common way to write object properties in > JSON. With these changes, our generated `bin/Build$(Configuration)/CGManifest.json` reports no errors when using <https://www.jsonschemavalidator.net>. [0]: https://json.schemastore.org/component-detection-manifest.json [1]: https://github.com/JamieMagee/verify-cgmanifest/blob/2adfb450cd1f2170c3df120036f4a531285167ef/cgmanifest.sample.json [2]: https://github.com/JamieMagee/verify-cgmanifest/blob/2adfb450cd1f2170c3df120036f4a531285167ef/README.md
|
As with the similar dotnet/java-interop#1035, the contents of this PR don't match the description: the description says:
which strongly implies that properties should be camelCase, yet the contents of the PR retain PascalCase naming. Consequently, certain validation tools such as https://www.jsonschemavalidator.net/ will flag ~everything as bad, plus the schema requires a |
|
which uses the
An actual fix for |
|
PR just added schema to json - it did not change serialization of the Properties. After serialization fixes: Both local verification and verificiation on https://www.jsonschemavalidator.net/ show no errors with newly generated files. |
|
@jonpryor Yeah, I see how the instructions can be a bit ambiguous. What I intended to convey was that you may use camel case or pascal case for the We currently don't strictly validate Thanks for your help in reviewing the PRs and thank you for editing your automation that generates your |
|
Automatically generated
https://github.com/xamarin/AndroidX/blob/main/cgmanifest.json closing this one without merging. Thanks |
This pull request adds the JSON schema for
cgmanifest.json.FAQ
Why?
A JSON schema helps you to ensure that your
cgmanifest.jsonfile is valid.JSON schema validation is a build-in feature in most modern IDEs like Visual Studio and Visual Studio Code.
Most modern IDEs also provide code-completion for JSON schemas.
How can I validate my
cgmanifest.jsonfile?Most modern IDEs like Visual Studio and Visual Studio Code have a built-in feature to validate JSON files.
You can also use this small script to validate your
cgmanifest.jsonfile.Why does it suggest camel case for the properties?
Component Detection is able to read camel case and pascal case properties.
However, the JSON schema doesn't have a case-insensitive mode.
We therefore suggest camel case as it's the most common format for JSON.
Why is the diff so large?
To deserialize the
cgmanifest.jsonfile, we useJSON.parse().However, to serialize the JSON again we use
prettier.We found that, in general, it gave smaller diffs than the default
JSON.stringify()function.