Skip to content

Version 2.0 Release #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 115 commits into from
Dec 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
ee928c4
Added the code to test for byte arrays
jeffpatton1971 Nov 25, 2020
7d5ea6f
Merge pull request #31 from SchemaModule/issue-30
jeffpatton1971 Nov 25, 2020
360932b
BUGFIX : Missed adding the return in the file switch
jeffpatton1971 Nov 25, 2020
3fd215a
item-34 : Signifcant changes across the board, please review document…
jeffpatton1971 Nov 30, 2020
b6712d3
Additional class and functions
jeffpatton1971 Dec 1, 2020
fb998d7
Updates to get-element to get around attempting to create an $id object
jeffpatton1971 Dec 1, 2020
7e99336
added boolean class
jeffpatton1971 Dec 1, 2020
e8bddf6
added boolean to new/get
jeffpatton1971 Dec 1, 2020
b1f23a6
fleshing out the functions with all objects
jeffpatton1971 Dec 1, 2020
f009cd0
Updated toJson method to swap out powershell propertynames to schema …
jeffpatton1971 Dec 1, 2020
4f59525
account for $schema as a special document type
jeffpatton1971 Dec 1, 2020
e1ca437
Added some functions
jeffpatton1971 Dec 1, 2020
d86b94c
Added the ability to find a given object by name
jeffpatton1971 Dec 1, 2020
f076f6d
Adding find() to object and array classes
jeffpatton1971 Dec 2, 2020
8dad391
renamed function to bring it in line with everything else
jeffpatton1971 Dec 2, 2020
08e09f8
Shuffled classes and functions around
jeffpatton1971 Dec 2, 2020
ff87fd7
added definitions to document class
jeffpatton1971 Dec 2, 2020
42a3f6c
Major update to find-element, now supports name, type and path
jeffpatton1971 Dec 2, 2020
e83f2e9
update to find-element to bring it inline with the other parameters, …
jeffpatton1971 Dec 2, 2020
c7607a1
Update classes with more appropriate naming
jeffpatton1971 Dec 3, 2020
47a5fb8
Working on a new-object function
jeffpatton1971 Dec 3, 2020
f74986c
Find-Element had a typo in the parameter name, and missed updates whe…
jeffpatton1971 Dec 3, 2020
323b0fe
Missed both calls to find-element
jeffpatton1971 Dec 3, 2020
0cdd6be
Didn't update parmeter name inside function
jeffpatton1971 Dec 3, 2020
4f4e4c3
Think I've found them all now
jeffpatton1971 Dec 3, 2020
b1712ec
Removed functions no longer required, updated get-document to use get…
jeffpatton1971 Dec 3, 2020
8e3fed7
re-wrote get-element as convertto-element and cleaned things up
jeffpatton1971 Dec 4, 2020
ed7a9ef
updated code with new convertto-element function, deprecating existin…
jeffpatton1971 Dec 4, 2020
5ca92c8
Updated referecnes to get-element and removed get-element function
jeffpatton1971 Dec 4, 2020
a0aea6f
testing for extraneous id properties
jeffpatton1971 Dec 4, 2020
2820a49
updating the get-document function
jeffpatton1971 Dec 7, 2020
778ba3b
Added toString() overrides and modified format-json function to modif…
jeffpatton1971 Dec 7, 2020
62b3199
Adding some custom formatting
jeffpatton1971 Dec 7, 2020
a165909
Adding customTypes
jeffpatton1971 Dec 7, 2020
fac530d
missed opening quote on value
jeffpatton1971 Dec 7, 2020
cf893c5
will have to check for nulls sooner, skipping them here creates inval…
jeffpatton1971 Dec 7, 2020
47d109e
Added object output for schemaDocument class
jeffpatton1971 Dec 11, 2020
04e360d
Added toobject for schemaObject
jeffpatton1971 Dec 11, 2020
2ee967f
Added toArray to schemaArray
jeffpatton1971 Dec 11, 2020
38684cf
added getproperty to schemaObject with propertyname constructor
jeffpatton1971 Dec 11, 2020
3a00b0f
updated get-array to work with the new schema objects
jeffpatton1971 Dec 11, 2020
4bff90e
updated get-object and get-array
jeffpatton1971 Dec 11, 2020
30aaf59
removed get-property it's not used anywhere
jeffpatton1971 Dec 11, 2020
aac0932
working on getobject and getarray methods, have working functions wit…
jeffpatton1971 Dec 11, 2020
73c9d7e
updated class methods with function code
jeffpatton1971 Dec 14, 2020
f0762ff
updated schemaDocument class with the same sets of outputs as object
jeffpatton1971 Dec 15, 2020
2d7bec8
added the remaining types
jeffpatton1971 Dec 15, 2020
1c2e646
updated formats
jeffpatton1971 Dec 15, 2020
496002f
Added types and formats, will need to get this into psake as well
jeffpatton1971 Dec 15, 2020
58e434a
removing two functions that are no longer required
jeffpatton1971 Dec 15, 2020
794e05c
Updating module to work with exported function names
jeffpatton1971 Dec 15, 2020
3c1f1bd
Had to remove the new-object function as it was causing issues when e…
jeffpatton1971 Dec 16, 2020
9f0c172
updated functions
jeffpatton1971 Dec 16, 2020
da4099d
This class was not needed
jeffpatton1971 Dec 16, 2020
ee74817
re-organized classes and functions
jeffpatton1971 Dec 16, 2020
11d0013
Removed ToJson() method from all classes, you can just as easily conv…
jeffpatton1971 Dec 16, 2020
38f9224
adding a list format for testing
jeffpatton1971 Dec 16, 2020
2a65f0f
Fixed listitem formatting
jeffpatton1971 Dec 16, 2020
1f62325
Updated all ToString() to return json
jeffpatton1971 Dec 16, 2020
faed373
grouped all the type classes into the same set of views
jeffpatton1971 Dec 16, 2020
3d182cd
added missing definition to format of schemaDocumnet
jeffpatton1971 Dec 16, 2020
19a4a49
Renamed the ToObject method
jeffpatton1971 Dec 16, 2020
f7ff3f5
Updated the outputtype and removed the force param
jeffpatton1971 Dec 17, 2020
9a8e546
Updated all functions with gethelp and outputtype decorations
jeffpatton1971 Dec 17, 2020
25527a2
Remove-Null no longer required
jeffpatton1971 Dec 17, 2020
5b5da72
Updating markdownhelp with new functions
jeffpatton1971 Dec 17, 2020
2a1a2d1
Cleaning up and clarifying parameter names
jeffpatton1971 Dec 18, 2020
22186d7
Updated help docs after module update
jeffpatton1971 Dec 18, 2020
e48eb04
Typo in type assignment
jeffpatton1971 Dec 18, 2020
36b19ce
Missed the rename of parameternames when I call the functions
jeffpatton1971 Dec 18, 2020
55423bd
Needed to adjust this function as I changed how the arrays were created
jeffpatton1971 Dec 18, 2020
2a24c55
Added a test on convertfrom-array to check the array type
jeffpatton1971 Dec 18, 2020
ac4c9a6
Added similar test to convertfrom-object
jeffpatton1971 Dec 18, 2020
cce954e
Moved the test for schema and id outside of the loop, was in the wron…
jeffpatton1971 Dec 18, 2020
b156f5a
Missed the rename on this method
jeffpatton1971 Dec 18, 2020
ebafae4
updating function as I write help to make things line up
jeffpatton1971 Dec 18, 2020
91403f3
Added type to Depth param
jeffpatton1971 Dec 18, 2020
b301245
Added synopsis for ConvertFrom-SchemaArray
jeffpatton1971 Dec 18, 2020
4fa326a
Added documentation for ConvertFrom-SchemaArray
jeffpatton1971 Dec 18, 2020
fa86eec
Updated documentation
jeffpatton1971 Dec 18, 2020
a6cb9d6
typo in description
jeffpatton1971 Dec 21, 2020
3685d4c
Defined mandatory parameters
jeffpatton1971 Dec 21, 2020
55abec6
Updated help
jeffpatton1971 Dec 21, 2020
bc00cf6
Updating help
jeffpatton1971 Dec 21, 2020
f56300a
Deleted and re-created the help as everything internally was messed up
jeffpatton1971 Dec 21, 2020
05252ef
updated types for parameters
jeffpatton1971 Dec 21, 2020
bfdd40c
Adding rough draft of about classes help
jeffpatton1971 Dec 21, 2020
6e24e90
Added find-element help
jeffpatton1971 Dec 21, 2020
431f43c
Corrected a typo in the help URL
jeffpatton1971 Dec 21, 2020
e36f7f1
Added format-document help
jeffpatton1971 Dec 21, 2020
ac10e65
Added get-definition help
jeffpatton1971 Dec 21, 2020
3c23615
Updated get-document with proper output type
jeffpatton1971 Dec 21, 2020
a09ff68
Updated get-document
jeffpatton1971 Dec 21, 2020
7deb478
Added get-reference help
jeffpatton1971 Dec 21, 2020
9f046a4
Added new-element help
jeffpatton1971 Dec 21, 2020
6e73739
Added help for the objects
jeffpatton1971 Dec 21, 2020
275e942
Added help for new-property
jeffpatton1971 Dec 21, 2020
7e34e85
ScriptAnalyzer : PSUseOutputTypeCorrectly
jeffpatton1971 Dec 21, 2020
9388d62
ScriptAnalyzer : PSShouldProcess
jeffpatton1971 Dec 22, 2020
8284365
Cleaned up help with markdownlint
jeffpatton1971 Dec 22, 2020
1aaed54
Cleaned up the related links
jeffpatton1971 Dec 22, 2020
661f606
Cleaned up about help
jeffpatton1971 Dec 22, 2020
31f3136
testing formatting
jeffpatton1971 Dec 22, 2020
72c957e
Updated formatting
jeffpatton1971 Dec 22, 2020
0dd2469
updated help to work with platyps
jeffpatton1971 Dec 22, 2020
285fb1d
Updated external help file
jeffpatton1971 Dec 22, 2020
dccb9c2
Created external help file
jeffpatton1971 Dec 22, 2020
95d47f9
Merge pull request #32 from SchemaModule/item-34
jeffpatton1971 Dec 22, 2020
91c5d1e
Added New-Boolean functions
jeffpatton1971 Dec 22, 2020
487089a
Added proper output type
jeffpatton1971 Dec 22, 2020
72b435d
Adding support help
jeffpatton1971 Dec 22, 2020
30aa4b9
Added external help
jeffpatton1971 Dec 22, 2020
5b97c12
Merge pull request #33 from SchemaModule/item-38
jeffpatton1971 Dec 22, 2020
5c04a75
Updating help and changelog for version 2
jeffpatton1971 Dec 22, 2020
39dbcb1
Updating readme
jeffpatton1971 Dec 22, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,76 @@
# Changelog

