PowerShell / PowerShell/PowerShell
`Invoke-RestMethod` & `Invoke-WebRequest` should have tab completion for `-ContentType`
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 55.5k
- Forks
- 8.5k
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 88
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/jsonapplication/x-www-form-urlencodedapplication/xmlapplication/zipapplication/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
ContentArgumentCompleterto virtual propertyContentTypeinWebRequestPSCmdletbase 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'.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the WebRequestPSCmdlet base class and its virtual ContentType property, then review how argument completers are implemented for PowerShell cmdlets. Add completion for common content types for both Invoke-RestMethod and Invoke-WebRequest, including prefix matching such as “app”, and verify that cycling through completions works.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, powershell
- Domain
- cli, developer-experience
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100