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

Exception When Generating OpenAPI Object with `oneOf` ,`anyOf` and `allOf` Property in Pode #1368

Closed mdaneri closed 2 weeks ago

mdaneri commented 1 month ago

Summary:

An exception is thrown when attempting to generate an OpenAPI object in Pode that includes a oneOf property containing non-object elements.

Description:

When trying to create an OpenAPI object in Pode that includes a oneOf property with non-object elements, such as string and number, the Pode code results in an exception. The expected OpenAPI object should have a property with oneOf types and another property with an enum. However, the Pode code fails to generate this structure correctly and raises an exception.

Expected OpenAPI Object:

ComparableQueryParameter: 
  type: object
  properties: 
    value: 
      description: The value to compare against
      oneOf: 
        - type: string
          format: date-time
        - type: number
          format: float
    op: 
      type: string
      enum: 
        - GT
        - LT
        - GE
        - LE
        - EQ
        - NE 
  required:  
    - value
    - op

Pode Code Used:

Merge-PodeOAProperty -Type OneOf -Name 'value' -Description 'The value to compare against' -Required -NoObjectDefinitionsFromPipeline -ObjectDefinitions (
    (New-PodeOAStringProperty -Format Date-Time),
    (New-PodeOANumberProperty -Format Float)
) | New-PodeOAStringProperty -Name 'op' -Enum 'GT', 'LT', 'GE', 'LE', 'EQ', 'NE' -Required |
    New-PodeOAObjectProperty | Add-PodeOAComponentSchema -Name 'ComparableQueryParameter'