| 1 | #Region "Microsoft.VisualBasic::fffc9d2074ab275a77c1a577b9852988, Microsoft.VisualBasic.Core\Serialization\JSON\SchemaProvider\Schema.vb" |
| 2 | |
| 3 | ' Author: |
| 4 | ' |
| 5 | ' asuka (amethyst.asuka@gcmodeller.org) |
| 6 | ' xie (genetics@smrucc.org) |
| 7 | ' xieguigang (xie.guigang@live.com) |
| 8 | ' |
| 9 | ' Copyright (c) 2018 GPL3 Licensed |
| 10 | ' |
| 11 | ' |
| 12 | ' GNU GENERAL PUBLIC LICENSE (GPL3) |
| 13 | ' |
| 14 | ' |
| 15 | ' This program is free software: you can redistribute it and/or modify |
| 16 | ' it under the terms of the GNU General Public License as published by |
| 17 | ' the Free Software Foundation, either version 3 of the License, or |
| 18 | ' (at your option) any later version. |
| 19 | ' |
| 20 | ' This program is distributed in the hope that it will be useful, |
| 21 | ' but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 22 | ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 23 | ' GNU General Public License for more details. |
| 24 | ' |
| 25 | ' You should have received a copy of the GNU General Public License |
| 26 | ' along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 27 | |
| 28 | |
| 29 | |
| 30 | ' /********************************************************************************/ |
| 31 | |
| 32 | ' Summaries: |
| 33 | |
| 34 | ' Class Schema |
| 35 | ' |
| 36 | ' Properties: title |
| 37 | ' |
| 38 | ' Function: ToString |
| 39 | ' |
| 40 | ' Class SchemaProvider |
| 41 | ' |
| 42 | ' Properties: description, properties, required, type |
| 43 | ' |
| 44 | ' Class [Property] |
| 45 | ' |
| 46 | ' Properties: exclusiveMinimum, minimum, name, ref |
| 47 | ' |
| 48 | ' Function: ToString |
| 49 | ' |
| 50 | ' |
| 51 | ' /********************************************************************************/ |
| 52 | |
| 53 | #End Region |
| 54 | |
| 55 | Imports Microsoft.VisualBasic.ComponentModel.Collection |
| 56 | Imports Microsoft.VisualBasic.ComponentModel.Collection.Generic |
| 57 | |
| 58 | Namespace Serialization.JSON |
| 59 | |
| 60 | ''' <summary> |
| 61 | ''' Here is a basic example of a JSON Schema: |
| 62 | ''' |
| 63 | ''' ```json |
| 64 | ''' { |
| 65 | ''' "title": "Example Schema", |
| 66 | ''' "type": "object", |
| 67 | ''' "properties": { |
| 68 | ''' "firstName": { |
| 69 | ''' "type": "string" |
| 70 | ''' }, |
| 71 | ''' "lastName": { |
| 72 | ''' "type": "string" |
| 73 | ''' }, |
| 74 | ''' "age": { |
| 75 | ''' "description": "Age in years", |
| 76 | ''' "type": "integer", |
| 77 | ''' "minimum": 0 |
| 78 | ''' } |
| 79 | ''' }, |
| 80 | ''' "required": ["firstName", "lastName"] |
| 81 | ''' } |
| 82 | ''' ``` |
| 83 | ''' </summary> |
| 84 | Public Class Schema : Inherits SchemaProvider |
| 85 | |
| 86 | Public Property title As String |
| 87 | |
| 88 | Public Overrides Function ToString() As String |
| 89 | Return Me.GetJson(simpleDict:=True) |
| 90 | End Function |
| 91 | End Class |
| 92 | |
| 93 | Public MustInherit Class SchemaProvider |
| 94 | Public Property description As String |
| 95 | Public Property type As String |
| 96 | Public Property properties As Dictionary(Of [Property]) |
| 97 | Public Property required As String() |
| 98 | End Class |
| 99 | |
| 100 | Public Class [Property] : Inherits SchemaProvider |
| 101 | Implements INamedValue |
| 102 | |
| 103 | Public Property name As String Implements INamedValue.Key |
| 104 | Public Property minimum As Integer |
| 105 | Public Property exclusiveMinimum As Boolean |
| 106 | Public Property ref As String |
| 107 | |
| 108 | Public Overrides Function ToString() As String |
| 109 | Return Me.GetJson |
| 110 | End Function |
| 111 | End Class |
| 112 | End Namespace |