Skip to content

Swagger/OpenAPI marks PUT-only parameter as required for GET in multi-method endpoints using parameter sets #5601

@RubenT91

Description

@RubenT91

Description of Issue

When a PowerShell Universal endpoint is configured with multiple HTTP methods on the same route and uses PowerShell parameter sets to separate GET and PUT, Swagger/OpenAPI renders the parameters incorrectly for the GET operation.

The main issue is that a parameter that is only mandatory in the PUT parameter set is still shown under GET and is marked as required.

A related symptom is that helper switches such as GET and PUT may also appear in Swagger when used as a workaround, but internal validation showed the primary issue persists even without those helper switches.

Direct runtime execution behaves correctly. The problem appears limited to Swagger/OpenAPI generation and Swagger UI / Swagger Execute.

List of steps, sample code, failing test or link to a project that reproduces the behavior:

  1. Create a multi-method endpoint with GET and PUT on the same route.
  2. Use parameter sets so that:
    • one shared identifier parameter is mandatory for both GET and PUT
    • one action-specific parameter is mandatory only for PUT
  3. Open the generated Swagger/OpenAPI documentation.
  4. Review the GET operation.

Expected behavior:

  • GET should only show the shared identifier parameter as required.
  • The PUT-only parameter should not appear under GET.

Actual behavior:

  • GET shows the PUT-only parameter and marks it as required.
  • Runtime calls still behave correctly outside Swagger.

Sample code:

[CmdletBinding(DefaultParameterSetName = 'GET')]
param (
    [Parameter(ParameterSetName = 'GET', Mandatory = $true)]
    [Parameter(ParameterSetName = 'PUT', Mandatory = $true)]
    [string]$ResourceId,

    [Parameter(ParameterSetName = 'PUT', Mandatory = $true)]
    [ValidateNotNullOrEmpty()]
    [ValidateSet("OptionA", "OptionB")]
    [string]$ActionType
)

switch ($PSCmdlet.ParameterSetName) {
    'GET' {
        @{ Method = 'GET'; ResourceId = $ResourceId } | ConvertTo-Json
    }
    'PUT' {
        @{ Method = 'PUT'; ResourceId = $ResourceId; ActionType = $ActionType } | ConvertTo-Json
    }
}

Additional reproduction notes:
Internal validation tested 3 variants:

  1. Multi-method endpoint with helper switches GET / PUT
  2. Multi-method endpoint without helper switches
  3. Separate GET and PUT endpoints

Results:

  • Variant 1: Swagger GET showed the shared parameter, the PUT-only parameter, and helper switches; the PUT-only parameter was marked required
  • Variant 2: Swagger GET still showed the shared parameter and the PUT-only parameter; the PUT-only parameter was marked required
  • Variant 3: Separate GET endpoint only showed the shared parameter as expected

This suggests the issue is in OpenAPI parameter-set mapping for multi-method endpoints, not just the helper-switch workaround.

Version

2026.1.3 / 2026.1.4

Severity

Medium

Hosting Method

MSI (Windows Service)

Operating System

Windows

Database

SQLite

Licensed

Yes

Features

API Endpoints

OpenAPI / Swagger

Additional Environment data

Direct runtime execution via Invoke-RestMethod succeeded in all tested variants.

Issue appears isolated to Swagger/OpenAPI generation and Swagger UI / Swagger Execute.

Customer also confirmed the issue still persists after testing in 2026.1.4.

Screenshots/Animations

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    requires triageIssue has not yet been verified by the development team.v5Version 5 issue.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions