Badgerati / Pode

Pode is a Cross-Platform PowerShell web framework for creating REST APIs, Web Sites, and TCP/SMTP servers
https://badgerati.github.io/Pode
MIT License
830 stars 92 forks source link

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

Closed mdaneri closed 2 months ago

mdaneri commented 2 months ago

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
      }