Skip to content

Commit 6ca25ad

Browse files
committed
Show comment based help for Invoke-ShlinkRestMethod in docs
1 parent 051f18b commit 6ca25ad

File tree

4 files changed

+96
-45
lines changed

4 files changed

+96
-45
lines changed

.vscode/tasks.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"label": "Build (with docs)",
2424
"type": "process",
2525
"command": "pwsh",
26-
"args": ["-noprofile","-command","Invoke-Build","-File","./invoke.build.ps1","-Author","'codaamok'","-ModuleName","'PSShlink'","-UpdateDocs","$true","$true"],
26+
"args": ["-noprofile","-command","Invoke-Build","-File","./invoke.build.ps1","-Author","'codaamok'","-ModuleName","'PSShlink'","-UpdateDocs","$true"],
2727
"group": {
2828
"kind": "build",
2929
"isDefault": true

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
8+
### Fixed
9+
- Show comment based help correctly for `Invoke-ShlinkRestMethod`, mostly for PlatyPS and in-repository help markdown files
810

911
## [0.12.0] - 2023-03-05
1012
### Added

docs/Invoke-ShlinkRestMethod.md

Lines changed: 91 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ schema: 2.0.0
88
# Invoke-ShlinkRestMethod
99

1010
## SYNOPSIS
11-
{{ Fill in the Synopsis }}
11+
Query a Shlink server's REST API
1212

1313
## SYNTAX
1414

@@ -19,116 +19,162 @@ Invoke-ShlinkRestMethod [-Endpoint] <String> [[-Path] <String>] [[-Query] <HttpU
1919
```
2020

2121
## DESCRIPTION
22-
{{ Fill in the Description }}
22+
This function provides flexibility to query a Shlink's server how you want to.
23+
24+
Specify all the parameters, endpoint, and path details you need.
25+
26+
All data from all pages are returned.
27+
28+
See Shlink's REST API documentation: https://shlink.io/documentation/api-docs/ and https://api-spec.shlink.io/
2329

2430
## EXAMPLES
2531

26-
### Example 1
27-
```powershell
28-
PS C:\> {{ Add example code here }}
32+
### EXAMPLE 1
33+
```
34+
Invoke-ShlinkRestMethod -Endpoint "short-urls" -PropertyTree "shortUrls", "Data" -Query [System.Web.HttpUtility]::ParseQueryString("searchTerm", "abc")
35+
```
36+
37+
Gets all short codes from Shlink matching the search term "abc".
38+
39+
Note (it's not obvious), you can add more query params to an instance of HttpUtility like you can any dictionary by using the .Add() method on the object.
40+
41+
### EXAMPLE 2
42+
```
43+
Invoke-ShlinkRestMethod -Endpoint "short-urls" -Path "abc" -METHOD "DELETE"
2944
```
3045

31-
{{ Add example description here }}
46+
Deletes the shortcode "abc" from Shlink.
47+
48+
### EXAMPLE 3
49+
```
50+
Invoke-ShlinkRestMethod -Endpoint "tags" -Path "stats"
51+
```
52+
53+
Gets all tags with statistics.
3254

3355
## PARAMETERS
3456

35-
### -ApiVersion
36-
{{ Fill ApiVersion Description }}
57+
### -Endpoint
58+
The endpoint to use in the request.
59+
This is before the -Path.
60+
See the examples for example usage.
3761

3862
```yaml
39-
Type: Int32
63+
Type: String
4064
Parameter Sets: (All)
4165
Aliases:
42-
Accepted values: 1, 2, 3
4366

44-
Required: False
45-
Position: 3
67+
Required: True
68+
Position: 1
4669
Default value: None
4770
Accept pipeline input: False
4871
Accept wildcard characters: False
4972
```
5073
51-
### -Endpoint
52-
{{ Fill Endpoint Description }}
74+
### -Path
75+
The path to use in the request.
76+
This is after the -Endpoint.
77+
See the examples for example usage.
5378
5479
```yaml
5580
Type: String
5681
Parameter Sets: (All)
5782
Aliases:
5883

59-
Required: True
60-
Position: 0
84+
Required: False
85+
Position: 2
6186
Default value: None
6287
Accept pipeline input: False
6388
Accept wildcard characters: False
6489
```
6590
66-
### -Method
67-
{{ Fill Method Description }}
91+
### -Query
92+
The query to use in the request.
93+
Must be an instance of System.Web.HttpUtility.
94+
See the examples for example usage.
95+
96+
Note (it's not obvious), you can add more query params to an instance of HttpUtility like you can any dictionary by using the .Add() method on the object.
6897
6998
```yaml
70-
Type: WebRequestMethod
99+
Type: HttpUtility
71100
Parameter Sets: (All)
72101
Aliases:
73-
Accepted values: Default, Get, Head, Post, Put, Delete, Trace, Options, Merge, Patch
74102

75103
Required: False
76-
Position: 4
104+
Position: 3
77105
Default value: None
78106
Accept pipeline input: False
79107
Accept wildcard characters: False
80108
```
81109
82-
### -Path
83-
{{ Fill Path Description }}
110+
### -ApiVersion
111+
The API version of Shlink to use in the request.
84112
85113
```yaml
86-
Type: String
114+
Type: Int32
87115
Parameter Sets: (All)
88116
Aliases:
89117

90118
Required: False
91-
Position: 1
92-
Default value: None
119+
Position: 4
120+
Default value: 3
93121
Accept pipeline input: False
94122
Accept wildcard characters: False
95123
```
96124
97-
### -PropertyTree
98-
{{ Fill PropertyTree Description }}
125+
### -Method
126+
The HTTP method to use in the request.
99127
100128
```yaml
101-
Type: String[]
129+
Type: WebRequestMethod
102130
Parameter Sets: (All)
103131
Aliases:
132+
Accepted values: Default, Get, Head, Post, Put, Delete, Trace, Options, Merge, Patch
104133

105134
Required: False
106135
Position: 5
107-
Default value: None
136+
Default value: GET
108137
Accept pipeline input: False
109138
Accept wildcard characters: False
110139
```
111140
112-
### -Query
113-
{{ Fill Query Description }}
141+
### -PropertyTree
142+
Data returned by Shlink's rest API is usually embedded within one or two properties.
143+
144+
Here you can specify the embedded properties as a string array in the order you need to select them to access the data.
145+
146+
For example, the "short-urls" endpoint includes the data within the "shortUrls.data" properties.
147+
Therefore, for this parameter you specify a string array of @("shortUrls", "data").
148+
149+
In other words, using this function for the short-urls endpoint results in the below object if there are two pages worth of data returned:
150+
151+
Invoke-ShlinkRestMethod -Endpoint 'short-urls'
152+
153+
shortUrls
154+
---------
155+
@{data=System.Object\[\]; pagination=}
156+
@{data=System.Object\[\]; pagination=}
114157
115158
```yaml
116-
Type: HttpUtility
159+
Type: String[]
117160
Parameter Sets: (All)
118161
Aliases:
119162

120163
Required: False
121-
Position: 2
164+
Position: 6
122165
Default value: None
123166
Accept pipeline input: False
124167
Accept wildcard characters: False
125168
```
126169
127-
### -ShlinkApiKey
128-
{{ Fill ShlinkApiKey Description }}
170+
### -ShlinkServer
171+
The URL of your Shlink server (including schema).
172+
For example "https://example.com".
173+
It is not required to use this parameter for every use of this function.
174+
When it is used once for any of the functions in the PSShlink module, its value is retained throughout the life of the PowerShell session and its value is only accessible within the module's scope.
129175
130176
```yaml
131-
Type: SecureString
177+
Type: String
132178
Parameter Sets: (All)
133179
Aliases:
134180

@@ -139,16 +185,18 @@ Accept pipeline input: False
139185
Accept wildcard characters: False
140186
```
141187
142-
### -ShlinkServer
143-
{{ Fill ShlinkServer Description }}
188+
### -ShlinkApiKey
189+
A SecureString object of your Shlink server's API key.
190+
It is not required to use this parameter for every use of this function.
191+
When it is used once for any of the functions in the PSShlink module, its value is retained throughout the life of the PowerShell session and its value is only accessible within the module's scope.
144192
145193
```yaml
146-
Type: String
194+
Type: SecureString
147195
Parameter Sets: (All)
148196
Aliases:
149197

150198
Required: False
151-
Position: 6
199+
Position: 8
152200
Default value: None
153201
Accept pipeline input: False
154202
Accept wildcard characters: False
@@ -159,10 +207,10 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
159207
160208
## INPUTS
161209
162-
### None
210+
### This function does not accept pipeline input.
163211
## OUTPUTS
164212
165-
### System.Object
213+
### System.Management.Automation.PSObject
166214
## NOTES
167215
168216
## RELATED LINKS

src/Public/Invoke-ShlinkRestMethod.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
function Invoke-ShlinkRestMethod {
2-
# TODO this function needs tests
32
<#
43
.SYNOPSIS
54
Query a Shlink server's REST API
@@ -91,6 +90,8 @@ function Invoke-ShlinkRestMethod {
9190
[Parameter()]
9291
[SecureString]$ShlinkApiKey
9392
)
93+
94+
# TODO this function needs tests
9495

9596
try {
9697
GetShlinkConnection -Server $ShlinkServer -ApiKey $ShlinkApiKey

0 commit comments

Comments
 (0)