All changes to this module should be reflected in this document.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased

- Move code out of functions into classes

## [2.0.0] - 2020-12-22

### Added

- Added classes to define JSON schema objects
- Added utility methods to classes
- Added Functions to support the classes
- New-SchemaElement
- New-SchemaString
- New-SchemaInteger
- New-SchemaNumber
- New-SchemaProperty
- New-SchemaBoolean
- Get-SchemaDefinition
- Get-SchemaReference
- Find-SchemaElement
- ConvertTo-SchemaElement
- ConvertFrom-SchemaObject
- ConvertFrom-SchemaArray
- Format-SchemaDocument
- Added support for types (schema.types.ps1xml)
- Added support for formatting (schema.format.ps1xml)

### Updated

- Get-SchemaDocument has been udpated to work with the new functions

### Removed

- Get-SchemaArray
- Get-SchemaObject
- Get-SchemaProperty

## [1.1.0] - 2020-09-11

### Added

- Updatable Help Support

## [1.0.0] - 2020-09-09

### Added

- Updated documentation and external help
- CHNAGELOG added
- psakefile added
- Added JSON logo

### Changed

- README
- Definition File updated with URLs and new version

### Fixed

- Missing some JSON data types, bool and int
- Write-Verbose acts different for arrays, so corrected the output

