Merge-PodeJsonSchema
SYNOPSIS
Creates a merged JSON Schema type definition using a specified merge type.
SYNTAX
Merge-PodeJsonSchema [-Type] <String> [-Definition] <Hashtable[]> [-ProgressAction <ActionPreference>]
[<CommonParameters>]
DESCRIPTION
This function creates a merged JSON Schema type definition using a specified merge type (AllOf, AnyOf, OneOf, Not) and an array of JSON Schema definitions to merge.
EXAMPLES
EXAMPLE 1
# create a JSON Schema definition that requires a value to match all of the specified schemas
Merge-PodeJsonSchema -Type 'AllOf' -Definition @(
(New-PodeJsonSchemaString -Pattern '^[a-zA-Z]+$' -Description 'Must be a string of letters only'),
(New-PodeJsonSchemaString -MinLength 5 -MaxLength 10 -Description 'Must be between 5 and 10 characters long')
)
EXAMPLE 2
# create a JSON Schema definition that requires a value to match at least one of the specified schemas
Merge-PodeJsonSchema -Type 'AnyOf' -Definition @(
(New-PodeJsonSchemaInteger -Minimum 0 -Maximum 100 -Description 'A percentage of some value'),
(New-PodeJsonSchemaString -Enum 'red', 'green', 'blue' -Description 'A string that must be one of the specified colours')
)
EXAMPLE 3
# create a JSON Schema definition that requires a value to match exactly one of the specified schemas
Merge-PodeJsonSchema -Type 'OneOf' -Definition @(
(New-PodeJsonSchemaInteger -Minimum 0 -Maximum 100 -Description 'A percentage of some value'),
(New-PodeJsonSchemaString -Enum 'red', 'green', 'blue' -Description 'A string that must be one of the specified colours')
)
EXAMPLE 4
# create a JSON Schema definition that requires a value to NOT match any of the specified schemas
Merge-PodeJsonSchema -Type 'Not' -Definition @(
(New-PodeJsonSchemaInteger -Minimum 0 -Maximum 100 -Description 'A percentage of some value'),
(New-PodeJsonSchemaString -Enum 'red', 'green', 'blue' -Description 'A string that must be one of the specified colours')
)
PARAMETERS
-Definition
An array of JSON Schema type definitions to merge.
Type: Hashtable[]
Parameter Sets: (All)
Aliases:
Required: True
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-ProgressAction
{{ Fill ProgressAction Description }}
Type: ActionPreference
Parameter Sets: (All)
Aliases: proga
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Type
The type of merge to perform. Must be one of 'AllOf', 'AnyOf', 'OneOf', or 'Not'.
Type: String
Parameter Sets: (All)
Aliases:
Required: True
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.