Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialize-PodeOpenApiTable fails to initialize OpenAPI table when DefaultDefinitionTag param is Null #1407

Merged
merged 5 commits into from
Oct 20, 2024

Conversation

mdaneri
Copy link
Contributor

@mdaneri mdaneri commented Oct 7, 2024

Fix for #1406
Added a new sample for the Use-PodeAuth function

Description of the Change

New sample for the Use-PodeAuth function
Initialize-PodeOpenApiTable now is checking if $DefaultDefinitionTag param is $null and by default assign the value 'default'

function Initialize-PodeOpenApiTable {
    param(
        [string]
        $DefaultDefinitionTag
    )
    # Check if the provided definition tag is null or empty. If so, set it to 'default'.
    if ([string]::IsNullOrEmpty($DefaultDefinitionTag)) {
        $DefaultDefinitionTag = 'default'
    }

    # Initialization of the OpenAPI table with default settings
    # Create a hashtable named $OpenAPI to hold various OpenAPI-related configurations and data.
    $OpenAPI = @{
        # Initialize a stack to manage the Definition Tag selection.
        DefinitionTagSelectionStack = [System.Collections.Generic.Stack[System.Object]]::new()
    }

    # Set the currently selected definition tag to the provided or default tag.
    $OpenAPI['SelectedDefinitionTag'] = $DefaultDefinitionTag

    # Initialize the Definitions dictionary with a base OpenAPI object for the selected definition tag.
    # The base OpenAPI object is created using the Get-PodeOABaseObject function.
    $OpenAPI['Definitions'] = @{ $OpenAPI['SelectedDefinitionTag'] = Get-PodeOABaseObject }

    # Return the initialized OpenAPI table
    return $OpenAPI
}

Related Issue

#1406

@Badgerati Badgerati linked an issue Oct 20, 2024 that may be closed by this pull request
Copy link
Owner

@Badgerati Badgerati left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Badgerati Badgerati added this to the 2.11.1 milestone Oct 20, 2024
@Badgerati Badgerati merged commit 0411580 into Badgerati:develop Oct 20, 2024
15 checks passed
@mdaneri mdaneri deleted the issue-1406 branch October 21, 2024 14:13
@Badgerati Badgerati mentioned this pull request Nov 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Set-PodeOAGlobalAuth failure on launch
2 participants