From 7a26f597a99da9cd8845053199c414228f09a7a4 Mon Sep 17 00:00:00 2001 From: Leonardo Matos Date: Thu, 4 Oct 2018 10:44:30 -0300 Subject: [PATCH] v1.1.0 --- dist/twbschema.min.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/twbschema.min.js b/dist/twbschema.min.js index bea9d5a..3113e83 100644 --- a/dist/twbschema.min.js +++ b/dist/twbschema.min.js @@ -1 +1 @@ -window.twbschema=(function(){var a=/([[(]?([\w-]+)?(_|\*)([\w-]+)?[\])]?)/g;var b=0;var c="";var e=function(z,k){var x;var p="";var u;if(!k){u=true;k=""}var f=z.required;var j=Object.assign({},z.properties,z.patternProperties);var y="";for(var g in j){if(j.hasOwnProperty(g)){var m=k+g;var t="schema-field-"+b;b++;var r="";if(Array.isArray(f)){for(x=0;xrequired';break}}}var h=j[g];var l=h.type;if(Array.isArray(l)){l=l[0]}var v;if(h.description){v=h.description.replace(a,'$1')}else{v=""}var o="";var n=function(A,C){if(C===undefined){return}var D;if(Array.isArray(C)&&typeof C[0]!=="object"){D="";for(var B=0;B0){D+=' · '}D+=""+C[B]+""}}else{switch(typeof C){case"string":case"number":D=C;break;default:D=JSON.stringify(C)}D=""+D+""}o+='
  • '+A+": "+D+"
  • "};if(h.hasOwnProperty("default")){n("Default",h["default"])}if(h["enum"]){n("Possible values",h["enum"])}var s="";var w=function(){l='"};switch(l){case"integer":case"number":n("Minimun",h.minimum);n("Maximum",h.maximum);n("Max precision",h.multipleOf);break;case"string":n("Min length",h.minLength);n("Max length",h.maxLength);n("Format",h.format);n("RegEx",h.pattern);break;case"object":w();m+=".";s=e(h,m);n("Min properties",h.minProperties);n("Max properties",h.maxProperties);break;case"array":l=l+"["+h.items.type+"]";w();if(h.items.type==="object"){m+="[].";s=e(h.items,m)}else{var q={properties:{"[]":h.items}};s=e(q,m)}n("Min elements",h.minItems);n("Max elements",h.maxItems);break}if(o!==""){o='
      '+o+"
    "}p+='
    '+k+""+g+'
    '+l+r+'
    '+v+'
    '+o+'
    '+s+"
    ";if(u){if(c!==""){c=""}else{c=" bg-light"}}if(y===""){y=" border-top"}}}return p};var d=function(h,j){var g,i;if(typeof j==="string"){try{g=JSON.parse(j)}catch(k){i=k}}else{if(typeof j==="object"&&j!==null){g=j}else{i=new Error("Schema must be a valid JSON object or string")}}if(i){console.error("[twbschema fatal error (invalid schema)]",i)}else{var f=e(g);if(typeof h==="object"&&h!==null&&h.innerHTML){h.innerHTML=f}else{return f}}};return{doc:d}}()); \ No newline at end of file +window.twbschema=(function(){var a=/([[(]?([\w-]+)?(_|\*)([\w-]+)?[\])]?)/g;var b=0;var c="";var e=function(z,k){var x;var p="";var u;if(!k){u=true;k=""}var f=z.required;var j=Object.assign({},z.properties,z.patternProperties);var y="";for(var g in j){if(j.hasOwnProperty(g)){var m=k+g;var t="schema-field-"+b;b++;var r="";if(Array.isArray(f)){for(x=0;xrequired';break}}}var h=j[g];var l=h.type;if(Array.isArray(l)){l=l[0]}var v;if(h.description){v=h.description.replace(a,'$1')}else{v=""}var o="";var n=function(A,C){if(C===undefined){return}var D;if(Array.isArray(C)&&typeof C[0]!=="object"){D="";for(var B=0;B0){D+=' · '}D+=""+C[B]+""}}else{switch(typeof C){case"string":case"number":D=C;break;default:D=JSON.stringify(C)}D=""+D+""}o+='
  • '+A+": "+D+"
  • "};if(h.hasOwnProperty("default")){n("Default",h["default"])}if(h["enum"]){n("Possible values",h["enum"])}var s="";var w=function(){l='"};switch(l){case"number":n("Minimun",h.minimum);n("Maximum",h.maximum);n("Max precision",h.multipleOf);break;case"integer":n("Minimun",h.min);n("Maximum",h.max);break;case"string":n("Min length",h.minLength);n("Max length",h.maxLength);n("Format",h.format);n("RegEx",h.pattern);break;case"object":w();m+=".";s=e(h,m);n("Min properties",h.minProperties);n("Max properties",h.maxProperties);break;case"array":l=l+"["+h.items.type+"]";w();if(h.items.type==="object"){m+="[].";s=e(h.items,m)}else{var q={properties:{"[]":h.items}};s=e(q,m)}n("Min elements",h.minItems);n("Max elements",h.maxItems);break}if(o!==""){o='
      '+o+"
    "}p+='
    '+k+""+g+'
    '+l+r+'
    '+v+'
    '+o+'
    '+s+"
    ";if(u){if(c!==""){c=""}else{c=" bg-light"}}if(y===""){y=" border-top"}}}return p};var d=function(h,j){var g,i;if(typeof j==="string"){try{g=JSON.parse(j)}catch(k){i=k}}else{if(typeof j==="object"&&j!==null){g=j}else{i=new Error("Schema must be a valid JSON object or string")}}if(i){console.error("[twbschema fatal error (invalid schema)]",i)}else{var f=e(g);if(typeof h==="object"&&h!==null&&h.innerHTML){h.innerHTML=f}else{return f}}};return{doc:d}}()); \ No newline at end of file diff --git a/package.json b/package.json index ad571fb..3f4f48b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "twbschema", - "version": "1.0.0", + "version": "1.1.0", "description": "Docs with Boostrap 4 for your JSON schema types", "main": "main.js", "scripts": {