Skip to content

Version 3.0.0 Release #42

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 27 commits into from
Nov 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
82da0ce
UserStory-51 : Added a switch to ConvertTo-Element to force a SchemaD…
jeffpatton1971 Nov 18, 2021
5109463
UserStory-51 : If type arrives as an array take the first item in the…
jeffpatton1971 Nov 18, 2021
87f9cbb
UserStory-51 : Added a global variable for RawSchema, to potentially …
jeffpatton1971 Nov 18, 2021
7623160
UserStory-51 : Changed reference param in Get-Definition to string, t…
jeffpatton1971 Nov 18, 2021
9313260
bug-55 : Removed the validators for New-Property which lets us move a…
jeffpatton1971 Nov 19, 2021
f59e222
UserStory-51 : Added logic to the array discovery to properly follow …
jeffpatton1971 Nov 19, 2021
cd77840
Bug-56 : Assign the newly created object required array to be the pas…
jeffpatton1971 Nov 19, 2021
e70e2b7
Task-58 : Extended the class with a new find method that include a bo…
jeffpatton1971 Nov 19, 2021
535c8d2
Task-59 : Added ConvertTo-Definition to the psd1
jeffpatton1971 Nov 20, 2021
87f94fb
Task-59 : Updated module with ConvertTo-Definition as well as add log…
jeffpatton1971 Nov 20, 2021
12c9895
Feature-44 : Added ToObject in the schemaArray class
jeffpatton1971 Nov 21, 2021
bb0656d
Bug-60 : Added some logic around how treat Uri/path/named references …
jeffpatton1971 Nov 22, 2021
82698a6
Bug-60 : Missed handling a named reference inside the array function
jeffpatton1971 Nov 22, 2021
1f8cb63
Bug-61 : ConvertFromArray was not working after we removed "invalid a…
jeffpatton1971 Nov 22, 2021
e563d36
Bug-62 : Catch if anyOf/allOf/oneOf/ are being used
jeffpatton1971 Nov 22, 2021
9b00879
Bug-62 : Corrected an issue where once again assumed a specific forma…
jeffpatton1971 Nov 24, 2021
ad2719d
Task-57 : Updating documentatoin to reflect recent changes to module
jeffpatton1971 Nov 24, 2021
f09f500
Task-57 : Adding New function ConvertTo-Definition
jeffpatton1971 Nov 24, 2021
d57b8df
Task-56 : Added missing help for new function
jeffpatton1971 Nov 24, 2021
278dfad
Task-56 : Updated help with new -IsRoot switch
jeffpatton1971 Nov 24, 2021
1cf0b19
Task-56 : Updated external help
jeffpatton1971 Nov 24, 2021
d348698
Task-56 : Uncommented the output type for function
jeffpatton1971 Nov 24, 2021
55b9787
Task-57 : Updated external help
jeffpatton1971 Nov 24, 2021
8e5c47a
Task-57 : Updated README
jeffpatton1971 Nov 24, 2021
792ffff
Task-57 : Updated CHANGELOG
jeffpatton1971 Nov 24, 2021
9898e86
Task-57 : Updated module version to new version number
jeffpatton1971 Nov 24, 2021
259d3ff
Merge pull request #41 from SchemaModule/epic-54
jeffpatton1971 Nov 24, 2021
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
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Unreleased

- Move code out of functions into classes
- Better Error handling support

## [3.0.0] - 2021-11-24

### Added
- Added support for processing definitions
- Added schemaDefinition Class
- Added type support for Definitions
- Added ConvertTo-SchemaDefinition function
- Added ToObject support for Arrays
- Added Global:RawSchema variable to view incoming schema before processing

### Updated

- Find-SchemaElement handles arrays and definitions
- ConvertTo-SchemaElement can now work with definitions properly
- Get-SchemaDefinition has better support for actual definitions

## [2.0.0] - 2020-12-22

Expand Down
Binary file modified README.md
Binary file not shown.
Binary file not shown.
Binary file not shown.
3 changes: 0 additions & 3 deletions docs/ConvertFrom-SchemaArray.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,14 @@ 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
Expand Down
3 changes: 0 additions & 3 deletions docs/ConvertFrom-SchemaObject.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,14 @@ 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
Expand Down
125 changes: 125 additions & 0 deletions docs/ConvertTo-SchemaDefinition.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
---
external help file: schema-help.xml
Module Name: schema
online version: https://github.com/SchemaModule/PowerShell/blob/master/docs/ConvertTo-SchemaDefinition.md#convertto-schemadefinition
schema: 2.0.0
---

# ConvertTo-SchemaDefinition

## SYNOPSIS

This function takes an object that has the format of a Schema Definition and
converts it into the schemaDefinition class. It can also return as either the
schemaDefinition class or a json string.

## SYNTAX

```
ConvertTo-SchemaDefinition [[-Definition] <Object>] [-AsJson] [<CommonParameters>]
```

## DESCRIPTION

This function takes an object that has the format of a Schema Definition and
converts it into the schemaDefinition class. It can also return as either the
schemaDefinition class or a json string.

## EXAMPLES

### Example 1

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

ConvertTo-SchemaDefinition -Definition $Schema.definitions.room


type : object
properties : @{Id=; Title;Description=}
required :
```

This example shows how to use the function to convert an object into a schema
class.


## PARAMETERS

### -AsJson

Allows the funciton to return a string in JSON format.

```yaml
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:

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

### -Definition

