OPCUAUniCT / OPCUAWebPlatformUniCT

An ASP.NET Core web application exposing OPC UA Servers to non OPCUA-compliant clients with a REST interface
GNU General Public License v2.0
103 stars 43 forks source link

Newtonsoft Json.NET Schema Component Dependency #6

Closed jkancio closed 6 years ago

jkancio commented 6 years ago

Hi, This project depends on the Newtonsoft Json.NET Schema that is a paid Component.

Please, do you have any idea how difficult would be rewrite the code to remove this dependency?

msalafia commented 6 years ago

OPC UA Web Platform use two packages for managing JSON and JSON schema: Json.NET and NJsonSchema. We use only free features of the first one, because only validation are limited for free license (and we don't use them). So that, there is no need to change dependency.

Hope this could be clarifying.

jkancio commented 6 years ago

I'm sorry, but I've got an error: The free-quota limit of 10 schema generations per hour has been reached. Please visit http://www.newtonsoft.com/jsonschema to upgrade to a commercial license.

Besides that, I've seen in https://www.newtonsoft.com/jsonschema that Json.NET Schema is paid and the code has "using Newtonsoft.Json.Schema;", for instance, in ...OPCUAWebPlatformUniCT\OPCUA_Web_Platform\Models\OPCUA\UaValue.cs (class UaValue).

Am I Wrong?

msalafia commented 6 years ago

This is strange because i saw that Json.NET has limitation only for JSON Schema validation (1000 per hous) and not for schema generation.

Can you please provide the line that rise this error?

jkancio commented 6 years ago

Sorry, but since the time I've written to you, I could not reproduce the error anymore. I've been using the code and it is fine up to now.

jkancio commented 6 years ago

Hi, msalafia, I've got again the error at line 238 of DataTypeManager.cs, as you can see bellow.

## JSchemaException: The free-quota limit of 10 schema generations per hour has been reached. Please visit http://www.newtonsoft.com/jsonschema to upgrade to a commercial license.

Newtonsoft.Json.Schema.Infrastructure.Licensing.LicenseHelpers.IncrementAndCheckGenerationCount() Newtonsoft.Json.Schema.Generation.JSchemaGenerator.Generate(Type type, bool rootSchemaNullable) WebPlatform.OPCUALayer.DataTypeManager.SerializeFloat(VariableNode variableNode, Variant value, bool generateSchema) in DataTypeManager.cs + { var schemaGenerator = new JSchemaGenerator(); if (variableNode.ValueRank == -1) { var jFloatVal = new JValue(value.Value); var schema = (generateSchema) ? schemaGenerator.Generate(typeof(float)) : null; return new UaValue(jFloatVal, schema); } else if (variableNode.ValueRank == 1) { var arr = (Array)value.Value; var jArray = new JArray(arr);

marcostefanoscroppo commented 6 years ago

Hi @jkancio, try the code in the branch issue-6. Please, refer to the pull request #9 for code review and let us know if this issue is solved. Only some base DataTypes were affected by this problem. Now everything should be ok.

jkancio commented 6 years ago

I have tested the code since it was published and so far I have not received the error any more.