Skip to content

Commit 95d47f9

Browse files
Merge pull request #32 from SchemaModule/item-34
Item 34 : New Release with more features
2 parents 360932b + dccb9c2 commit 95d47f9

27 files changed

+6387
-526
lines changed

cabs/schema_b75e69d4-47bc-4ac6-b7d7-df9a36e08bbe_HelpInfo.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<SupportedUICultures>
55
<UICulture>
66
<UICultureName>en-US</UICultureName>
7-
<UICultureVersion>1.1.0</UICultureVersion>
7+
<UICultureVersion>2.0.0</UICultureVersion>
88
</UICulture>
99
</SupportedUICultures>
1010
</HelpInfo>
Binary file not shown.
Binary file not shown.

docs/ConvertFrom-SchemaArray.md

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
---
2+
external help file: schema-help.xml
3+
Module Name: schema
4+
online version: https://github.com/SchemaModule/PowerShell/blob/master/docs/ConvertFrom-SchemaArray.md#convertfrom-schemaarray
5+
schema: 2.0.0
6+
---
7+
8+
# ConvertFrom-SchemaArray
9+
10+
## SYNOPSIS
11+
12+
This function takes the schemaArray object and converts it into a PowerShell array
13+
that can be nicely output as a JSON string.
14+
15+
## SYNTAX
16+
17+
```
18+
ConvertFrom-SchemaArray [-Array] <Object> [[-Depth] <Int32>] [<CommonParameters>]
19+
```
20+
21+
## DESCRIPTION
22+
23+
This function takes the schemaArray object and converts it into a PowerShell array
24+
that can be nicely output as a JSON string. This function is useful when you need
25+
to output the JSON schema as a JSON object. This would have the effect of
26+
creating an empty JSON document based on the schema that was provided.
27+
28+
## EXAMPLES
29+
30+
### Example 1
31+
32+
```powershell
33+
PS C:\> $Schema = Get-SchemaDocument -Path 'D:\TEMP\test\schema-sample.json'
34+
35+
ConvertFrom-SchemaArray -Array $Schema.Find('printers')
36+
37+
brand capability model type
38+
----- ---------- ----- ----
39+
```
40+
41+
Take an object defined in a JSON schema and convert it into a custom PowerShell
42+
object.
43+
44+
## PARAMETERS
45+
46+
### -Array
47+
48+
This is a JSON Schema Array as defined by the json-schema.org (see related links
49+
below). This array is then converted into a PowerShell object that can be used
50+
like any other PowerShell object.
51+
52+
{
53+
"type": "array",
54+
"additionalItems": true,
55+
"id": "#/properties/contents/items/anyOf/0/properties/printers",
56+
"items": {
57+
"anyOf": [{
58+
"type": "object",
59+
"additionalProperties": true,
60+
"id": "#/properties/contents/items/anyOf/0/properties/printers/items/anyOf/0",
61+
"properties": "System.Collections.Hashtable",
62+
"required": "type capability brand model",
63+
"title": "The first anyOf schema",
64+
"description": "An explanation about the purpose of this instance.",
65+
"default": "",
66+
"enum": null
67+
}]
68+
},
69+
"title": "The printers schema",
70+
"description": "An explanation about the purpose of this instance.",
71+
"default": [
72+
]
73+
}
74+
75+
```yaml
76+
Type: System.Object
77+
Parameter Sets: (All)
78+
Aliases:
79+
80+
Required: True
81+
Position: 0
82+
Default value: None
83+
Accept pipeline input: False
84+
Accept wildcard characters: False
85+
```
86+
87+
### -Depth
88+
89+
The Depth parameter defines the number of levers that are recursed in order to
90+
create the object.
91+
92+
```yaml
93+
Type: System.Int32
94+
Parameter Sets: (All)
95+
Aliases:
96+
97+
Required: False
98+
Position: 1
99+
Default value: None
100+
Accept pipeline input: False
101+
Accept wildcard characters: False
102+
```
103+
104+
### CommonParameters
105+
106+
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
107+
108+
## INPUTS
109+
110+
### None
111+
112+
## OUTPUTS
113+
114+
### System.Object[]
115+
116+
## NOTES
117+
118+
## RELATED LINKS
119+
120+
[ConvertFrom-SchemaObject](https://github.com/SchemaModule/PowerShell/blob/master/docs/ConvertFrom-SchemaObject.md#convertfrom-schemaobject)
121+
122+
[About Classes](https://github.com/SchemaModule/PowerShell/blob/master/docs/about_Schema_Classes.md)
123+
124+
[JSON Schema Array](https://json-schema.org/understanding-json-schema/reference/array.html)

docs/ConvertFrom-SchemaObject.md

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
---
2+
external help file: schema-help.xml
3+
Module Name: schema
4+
online version: https://github.com/SchemaModule/PowerShell/blob/master/docs/ConvertFrom-SchemaObject.md#convertfrom-schemaobject
5+
schema: 2.0.0
6+
---
7+
8+
# ConvertFrom-SchemaObject
9+
10+
## SYNOPSIS
11+
12+
This function takes the schemaObject object and converts it into a PowerShell object
13+
that can be nicely output as a JSON string.
14+
15+
## SYNTAX
16+
17+
```
18+
ConvertFrom-SchemaObject [-Object] <Object> [[-Depth] <Int32>] [<CommonParameters>]
19+
```
20+
21+
## DESCRIPTION
22+
23+
This function takes the schemaObject object and converts it into a PowerShell object
24+
that can be nicely output as a JSON string. This function is useful when you need
25+
to output the JSON schema as a JSON object. This would have the effect of
26+
creating an empty JSON document based on the schema that was provided.
27+
28+
## EXAMPLES
29+
30+
### Example 1
31+
32+
```powershell
33+
PS C:\> $Schema = Get-SchemaDocument -Path 'D:\TEMP\test\schema-sample.json'
34+
35+
ConvertFrom-SchemaObject -Object $Schema
36+
37+
38+
$schema : http://json-schema.org/draft-07/schema#
39+
$id : http://example.com/example.json
40+
width :
41+
depth :
42+
closet : False
43+
room :
44+
contents : {System.Object}
45+
exterioraccess : False
46+
```
47+
48+
Take an object defined in a JSON schema and convert it into a custom PowerShell
49+
object.
50+
51+
## PARAMETERS
52+
53+
### -Depth
54+
55+
The Depth parameter defines the number of levers that are recursed in order to
56+
create the object.
57+
58+
```yaml
59+
Type: System.Int32
60+
Parameter Sets: (All)
61+
Aliases:
62+
63+
Required: False
64+
Position: 1
65+
Default value: None
66+
Accept pipeline input: False
67+
Accept wildcard characters: False
68+
```
69+
70+
### -Object
71+
72+
This is a JSON Schema object as defined by the json-schema.org (see related links
73+
below). This object is then converted into a PowerShell object that can be used
74+
like any other PowerShell object.
75+
76+
{
77+
"type": "object",
78+
"schema": "<http://json-schema.org/draft-07/schema>#",
79+
"additionalProperties": true,
80+
"definitions": null,
81+
"id": "http://example.com/example.json",
82+
"properties": {
83+
"width": "schemaString",
84+
"depth": "schemaString",
85+
"closet": "schemaBoolean",
86+
"room": "schemaString",
87+
"contents": "schemaArray",
88+
"exterioraccess": "schemaBoolean"
89+
},
90+
"required": [
91+
"room",
92+
"width",
93+
"depth",
94+
"closet",
95+
"exterioraccess",
96+
"contents"
97+
],
98+
"title": "The root schema",
99+
"description": "The root schema comprises the entire JSON document.",
100+
"default": {
101+
102+
}
103+
}
104+
105+
```yaml
106+
Type: System.Object
107+
Parameter Sets: (All)
108+
Aliases:
109+
110+
Required: True
111+
Position: 0
112+
Default value: None
113+
Accept pipeline input: False
114+
Accept wildcard characters: False
115+
```
116+
117+
### CommonParameters
118+
119+
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
120+
121+
## INPUTS
122+
123+
### None
124+
125+
## OUTPUTS
126+
127+
### System.Object
128+
129+
## NOTES
130+
131+
## RELATED LINKS
132+
133+
[ConvertFrom-SchemaArray](https://github.com/SchemaModule/PowerShell/blob/master/docs/ConvertFrom-SchemaArray.md#convertfrom-schemaarray)
134+
135+
[About Classes](https://github.com/SchemaModule/PowerShell/blob/master/docs/about_Schema_Classes.md)
136+
137+
[JSON Schema Object](https://json-schema.org/understanding-json-schema/reference/object.html)

0 commit comments

Comments
 (0)