## [0.0.1] - 2020-09-08

### Added

- Repository Created
- Module manifest created
- Module file copied from outside repository
Expand Down
Binary file modified README.md
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<SupportedUICultures>
<UICulture>
<UICultureName>en-US</UICultureName>
<UICultureVersion>1.1.0</UICultureVersion>
<UICultureVersion>2.0.0</UICultureVersion>
</UICulture>
</SupportedUICultures>
</HelpInfo>
Binary file not shown.
Binary file not shown.
124 changes: 124 additions & 0 deletions docs/ConvertFrom-SchemaArray.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
---
external help file: schema-help.xml
Module Name: schema
online version: https://github.com/SchemaModule/PowerShell/blob/master/docs/ConvertFrom-SchemaArray.md#convertfrom-schemaarray
schema: 2.0.0
---

# ConvertFrom-SchemaArray

## SYNOPSIS

This function takes the schemaArray object and converts it into a PowerShell array
that can be nicely output as a JSON string.

## SYNTAX

```
ConvertFrom-SchemaArray [-Array] <Object> [[-Depth] <Int32>] [<CommonParameters>]
```

## DESCRIPTION

This function takes the schemaArray object and converts it into a PowerShell array
that can be nicely output as a JSON string. This function is useful when you need
to output the JSON schema as a JSON object. This would have the effect of
creating an empty JSON document based on the schema that was provided.

## EXAMPLES

### Example 1

```powershell
PS C:\> $Schema = Get-SchemaDocument -Path 'D:\TEMP\test\schema-sample.json'

ConvertFrom-SchemaArray -Array $Schema.Find('printers')

brand capability model type
----- ---------- ----- ----
```

