How to set a schema in `node_modules` as a `$schema` - json

I'm creating an npm package which contains a schema file, set.schema.json. I'm wondering how I can set this as the $schema of a JSON file in another project with this package installed as a dependency. I'm mainly using the schema for IDE suggestions, rather than validation.

JSON Schema does not specify a way to do this.
Any way you want to do this needs to be supported by the IDE in question.

Related

vs code ui editor for json schemas

Hei Guys,
I wonder if it is possible to edit jsons according to json schemas like settings.json in a ui form in vs code?
Can anyone tell if this is possible in vs code?
Yep! Although support for $schema in instance data isn't something that JSON Schema defines, it has become something of a convention.
VSCode supports declaring $schema in your data, and even supports relative paths.
In this example, my JSON data file Untitled-1.json is defined in the same folder as schema.json.

JSON Schema - How to define dependencies between properties located in different files?

I am working with JSON schema for a file, which keeps a set of variables we are using to define our configuration, which will be executed through Ansible. Importantly, we are using JSON schema to validate YAML files.
So far everything goes well. However, I have this challenge.
I have a file called common.yml and other called domain.yml. Inside domain.yml we have a property called domain_root, which depends on a property called common_dir, which is inside common.yml and I have not found any documentation on how to define a dependency when the property is in place, but in another file.
By the way, dependencies in the same file are working without issues.
"dependencies": {
"domain_home": ["domain_parent_dir", "domain_name"],
"domain_libraries":["domain_home"],
"logs_directory":["oracle_user", "domain_name"],
}
Please, if you have any clues, kindly help me.
Best regards,
RCC
You cannot. JSON Schema actually doesn't work with files at all. JSON Schema implementations may load a file to get to the JSON, but JSON Schema knows nothing about files in a filesystem.
In stead, consider combining your multiple files into a single file for validation purposes.
This doesn't help if you want validation in-editor, but could help if you only need validation as part of a continuious intergration (CI) process.

Best tool for .json file schema validation

There are probably a lot of tools/libraries to validate JSON schemas.
I have a library and want users of my library to have configuration files that match the expected API.
Using Webstorm, the IDE will tell me that my Webpack config file schema is incorrect, something like this:
The Webpack files that are responsible are here:
https://github.com/webpack/webpack/blob/master/schemas/webpackOptionsSchema.json
Integration with existing IDEs like Webstorm, VSCode, Atom, ST3, etc, would be a huge plus.
I haven't figured out how to do this right...anybody know?
To integrate with various IDEs, consider uploading your json schema to JSON Schema Store.
Here is the GitHub Repo
https://github.com/SchemaStore/schemastore
This contains json schemas for many well known json files and gets integrated with Visual Studio and VS Code easily.
Also look at step by step integrations steps for Visual Studio
https://scottaddie.com/2016/08/02/community-driven-json-schemas-in-visual-studio-2015/

How to create a Oozie workflow using restful instead of Editor UI?

Normally, we create an oozie workflow using the Editor UI such as:
The workflow could also be exported into a json file and import by a json file too. Could someone tell me, there is a way to import/create a workflow with json file and restful(using python, java, c++ or any other language).
When I create a new workflow, I specify "HDFS deployment directory".editor and remove the need to manually edit the XML. Romain.

How can I import JSON data from a REST API into BIRT?

I want to use BIRT to generate reports against data that comes from a JSON based REST API. How can I import this data?
The process for doing this is described at http://developer.actuate.com/community/forum/?app=blog&blogid=45&showentry=471, but it turns out that there are a few important steps missing. I'll fill in a few blanks here.
The original instructions describe creating a Scripted Data Source, with an "open" script that makes use of the com.actuate.json.JSONParser class. First, it is important to realise that this class is not part of BIRT, and needs to be manually added (along with any dependencies).
The download provided by the original instructions provides the com.actuate.json.JSONParser class, but leaves it up to you to source the dependencies. To make things easier I have reimplemented the JSONParser library in Maven, which will then download and package the dependencies for you. It also includes some bug fixes and enhancements like GZIP compression support. You can get the Maven project from https://github.com/mcasperson/birt-jsonparser, and to build the JSONParser library and package the dependencies, run the command
mvn clean package dependency:copy-dependencies
This will result in the birt-jsonparser-0.0.1-SNAPSHOT.jar file being created in the target directory, and all the dependencies copied into the target\dependency directory. Copy all of these JAR files into the {BIRT_INSTALL}/plugins/org.eclipse.birt.report.viewer_{BIRT_VIEWER_VERSION}/birt/scriptlib directory to allow the JSONParser class to be accessed from within your BIRT report.
If you want to debug your report, these JAR files will also have to be referenced in the Debug profile.