-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Description
Summary of the new feature / enhancement
As a user who tests API REST calls from the terminal using Invoke-RestMethod
& Invoke-WebRequest
frequently, it would be very beneficial to have tab completion for content types. Especially for common ones like application/json
or application/x-www-form-urlencoded
which can get cumbersome to type out every time.
Given the list of MIME Types is quite big and most of these are not commonly used in PowerShell, we could limit tab completion to common content types.
Quick grep search of content types across GitHub repos for PowerShell:
application/json
application/x-www-form-urlencoded
application/xml
application/zip
application/octet-stream
We could even use .NET Media MIME types in System.Net.Mime.MediaTypeNames
to load these in dynamically and avoid hardcoding a list.
It would improve the developer experience of these cmdlets, especially when testing API calls.
Proposed technical implementation details (optional)
- Add a
ContentArgumentCompleter
to virtual propertyContentType
inWebRequestPSCmdlet
base class. - Ensure user can do something like
Invoke-RestMethod -ContentType <TAB>
and cycle through completions of content types. - If they provide start of word it would complete the possible content type completions e.g.
Invoke-RestMethod -ContentType 'app<TAB>
would complete toInvoke-RestMethod -ContentType 'application/json'
.