Skip to content

Commit 30aa4b9

Browse files
Added external help
1 parent 72b435d commit 30aa4b9

File tree

2 files changed

+3149
-0
lines changed

2 files changed

+3149
-0
lines changed

schema/about_Schema_Classes.help.txt

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
TOPIC
2+
about_schema_classes
3+
4+
SHORT DESCRIPTION
5+
This module uses several custom classes in order to provide flexibility and
6+
functionality to the module and experience as a whole.
7+
8+
LONG DESCRIPTION
9+
This module uses several custom classes in order to provide flexibility and
10+
functionality to the module and experience as a whole. The SchemaModule
11+
classes are derived from the JSON Schema reference pages for draft 7.0. They
12+
contain all the attributes for each object as well as some support methods
13+
to make working with the objects easier.
14+
As they are PowerShell Custom Types, they can't be used directly within
15+
PowerShell. In order to take advantage of these types in your own scripts
16+
you may need to add a "using" statement, or leverage the New-SchemaElement
17+
function to instantiate the objects in the PowerShell console.
18+
19+
Classes
20+
The SchemaModule classes are derived from the JSON Schema reference pages
21+
for draft 7.0. They contain all the attributes for each object as well as
22+
some support methods to make working with the objects easier.
23+
24+
SCHEMADOCUMENT
25+
This class is really modified object that contains the $schema attribute as
26+
well as validation on what values can be present for that attribute.
27+
Schema Object
28+
Schema Keyword
29+
Schema Types
30+
31+
SCHEMASTRING
32+
The string type is used for strings of text. It may contain Unicode
33+
characters.
34+
Schema String
35+
Schema Types
36+
37+
SCHEMAINTEGER
38+
The integer type is used for integral numbers. In PowerShell this is an
39+
int32
40+
Schema Integer
41+
Schema Types
42+
43+
SCHEMANUMBER
44+
The number type is used for any numeric type, either integers or floating
45+
point numbers. In PowerShell this is a double.
46+
Schema Number
47+
Schema Types
48+
49+
SCHEMABOOLEAN
50+
The boolean type matches only two special values: true and false. Note that
51+
values that evaluate to true or false, such as 1 and 0, are not accepted by
52+
the schema.
53+
Schema Boolean
54+
Schema Types
55+
56+
SCHEMAOBJECT
57+
Objects are the mapping type in JSON. They map "keys" to "values". In JSON,
58+
the "keys" must always be strings. Each of these pairs is conventionally
59+
referred to as a "property".
60+
Schema Object
61+
Schema Types
62+
63+
SCHEMAARRAY
64+
Arrays are used for ordered elements. In JSON, each element in an array may
65+
be of a different type.
66+
Schema Array
67+
Schema Types
68+
69+
EXAMPLES
70+
String = New-SchemaElement -Type string
71+
72+
$String |Get-Member
73+
74+
75+
TypeName: schemaString
76+
77+
Name MemberType Definition
78+
---- ---------- ----------
79+
AddEnum Method void AddEnum(string enum)
80+
AddExample Method void AddExample(string example)
81+
Equals Method bool Equals(System.Object obj)
82+
GetHashCode Method int GetHashCode()
83+
GetType Method type GetType()
84+
ToString Method System.Object ToString()
85+
default Property string default {get;set;}
86+
description Property string description {get;set;}
87+
enum Property string[] enum {get;set;}
88+
examples Property string[] examples {get;set;}
89+
id Property string id {get;set;}
90+
maxLength Property int maxLength {get;set;}
91+
minLength Property int minLength {get;set;}
92+
pattern Property string pattern {get;set;}
93+
ref Property string ref {get;set;}
94+
title Property string title {get;set;}
95+
type Property string type {get;set;}
96+
97+
98+
$String.AddEnum(@('cat','dog'))
99+
100+
$String |ConvertTo-Json
101+
{
102+
"type": "string",
103+
"examples": [
104+
105+
],
106+
"id": null,
107+
"ref": null,
108+
"minLength": 0,
109+
"maxLength": 0,
110+
"pattern": null,
111+
"enum": [
112+
"cat dog"
113+
],
114+
"title": null,
115+
"description": null,
116+
"default": null
117+
}
118+
#
119+
120+
This example shows how to create an object and access one of the methods
121+
122+
$Schema = Get-SchemaDocument -Path 'D:\TEMP\test\schema-sample.json'
123+
$Schema |Get-Member
124+
125+
126+
TypeName: schemaDocument
127+
128+
Name MemberType Definition
129+
---- ---------- ----------
130+
AddProperty Method System.Object AddProperty(System.Object property)
131+
Equals Method bool Equals(System.Object obj)
132+
Find Method System.Object Find(string item)
133+
GetHashCode Method int GetHashCode()
134+
GetProperty Method System.Object GetProperty(string PropertyName)
135+
GetType Method type GetType()
136+
ToObject Method System.Object ToObject(), System.Object ToObject(int Depth), System.Object ToObject(string PropertyName), System.Object ToObject(string PropertyName, int Depth)
137+
ToString Method System.Object ToString()
138+
additionalProperties Property bool additionalProperties {get;set;}
139+
default Property System.Object default {get;set;}
140+
definitions Property System.Object definitions {get;set;}
141+
description Property string description {get;set;}
142+
id Property string id {get;set;}
143+
properties Property System.Object properties {get;set;}
144+
required Property string[] required {get;set;}
145+
schema Property string schema {get;set;}
146+
title Property string title {get;set;}
147+
type Property string type {get;set;}
148+
149+
150+
$Schema.Find('printers')
151+
152+
$id title description default items
153+
--- ----- ----------- ------- -----
154+
#/properties/contents/items/anyOf/0/properties/printers The printers schema An explanation about the purpose of this instance. {} @{anyOf=System.Object[]}
155+
156+
This is another example of using methods within a created object
157+
158+
SEE ALSO
159+
Project Site
160+
Github Repo
161+

0 commit comments

Comments
 (0)