|
| 1 | +--- |
| 2 | +external help file: schema-help.xml |
| 3 | +Module Name: schema |
| 4 | +online version: https://github.com/SchemaModule/PowerShell/blob/master/docs/ConvertTo-SchemaDefinition.md#convertto-schemadefinition |
| 5 | +schema: 2.0.0 |
| 6 | +--- |
| 7 | + |
| 8 | +# ConvertTo-SchemaDefinition |
| 9 | + |
| 10 | +## SYNOPSIS |
| 11 | + |
| 12 | +This function takes an object that has the format of a Schema Definition and |
| 13 | +converts it into the schemaDefinition class. It can also return as either the |
| 14 | +schemaDefinition class or a json string. |
| 15 | + |
| 16 | +## SYNTAX |
| 17 | + |
| 18 | +``` |
| 19 | +ConvertTo-SchemaDefinition [[-Definition] <Object>] [-AsJson] [<CommonParameters>] |
| 20 | +``` |
| 21 | + |
| 22 | +## DESCRIPTION |
| 23 | + |
| 24 | +This function takes an object that has the format of a Schema Definition and |
| 25 | +converts it into the schemaDefinition class. It can also return as either the |
| 26 | +schemaDefinition class or a json string. |
| 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 | +ConvertTo-SchemaDefinition -Definition $Schema.definitions.room |
| 36 | +
|
| 37 | +
|
| 38 | +type : object |
| 39 | +properties : @{Id=; Title;Description=} |
| 40 | +required : |
| 41 | +``` |
| 42 | + |
| 43 | +This example shows how to use the function to convert an object into a schema |
| 44 | +class. |
| 45 | + |
| 46 | + |
| 47 | +## PARAMETERS |
| 48 | + |
| 49 | +### -AsJson |
| 50 | + |
| 51 | +Allows the funciton to return a string in JSON format. |
| 52 | + |
| 53 | +```yaml |
| 54 | +Type: System.Management.Automation.SwitchParameter |
| 55 | +Parameter Sets: (All) |
| 56 | +Aliases: |
| 57 | + |
| 58 | +Required: False |
| 59 | +Position: Named |
| 60 | +Default value: None |
| 61 | +Accept pipeline input: False |
| 62 | +Accept wildcard characters: False |
| 63 | +``` |
| 64 | +
|
| 65 | +### -Definition |
| 66 | +
|
| 67 | +This is a JSON Schema definition as defined by the json-schema.org (see related |
| 68 | +links below). This object is then converted into a PowerShell object that can be |
| 69 | +used like any other PowerShell object. |
| 70 | +
|
| 71 | +{ |
| 72 | + "type": [ |
| 73 | + "object" |
| 74 | + ], |
| 75 | + "properties": { |
| 76 | + "Id": { |
| 77 | + "type": "string" |
| 78 | + }, |
| 79 | + "Regions": { |
| 80 | + "type": "array", |
| 81 | + "items": { |
| 82 | + "$ref": "#/definitions/Region" |
| 83 | + } |
| 84 | + } |
| 85 | + }, |
| 86 | + "required": [ |
| 87 | + "Id", |
| 88 | + "Regions" |
| 89 | + ] |
| 90 | +} |
| 91 | +
|
| 92 | +```yaml |
| 93 | +Type: System.Object |
| 94 | +Parameter Sets: (All) |
| 95 | +Aliases: |
| 96 | + |
| 97 | +Required: True |
| 98 | +Position: 0 |
| 99 | +Default value: None |
| 100 | +Accept pipeline input: False |
| 101 | +Accept wildcard characters: False |
| 102 | +``` |
| 103 | +
|
| 104 | +### CommonParameters |
| 105 | +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). |
| 106 | +
|
| 107 | +## INPUTS |
| 108 | +
|
| 109 | +### None |
| 110 | +## OUTPUTS |
| 111 | +
|
| 112 | +### schemaDefinition |
| 113 | +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) |
| 114 | +
|
| 115 | +## NOTES |
| 116 | +
|
| 117 | +## RELATED LINKS |
| 118 | +
|
| 119 | +[Get-SchemaDocument](https://github.com/SchemaModule/PowerShell/blob/master/docs/Get-SchemaDocument.md#get-schemadocument) |
| 120 | +
|
| 121 | +[New-SchemaProperty](https://github.com/SchemaModule/PowerShell/blob/master/docs/New-SchemaProperty.md#new-schemaproperty) |
| 122 | +
|
| 123 | +[About Classes](https://github.com/SchemaModule/PowerShell/blob/master/docs/about_Schema_Classes.md) |
| 124 | +
|
| 125 | +[JSON Schema Reference](https://json-schema.org/understanding-json-schema/reference/index.html) |
0 commit comments