[ABANDONED] Request to the developers to fix the jsonschema library

Hello!

So I'm not sure if this is where I should post this.

In our team we are currently using one of Ignitions libraries, the jsonschema library.

One of the JSON Schema functionalities is making a reference to another schema (another file or an url).

Let me show you the code of the library that make that works:

1 try {
2    URL url = new URL(schemaUrl);
3    parentSchema = factory.getSchema(url);
4 } catch (MalformedURLException var10) {
5    InputStream is =  Thread.currentThread().getContextClassLoader().getResourceAsStream(schemaUrl);
6    parentSchema = factory.getSchema(is);
7 }

This work with no problem, with the exception of the line 5. For some reason getResourceAsStream() doesn't work in Ignition.

My request to the developers is to change that line of code so the InputStream gets selected correctly.

I know that Ignition doesn't give support to Ignition's Java Docs libraries but the library already has modifications. So maybe another one won't cost.

I'll link in the next comment the complete code of the jsonschema library.

What scope (gateway, client/designer) is your code trying to use this library from?

I don't think it was our intention to provide this as a general purpose library for module authors. It looks like it's in the common package simply because we use it from multiple scopes.

It's a script in the scripting, so I think it gets executed in the gateway, it is not for a module design. We use it to validate the messages from the http requests (they are in json format).

The library is com.inductiveautomation.ignition.common.jsonschema.

Why are you trying to use getResourceAsStream() from jython? That is for retrieving resource files from java jars, not for general file access.

1 Like

I'm not. That's the code from the library. I asking them to change it.

No, it’s working as intended.

It is not. I've been trying to make a reference to another schema file for weeks. I even have some tickets open trying to find the problem (thanks a lot to Jacob Wever, he has been amazing with his help).

I've been able to make it work with a normal java project, but for ignition is not possible.

From my understanding getResourceAsStream() does not work on Ignition so is not possible to reference another file.

That is an internal library for Ignition's own use. It is not published for integrators' use--IA publishes supported functionality in system.*, so it is not something IA supports using. Jython lets you get at the class because jython lets you get at pretty much anything in java. That doesn't make it a supported use. And you seem to have no clue what getResourceAsStream() is even supposed to do. (It isn't broken at all.)

This class is all about validating the JSON that Ignition itself uses against schemas that ship with Ignition.

To move forward, consider making your own subclass of BaseJsonValidator. Not sure if that will work, but it might.

Side note: Do you not see a problem with publicly displaying the complete decompilation of one of IA's copyrighted classes?

6 Likes

I don't understand why would make accessible libraries that shouldn't be.

Also, I didn't thought posting that would be that bad (already deleted).

However, I already asked this topic to be deleted given the negativity of the responses.

Thanks anyway for the help.

They aren't deliberately accessible. They are accessible because that's how jython works.

IA documents the functionality they support.

I would object to that. This topic is educational for others.

(Deleting the copyrighted code was a good action.)