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

-AdditionalProperties doesn't appear on the OpenAPI document despite using the -NoAdditionalProperties parameter. #1347

Merged
merged 2 commits into from
Jul 3, 2024
Merged

Conversation

mdaneri
Copy link
Contributor

@mdaneri mdaneri commented Jul 1, 2024

Description of the Change

This PR fixes a bug where the -NoAdditionalProperties parameter was not affecting the OpenAPI document. With this fix, when -NoAdditionalProperties is specified, AdditionalProperties will be correctly set to false in the generated schema.

New-PodeOAIntProperty -Name 'id'-Format Int64 -Example 1 |
        New-PodeOAStringProperty -Name 'name' -Example 'Dogs' |
        New-PodeOAObjectProperty  -XmlName 'category' -NoAdditionalProperties|
        Add-PodeOAComponentSchema -Name 'Category'

Current Behavior

Currently, the OpenAPI document is generated without the AdditionalProperties setting, even when the NoAdditionalProperties parameter is used:

"Category": {
        "type": "object",
        "xml": {
          "name": "category"
        },
        "properties": {
          "id": {
            "type": "integer",
            "example": 1,
            "format": "int64"
          },
          "name": {
            "type": "string",
            "example": "Dogs"
          }
        }
      }

Expected Behavior with Fix

With the bug fix, the OpenAPI document will correctly include AdditionalProperties set to false when the NoAdditionalProperties parameter is used:

"Category": {
        "type": "object",
        "xml": {
          "name": "category"
        },
        "properties": {
          "id": {
            "type": "integer",
            "example": 1,
            "format": "int64"
          },
          "name": {
            "type": "string",
            "example": "Dogs"
          }
        },
        "additionalProperties": false
      }

@Badgerati Badgerati added this to the 2.11.0 milestone Jul 3, 2024
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 merged commit 442f121 into Badgerati:develop Jul 3, 2024
13 of 14 checks passed
@mdaneri mdaneri deleted the fix-additionalProperties-whenfalse branch July 3, 2024 22:49
@Badgerati Badgerati mentioned this pull request Sep 29, 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.

2 participants