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

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant