Skip to content

Commit 662d489

Browse files
Merge pull request #45 from SchemaModule/issue-44
Issue 44 PR
2 parents 259d3ff + 7dee8e8 commit 662d489

9 files changed

+3653
-16
lines changed
Binary file not shown.
Binary file not shown.

Diff for: docs/ConvertTo-SchemaDefinition.md

+3-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ schemaDefinition class or a json string.
1616
## SYNTAX
1717

1818
```
19-
ConvertTo-SchemaDefinition [[-Definition] <Object>] [-AsJson] [<CommonParameters>]
19+
ConvertTo-SchemaDefinition [[-Definition] <Object>] [-AsJson] [<CommonParameters>]
2020
```
2121

2222
## DESCRIPTION
@@ -43,7 +43,6 @@ required :
4343
This example shows how to use the function to convert an object into a schema
4444
class.
4545

46-
4746
## PARAMETERS
4847

4948
### -AsJson
@@ -94,10 +93,10 @@ Type: System.Object
9493
Parameter Sets: (All)
9594
Aliases:
9695

97-
Required: True
96+
Required: False
9897
Position: 0
9998
Default value: None
100-
Accept pipeline input: False
99+
Accept pipeline input: True (ByValue)
101100
Accept wildcard characters: False
102101
```
103102

Diff for: docs/Get-SchemaDocument.md

+17-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ This function will return a schemaDocument object of the input Schema.
1414
## SYNTAX
1515

1616
```
17-
Get-SchemaDocument [[-Path] <String>] [<CommonParameters>]
17+
Get-SchemaDocument [[-Path] <String>] [-Headers <Hashtable>] [<CommonParameters>]
1818
```
1919

2020
## DESCRIPTION
@@ -63,6 +63,22 @@ This example passes a json schema file into the function.
6363

6464
## PARAMETERS
6565

66+
### -Headers
67+
68+
This should be a hashtable of key/value pairs that the server is expecting.
69+
70+
```yaml
71+
Type: System.Collections.Hashtable
72+
Parameter Sets: (All)
73+
Aliases:
74+
75+
Required: False
76+
Position: Named
77+
Default value: None
78+
Accept pipeline input: False
79+
Accept wildcard characters: False
80+
```
81+
6682
### -Path
6783
6884
This can be a filepath or URL, the function does light validation on the input.

Diff for: docs/New-SchemaBoolean.md

-2
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,9 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
165165
## INPUTS
166166
167167
### None
168-
169168
## OUTPUTS
170169
171170
### schemaBoolean
172-
173171
## NOTES
174172
175173
## RELATED LINKS

Diff for: schema/about_Schema_Classes.help.txt

+167
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
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+
SCHEMADEFINITION
64+
Sometimes we have small subschemas that are only intended for use in the
65+
current schema and it doesn't make sense to define them as separate schemas.
66+
Schema Definition
67+
Schema Types
68+
69+
SCHEMAARRAY
70+
Arrays are used for ordered elements. In JSON, each element in an array may
71+
be of a different type.
72+
Schema Array
73+
Schema Types
74+
75+
EXAMPLES
76+
String = New-SchemaElement -Type string
77+
78+
$String |Get-Member
79+
80+
81+
TypeName: schemaString
82+
83+
Name MemberType Definition
84+
---- ---------- ----------
85+
AddEnum Method void AddEnum(string enum)
86+
AddExample Method void AddExample(string example)
87+
Equals Method bool Equals(System.Object obj)
88+
GetHashCode Method int GetHashCode()
89+
GetType Method type GetType()
90+
ToString Method System.Object ToString()
91+
default Property string default {get;set;}
92+
description Property string description {get;set;}
93+
enum Property string[] enum {get;set;}
94+
examples Property string[] examples {get;set;}
95+
id Property string id {get;set;}
96+
maxLength Property int maxLength {get;set;}
97+
minLength Property int minLength {get;set;}
98+
pattern Property string pattern {get;set;}
99+
ref Property string ref {get;set;}
100+
title Property string title {get;set;}
101+
type Property string type {get;set;}
102+
103+
104+
$String.AddEnum(@('cat','dog'))
105+
106+
$String |ConvertTo-Json
107+
{
108+
"type": "string",
109+
"examples": [
110+
111+
],
112+
"id": null,
113+
"ref": null,
114+
"minLength": 0,
115+
"maxLength": 0,
116+
"pattern": null,
117+
"enum": [
118+
"cat dog"
119+
],
120+
"title": null,
121+
"description": null,
122+
"default": null
123+
}
124+
#
125+
126+
This example shows how to create an object and access one of the methods
127+
128+
$Schema = Get-SchemaDocument -Path 'D:\TEMP\test\schema-sample.json'
129+
$Schema |Get-Member
130+
131+
132+
TypeName: schemaDocument
133+
134+
Name MemberType Definition
135+
---- ---------- ----------
136+
AddProperty Method System.Object AddProperty(System.Object property)
137+
Equals Method bool Equals(System.Object obj)
138+
Find Method System.Object Find(string item)
139+
GetHashCode Method int GetHashCode()
140+
GetProperty Method System.Object GetProperty(string PropertyName)
141+
GetType Method type GetType()
142+
ToObject Method System.Object ToObject(), System.Object ToObject(int Depth), System.Object ToObject(string PropertyName), System.Object ToObject(string PropertyName, int Depth)
143+
ToString Method System.Object ToString()
144+
additionalProperties Property bool additionalProperties {get;set;}
145+
default Property System.Object default {get;set;}
146+
definitions Property System.Object definitions {get;set;}
147+
description Property string description {get;set;}
148+
id Property string id {get;set;}
149+
properties Property System.Object properties {get;set;}
150+
required Property string[] required {get;set;}
151+
schema Property string schema {get;set;}
152+
title Property string title {get;set;}
153+
type Property string type {get;set;}
154+
155+
156+
$Schema.Find('printers')
157+
158+
$id title description default items
159+
--- ----- ----------- ------- -----
160+
#/properties/contents/items/anyOf/0/properties/printers The printers schema An explanation about the purpose of this instance. {} @{anyOf=System.Object[]}
161+
162+
This is another example of using methods within a created object
163+
164+
SEE ALSO
165+
Project Site
166+
Github Repo
167+

0 commit comments

Comments
 (0)