This is a JSON Schema definition 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"
],
"properties": {
"Id": {
"type": "string"
},
"Regions": {
"type": "array",
"items": {
"$ref": "#/definitions/Region"
}
}
},
"required": [
"Id",
"Regions"
]
}

```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

### schemaDefinition
This class is really modified object that contains the $schema attribute as well as validation on what values can be present for that attribute. Schema Definition (https://json-schema.org/understanding-json-schema/structuring.html#defs) Schema Keyword (https://json-schema.org/understanding-json-schema/reference/schema.html) Schema Types (https://json-schema.org/understanding-json-schema/reference/type.html)

## NOTES

## RELATED LINKS

[Get-SchemaDocument](https://github.com/SchemaModule/PowerShell/blob/master/docs/Get-SchemaDocument.md#get-schemadocument)

[New-SchemaProperty](https://github.com/SchemaModule/PowerShell/blob/master/docs/New-SchemaProperty.md#new-schemaproperty)

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

[JSON Schema Reference](https://json-schema.org/understanding-json-schema/reference/index.html)
79 changes: 25 additions & 54 deletions docs/ConvertTo-SchemaElement.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ SchemaModule classes.
## SYNTAX

```
ConvertTo-SchemaElement [-Object] <Object> [<CommonParameters>]
ConvertTo-SchemaElement [-Object] <Object> [-IsRootSchema] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -71,6 +71,23 @@ Format-List CmdLet.

## PARAMETERS

### -IsRootSchema

This switch allows the function to know when it's working with the root of a
schema document versus a regular object.

```yaml
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
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
Expand Down Expand Up @@ -106,79 +123,33 @@ 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

### schemaDocument

This class is really modified object that contains the $schema attribute as well
as validation on what values can be present for that attribute.

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

[Schema Keyword](https://json-schema.org/understanding-json-schema/reference/schema.html)

[Schema Types](https://json-schema.org/understanding-json-schema/reference/type.html)
This class is really modified object that contains the $schema attribute as well as validation on what values can be present for that attribute. Schema Object (https://json-schema.org/understanding-json-schema/reference/object.html) Schema Keyword (https://json-schema.org/understanding-json-schema/reference/schema.html) Schema Types (https://json-schema.org/understanding-json-schema/reference/type.html)

### schemaString

The string type is used for strings of text. It may contain Unicode characters.

[Schema String](https://json-schema.org/understanding-json-schema/reference/string.html)

[Schema Types](https://json-schema.org/understanding-json-schema/reference/type.html)
The string type is used for strings of text. It may contain Unicode characters. Schema String (https://json-schema.org/understanding-json-schema/reference/string.html) Schema Types (https://json-schema.org/understanding-json-schema/reference/type.html)

### schemaInteger

The integer type is used for integral numbers. In PowerShell this is an int32

[Schema Integer](http://json-schema.org/understanding-json-schema/reference/numeric.html#integer)

[Schema Types](https://json-schema.org/understanding-json-schema/reference/type.html)
The integer type is used for integral numbers. In PowerShell this is an int32 Schema Integer (http://json-schema.org/understanding-json-schema/reference/numeric.html#integer) Schema Types (https://json-schema.org/understanding-json-schema/reference/type.html)

### schemaNumber

The number type is used for any numeric type, either integers or floating point
numbers. In PowerShell this is a double.

[Schema Number](http://json-schema.org/understanding-json-schema/reference/numeric.html#number)

[Schema Types](https://json-schema.org/understanding-json-schema/reference/type.html)
The number type is used for any numeric type, either integers or floating point numbers. In PowerShell this is a double. Schema Number (http://json-schema.org/understanding-json-schema/reference/numeric.html#number) Schema Types (https://json-schema.org/understanding-json-schema/reference/type.html)

### schemaBoolean

The boolean type matches only two special values: true and false. Note that
values that evaluate to true or false, such as 1 and 0, are not accepted by the
schema.

[Schema Boolean](http://json-schema.org/understanding-json-schema/reference/boolean.html)

[Schema Types](https://json-schema.org/understanding-json-schema/reference/type.html)
The boolean type matches only two special values: true and false. Note that values that evaluate to true or false, such as 1 and 0, are not accepted by the schema. Schema Boolean (http://json-schema.org/understanding-json-schema/reference/boolean.html) Schema Types (https://json-schema.org/understanding-json-schema/reference/type.html)

### schemaObject

Objects are the mapping type in JSON. They map "keys" to "values". In JSON, the
"keys" must always be strings. Each of these pairs is conventionally referred
to as a "property".

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

[Schema Types](https://json-schema.org/understanding-json-schema/reference/type.html)
Objects are the mapping type in JSON. They map "keys" to "values". In JSON, the "keys" must always be strings. Each of these pairs is conventionally referred to as a "property". Schema Object (https://json-schema.org/understanding-json-schema/reference/object.html) Schema Types (https://json-schema.org/understanding-json-schema/reference/type.html)

### schemaArray

Arrays are used for ordered elements. In JSON, each element in an array may be
of a different type.

[Schema Array](https://json-schema.org/understanding-json-schema/reference/array.html)

[Schema Types](https://json-schema.org/understanding-json-schema/reference/type.html)
Arrays are used for ordered elements. In JSON, each element in an array may be of a different type. Schema Array (https://json-schema.org/understanding-json-schema/reference/array.html) Schema Types (https://json-schema.org/understanding-json-schema/reference/type.html)

## NOTES

Expand Down
Loading