|
| 1 | +/* |
| 2 | + The MIT License |
| 3 | + |
| 4 | + Copyright (c) 2017-2019 EclipseSource Munich |
| 5 | + https://github.com/eclipsesource/jsonforms |
| 6 | + |
| 7 | + Permission is hereby granted, free of charge, to any person obtaining a copy |
| 8 | + of this software and associated documentation files (the "Software"), to deal |
| 9 | + in the Software without restriction, including without limitation the rights |
| 10 | + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 11 | + copies of the Software, and to permit persons to whom the Software is |
| 12 | + furnished to do so, subject to the following conditions: |
| 13 | + |
| 14 | + The above copyright notice and this permission notice shall be included in |
| 15 | + all copies or substantial portions of the Software. |
| 16 | + |
| 17 | + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 18 | + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 19 | + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 20 | + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 21 | + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 22 | + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 23 | + THE SOFTWARE. |
| 24 | +*/ |
| 25 | +import { registerExamples } from '../register'; |
| 26 | + |
| 27 | +export const schema = { |
| 28 | + $schema: 'http://json-schema.org/draft-07/schema#', |
| 29 | + type: 'object', |
| 30 | + properties: { |
| 31 | + propertiesString: { |
| 32 | + type: 'string', |
| 33 | + }, |
| 34 | + }, |
| 35 | + propertyNames: { |
| 36 | + minLength: 2, |
| 37 | + }, |
| 38 | + patternProperties: { |
| 39 | + '^string$': { |
| 40 | + type: 'string', |
| 41 | + }, |
| 42 | + '^number$': { |
| 43 | + type: 'number', |
| 44 | + }, |
| 45 | + '^integer$': { |
| 46 | + type: 'integer', |
| 47 | + }, |
| 48 | + '^object$': { |
| 49 | + type: 'object', |
| 50 | + properties: { |
| 51 | + prop1: { |
| 52 | + type: 'string', |
| 53 | + }, |
| 54 | + }, |
| 55 | + }, |
| 56 | + '^boolean$': { |
| 57 | + type: 'boolean', |
| 58 | + }, |
| 59 | + '^stringArray$': { |
| 60 | + type: 'array', |
| 61 | + items: { |
| 62 | + type: 'string', |
| 63 | + }, |
| 64 | + }, |
| 65 | + '^numberArray$': { |
| 66 | + type: 'array', |
| 67 | + items: { |
| 68 | + type: 'number', |
| 69 | + }, |
| 70 | + }, |
| 71 | + '^integerArray$': { |
| 72 | + type: 'array', |
| 73 | + items: { |
| 74 | + type: 'integer', |
| 75 | + }, |
| 76 | + }, |
| 77 | + '^objectArray$': { |
| 78 | + type: 'array', |
| 79 | + items: { |
| 80 | + type: 'object', |
| 81 | + properties: { |
| 82 | + prop1: { |
| 83 | + type: 'string', |
| 84 | + }, |
| 85 | + }, |
| 86 | + }, |
| 87 | + }, |
| 88 | + '^booleanArray$': { |
| 89 | + type: 'array', |
| 90 | + items: { |
| 91 | + type: 'boolean', |
| 92 | + }, |
| 93 | + }, |
| 94 | + }, |
| 95 | + additionalProperties: { |
| 96 | + type: 'string', |
| 97 | + title: 'Additional Properties', |
| 98 | + }, |
| 99 | + maxProperties: 15, |
| 100 | +}; |
| 101 | + |
| 102 | +export const uischema = { |
| 103 | + type: 'Control', |
| 104 | + scope: '#/', |
| 105 | +}; |
| 106 | + |
| 107 | +const data = { |
| 108 | + propertiesString: 'data', |
| 109 | + string: 'string value', |
| 110 | + number: 10.2, |
| 111 | + integer: 11, |
| 112 | + object: { |
| 113 | + prop1: 'prop 1 value', |
| 114 | + }, |
| 115 | + boolean: true, |
| 116 | + stringArray: ['value1', 'value2'], |
| 117 | + numberArray: [12.2], |
| 118 | + integerArray: [33], |
| 119 | + objectArray: [{ prop1: 'prop1 val' }, {}], |
| 120 | + booleanArray: [false, true], |
| 121 | +}; |
| 122 | + |
| 123 | +registerExamples([ |
| 124 | + { |
| 125 | + name: 'additional-properties', |
| 126 | + label: 'Additional Properties', |
| 127 | + data, |
| 128 | + schema, |
| 129 | + uischema, |
| 130 | + }, |
| 131 | +]); |
0 commit comments