Skip to content
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

Usage #4

Open
catalinux opened this issue Aug 24, 2015 · 8 comments
Open

Usage #4

catalinux opened this issue Aug 24, 2015 · 8 comments

Comments

@catalinux
Copy link

  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
Copy link
Owner

jlblcc commented Sep 19, 2015

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
Copy link

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
Copy link
Owner

jlblcc commented Sep 23, 2015

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

@amitdesai03
Copy link

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

@michaelilyin
Copy link

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

@catalinux
Copy link
Author

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
Copy link

michaelilyin commented Oct 20, 2016

Ok, thank you

2016-10-20 13:28 GMT+03:00 catalinux [email protected]:

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
#4 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ADk4gWmszVCcSx_VoadLMrA2hg-Th5gXks5q10IxgaJpZM4Fwxas
.

@jlblcc
Copy link
Owner

jlblcc commented Oct 20, 2016

I updated the README with the example from @catalinux.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants