Skip to content

New-PodeJsonSchemaProperty

SYNOPSIS

Creates a JSON Schema property definition for use in an object schema.

SYNTAX

New-PodeJsonSchemaProperty [-Name] <String> [-Definition] <Hashtable> [-Required]
 [-ProgressAction <ActionPreference>] [<CommonParameters>]

DESCRIPTION

This function creates a JSON Schema property definition for use in an object schema.

EXAMPLES

EXAMPLE 1

# create a JSON Schema property definition for a required string property "name" with a description
New-PodeJsonSchemaProperty -Name 'name' -Definition (
    New-PodeJsonSchemaString -Description 'The name of the person'
) -Required

EXAMPLE 2

# create a JSON Schema property definition for an optional integer property "age" with a description
New-PodeJsonSchemaProperty -Name 'age' -Definition (
    New-PodeJsonSchemaInteger -Description 'The age of the person'
)

EXAMPLE 3

# create a JSON Schema property definition for a required array property "tags" with a description, where the items in the array must be unique strings
New-PodeJsonSchemaProperty -Name 'tags' -Definition (
    New-PodeJsonSchemaArray -Unique -Item (
        New-PodeJsonSchemaString
    ) -Description 'An array of unique tags for the person'
) -Required

EXAMPLE 4

# create a JSON Schema property definition for an optional property "metadata" with a description, where the value can be any object with a minimum of 1 property
New-PodeJsonSchemaProperty -Name 'metadata' -Definition (
    New-PodeJsonSchemaObject -MinProperties 1 -Description 'Additional metadata about the person'
)

PARAMETERS

-Definition

A hashtable representing the JSON Schema type definition for the property. This should be created using one of the other New-PodeJsonSchema* functions.

Type: Hashtable
Parameter Sets: (All)
Aliases:

Required: True
Position: 2
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False

-Name

The name of the property.

Type: String
Parameter Sets: (All)
Aliases:

Required: True
Position: 1
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

-Required

Indicates whether the property is required.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
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.

INPUTS

OUTPUTS

System.Collections.Hashtable

NOTES

https://json-schema.org/understanding-json-schema/reference/type