jlblcc / json-schema-viewer

JavaScript tool for visualizing json-schemas
jlblcc.github.io/json-schema-viewer
The Unlicense
186 stars 69 forks source link

Usage #4

Open catalinux opened 9 years ago

catalinux commented 9 years ago
  1. How can I build/use the project for my own schema
  2. Does the schema requires some attributes that are not required by http://json-schema.org/draft-04/schema#
jlblcc commented 9 years ago

Sorry for the delay. I just merged a some code into this repo from another fork which is using the JSV as part of a larger application. I removed the extra code and have published to Bower(json-schema-viewer). You can install using Bower or clone the repo and use Grunt to build the JQM interface (grunt prod will build the minified js files, css, and examples). It's not necessary to use JQM, see basic.html for an example of this.

None of the extra attributes are required, if you don't supply them the viewer will ignore them or display a message stating that they weren't defined. However, the full draft-04 isn't supported, for example the viewer won't handle "format" - see the README for more background.

I'll try to add some better documentation soon.

amitdesai03 commented 9 years ago

Hey jlblcc, nice work...trying to use your code, however its hard to figure out how to use in browser..can you please provide some detailed documentation...thanks.

jlblcc commented 9 years ago

It's on the todo list, #6. What issues are you having?

amitdesai03 commented 9 years ago

I got past setup...i guess i am having trouble rendering properly...let me try and see if i can get past those...

michaelilyin commented 7 years ago

Hello, how I can load own schema to the viewer?

catalinux commented 7 years ago

You have smth like that

          (function($) {

            var loc = window.location,
            //if not already set, set the root schema location
            //this allows dev ENV to override the schema location
                schema = JSV.schema ? JSV.schema : loc.origin + loc.pathname.substring(0, loc.pathname.lastIndexOf('/') + 1) + 'schemas/schema/schema.json';

            JSV.init({
              schema : schema,
              plain : true, //don't use JQM
              viewerHeight : $('#main-body').height(), //set initial dimensions of SVG
              viewerWidth : $('#main-body').width()
            }, function() {
              $('#jsv-tree').css('width', '100%');
              //set diagram width to 100%, this DOES NOT resize the svg container
              //it will not adjust to window resize, needs a listener to support that
              JSV.resetViewer();
              $('#loading').fadeOut('slow');
            });
          })(jQuery);

variable schema has to be the url of your schema. Otherwhie it loads 'schemas/schema/schema.json relative to your path

Example: http://jlblcc.github.io/json-schema-viewer/basic.html

michaelilyin commented 7 years ago

Ok, thank you

2016-10-20 13:28 GMT+03:00 catalinux notifications@github.com:

You have smth like that

      (function($) {

        var loc = window.location,
        //if not already set, set the root schema location
        //this allows dev ENV to override the schema location
            schema = JSV.schema ? JSV.schema : loc.origin + loc.pathname.substring(0, loc.pathname.lastIndexOf('/') + 1) + 'schemas/schema/schema.json';

        JSV.init({
          schema : schema,
          plain : true, //don't use JQM
          viewerHeight : $('#main-body').height(), //set initial dimensions of SVG
          viewerWidth : $('#main-body').width()
        }, function() {
          $('#jsv-tree').css('width', '100%');
          //set diagram width to 100%, this DOES NOT resize the svg container
          //it will not adjust to window resize, needs a listener to support that
          JSV.resetViewer();
          $('#loading').fadeOut('slow');
        });
      })(jQuery);

variable schema has to be the url of your schema. Otherwhie it loads 'schemas/schema/schema.json relative to your path

Example: http://jlblcc.github.io/json-schema-viewer/basic.html

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/jlblcc/json-schema-viewer/issues/4#issuecomment-255069124, or mute the thread https://github.com/notifications/unsubscribe-auth/ADk4gWmszVCcSx_VoadLMrA2hg-Th5gXks5q10IxgaJpZM4Fwxas .

jlblcc commented 7 years ago

I updated the README with the example from @catalinux.