| | | 1 | | <# |
| | | 2 | | .SYNOPSIS |
| | | 3 | | Creates a new OpenAPI Link object. |
| | | 4 | | .DESCRIPTION |
| | | 5 | | This function creates a new OpenAPI Link object that can be used to define relationships between operations |
| | | 6 | | in an OpenAPI specification. Links allow you to specify how the output of one operation can be used as input to anot |
| | | 7 | | .PARAMETER OperationRef |
| | | 8 | | A reference to an existing operation in the OpenAPI specification using a JSON Reference. |
| | | 9 | | .PARAMETER OperationId |
| | | 10 | | The operationId of an existing operation in the OpenAPI specification. |
| | | 11 | | .PARAMETER Description |
| | | 12 | | A description of the link. |
| | | 13 | | .PARAMETER Server |
| | | 14 | | An OpenAPI Server object that specifies the server to be used for the linked operation. |
| | | 15 | | .PARAMETER Parameters |
| | | 16 | | A hashtable mapping parameter names to runtime expressions or literal objects that define the parameters for the lin |
| | | 17 | | .PARAMETER RequestBody |
| | | 18 | | A runtime expression or literal object that defines the request body for the linked operation. |
| | | 19 | | .EXAMPLE |
| | | 20 | | $link = New-KrOpenApiLink -OperationId "getUser" -Description "Link to get user details" -Parameters @{ "userId" = " |
| | | 21 | | This example creates a new OpenAPI Link object that links to the "getUser" operation, with a description and paramet |
| | | 22 | | .NOTES |
| | | 23 | | This function is part of the Kestrun PowerShell module for working with OpenAPI specifications. |
| | | 24 | | #> |
| | | 25 | | function New-KrOpenApiLink { |
| | | 26 | | [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseShouldProcessForStateChangingFunctions', '')] |
| | | 27 | | [KestrunRuntimeApi('Definition')] |
| | | 28 | | param( |
| | | 29 | | [string]$OperationRef, |
| | | 30 | | [string]$OperationId, |
| | | 31 | | [string]$Description, |
| | | 32 | | # Accept a prebuilt OpenAPI server (use New-KrOpenApiServer) |
| | | 33 | | [Microsoft.OpenApi.OpenApiServer] $Server, |
| | | 34 | | # Accept hashtable name -> string (runtime expression) or literal object |
| | | 35 | | [hashtable]$Parameters, |
| | | 36 | | # Accept string runtime expression or hashtable/array literal object |
| | | 37 | | [object] $RequestBody |
| | | 38 | | ) |
| | | 39 | | |
| | 0 | 40 | | return [Kestrun.OpenApi.OpenApiLinkFactory]::Create($OperationRef, $OperationId, $Description, $Server, $Parameters, |
| | | 41 | | } |