Skip to content

Commit

Permalink
Merge 2a771f6 into efb6b3e
Browse files Browse the repository at this point in the history
  • Loading branch information
Badgerati committed Sep 20, 2020
2 parents efb6b3e + 2a771f6 commit 6e27ae9
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
6 changes: 3 additions & 3 deletions docs/Tutorials/OpenAPI.md
Expand Up @@ -359,8 +359,8 @@ New-PodeOAIntProperty -Name 'userId'
# a float number with a max value of 100
New-PodeOANumberProperty -Name 'ratio' -Format Float -Maximum 100
# a string with a default value
New-PodeOAStringProperty -Name 'type' -Default 'admin'
# a string with a default value, and enum of options
New-PodeOAStringProperty -Name 'type' -Default 'admin' -Enum @('admin', 'user')
# a boolean that's required
New-PodeOABoolProperty -Name 'enabled' -Required
Expand All @@ -370,7 +370,7 @@ On their own, like above, the simple properties don't really do much. However, y

### Arrays

There isn't a dedicated function to create an array property, instead there is an `-Array` swicth on each of the propery functions - both Object and the above simple properties.
There isn't a dedicated function to create an array property, instead there is an `-Array` switch on each of the property functions - both Object and the above simple properties.

If you supply the `-Array` switch to any of the above simple properties, this will define an array of that type - the `-Name` parameter can also be omitted if only a simple array if required.

Expand Down
2 changes: 1 addition & 1 deletion examples/web-rest-openapi-simple.ps1
Expand Up @@ -25,7 +25,7 @@ Start-PodeServer {
Write-PodeJsonResponse -Value @{ Name = 'Rick'; UserId = $e.Parameters['userId'] }
} -PassThru |
Set-PodeOARequest -Parameters @(
(New-PodeOAIntProperty -Name 'userId' -Required | ConvertTo-PodeOAParameter -In Path)
(New-PodeOAIntProperty -Name 'userId' -Enum @(100,300,999) -Required | ConvertTo-PodeOAParameter -In Path)
)


Expand Down
21 changes: 21 additions & 0 deletions src/Public/OpenApi.ps1
Expand Up @@ -779,6 +779,10 @@ function New-PodeOAIntProperty
[string]
$Description,

[Parameter()]
[int[]]
$Enum,

[switch]
$Required,

Expand All @@ -801,6 +805,7 @@ function New-PodeOAIntProperty
deprecated = $Deprecated.IsPresent
description = $Description
format = $Format.ToLowerInvariant()
enum = $Enum
default = $Default
}

Expand Down Expand Up @@ -895,6 +900,10 @@ function New-PodeOANumberProperty
[string]
$Description,

[Parameter()]
[double[]]
$Enum,

[switch]
$Required,

Expand All @@ -917,6 +926,7 @@ function New-PodeOANumberProperty
deprecated = $Deprecated.IsPresent
description = $Description
format = $Format.ToLowerInvariant()
enum = $Enum
default = $Default
}

Expand Down Expand Up @@ -1021,6 +1031,10 @@ function New-PodeOAStringProperty
[string]
$Description,

[Parameter()]
[string[]]
$Enum,

[switch]
$Required,

Expand Down Expand Up @@ -1048,6 +1062,7 @@ function New-PodeOAStringProperty
deprecated = $Deprecated.IsPresent
description = $Description
format = $_format.ToLowerInvariant()
enum = $Enum
pattern = $Pattern
default = $Default
}
Expand Down Expand Up @@ -1110,6 +1125,10 @@ function New-PodeOABoolProperty
[string]
$Description,

[Parameter()]
[bool[]]
$Enum,

[switch]
$Required,

Expand All @@ -1131,6 +1150,7 @@ function New-PodeOABoolProperty
required = $Required.IsPresent
deprecated = $Deprecated.IsPresent
description = $Description
enum = $Enum
default = $Default
}

Expand Down Expand Up @@ -1272,6 +1292,7 @@ function ConvertTo-PodeOAParameter
schema = @{
type = $Property.type
format = $Property.format
enum = $Property.enum
}
}

Expand Down

0 comments on commit 6e27ae9

Please sign in to comment.