Take an object defined in a JSON schema and convert it into a custom PowerShell
object.

## PARAMETERS

### -Array

This is a JSON Schema Array as defined by the json-schema.org (see related links
below). This array is then converted into a PowerShell object that can be used
like any other PowerShell object.

{
"type": "array",
"additionalItems": true,
"id": "#/properties/contents/items/anyOf/0/properties/printers",
"items": {
"anyOf": [{
"type": "object",
"additionalProperties": true,
"id": "#/properties/contents/items/anyOf/0/properties/printers/items/anyOf/0",
"properties": "System.Collections.Hashtable",
"required": "type capability brand model",
"title": "The first anyOf schema",
"description": "An explanation about the purpose of this instance.",
"default": "",
"enum": null
}]
},
"title": "The printers schema",
"description": "An explanation about the purpose of this instance.",
"default": [
]
}

```yaml
Type: System.Object
Parameter Sets: (All)
Aliases:

Required: True
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -Depth

The Depth parameter defines the number of levers that are recursed in order to
create the object.

```yaml
Type: System.Int32
Parameter Sets: (All)
Aliases:

Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### CommonParameters

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).

## INPUTS

### None

## OUTPUTS

### System.Object[]

## NOTES

## RELATED LINKS

[ConvertFrom-SchemaObject](https://github.com/SchemaModule/PowerShell/blob/master/docs/ConvertFrom-SchemaObject.md#convertfrom-schemaobject)

[About Classes](https://github.com/SchemaModule/PowerShell/blob/master/docs/about_Schema_Classes.md)

[JSON Schema Array](https://json-schema.org/understanding-json-schema/reference/array.html)
137 changes: 137 additions & 0 deletions docs/ConvertFrom-SchemaObject.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
---
external help file: schema-help.xml
Module Name: schema
online version: https://github.com/SchemaModule/PowerShell/blob/master/docs/ConvertFrom-SchemaObject.md#convertfrom-schemaobject
schema: 2.0.0
---

# ConvertFrom-SchemaObject

## SYNOPSIS

This function takes the schemaObject object and converts it into a PowerShell object
that can be nicely output as a JSON string.

## SYNTAX

```
ConvertFrom-SchemaObject [-Object] <Object> [[-Depth] <Int32>] [<CommonParameters>]
```

## DESCRIPTION

This function takes the schemaObject object and converts it into a PowerShell object
that can be nicely output as a JSON string. This function is useful when you need
to output the JSON schema as a JSON object. This would have the effect of
creating an empty JSON document based on the schema that was provided.

## EXAMPLES

### Example 1

```powershell
PS C:\> $Schema = Get-SchemaDocument -Path 'D:\TEMP\test\schema-sample.json'

ConvertFrom-SchemaObject -Object $Schema


$schema : http://json-schema.org/draft-07/schema#
$id : http://example.com/example.json
width :
depth :
closet : False
room :
contents : {System.Object}
exterioraccess : False
```

Take an object defined in a JSON schema and convert it into a custom PowerShell
object.

## PARAMETERS

### -Depth

The Depth parameter defines the number of levers that are recursed in order to
create the object.

```yaml
Type: System.Int32
Parameter Sets: (All)
Aliases:

Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -Object

This is a JSON Schema object as defined by the json-schema.org (see related links
below). This object is then converted into a PowerShell object that can be used
like any other PowerShell object.

{
"type": "object",
"schema": "<http://json-schema.org/draft-07/schema>#",
"additionalProperties": true,
"definitions": null,
"id": "http://example.com/example.json",
"properties": {
"width": "schemaString",
"depth": "schemaString",
"closet": "schemaBoolean",
"room": "schemaString",
"contents": "schemaArray",
"exterioraccess": "schemaBoolean"
},
"required": [
"room",
"width",
"depth",
"closet",
"exterioraccess",
"contents"
],
"title": "The root schema",
"description": "The root schema comprises the entire JSON document.",
"default": {

}
}

```yaml
Type: System.Object
Parameter Sets: (All)
Aliases:

Required: True
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### CommonParameters

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).

## INPUTS

### None

## OUTPUTS

### System.Object

## NOTES

## RELATED LINKS

[ConvertFrom-SchemaArray](https://github.com/SchemaModule/PowerShell/blob/master/docs/ConvertFrom-SchemaArray.md#convertfrom-schemaarray)

[About Classes](https://github.com/SchemaModule/PowerShell/blob/master/docs/about_Schema_Classes.md)

[JSON Schema Object](https://json-schema.org/understanding-json-schema/reference/object.html)
Loading