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

GET Operations Incorrectly Allowing Request Body in OpenAPI Generation #1371

Closed
mdaneri opened this issue Jul 25, 2024 · 0 comments · Fixed by #1369
Closed

GET Operations Incorrectly Allowing Request Body in OpenAPI Generation #1371

mdaneri opened this issue Jul 25, 2024 · 0 comments · Fixed by #1369
Labels

Comments

@mdaneri
Copy link
Contributor

mdaneri commented Jul 25, 2024

Description:
There is an issue with the OpenAPI generation in Pode where GET operations are incorrectly allowing the inclusion of a Request Body. According to the OpenAPI Specification, GET operations should not have a request body, but Pode currently does not enforce this restriction.

Steps to Reproduce:

  1. Define a route in Pode with a GET operation that includes a request body.
  2. Generate the OpenAPI documentation for the route.
  3. Observe that the generated documentation includes a request body for the GET operation.

Expected Behavior:
The OpenAPI generation should not include a request body for GET operations as per the OpenAPI Specification.

Actual Behavior:
The generated OpenAPI documentation includes a request body for GET operations.

Example:

Add-PodeRoute -PassThru -Method Get -Path '/pet' -ScriptBlock {
    # code here
} | Set-PodeOARouteInfo -Summary 'Add a new pet to the store' -Description 'Add a new pet to the store' -Tags 'pet' -OperationId 'addPet' -PassThru |
    Set-PodeOARequest -RequestBody (New-PodeOARequestBody -Description 'Create a new pet in the store' -Required -Content (
        New-PodeOAContentMediaType -MediaType 'application/json', 'application/xml' -Content 'Pet'
    )) -PassThru |
    Add-PodeOAResponse -StatusCode 200 -Description 'Successful operation' -Content (New-PodeOAContentMediaType -MediaType 'application/json', 'application/xml' -Content 'Pet') -PassThru |
    Add-PodeOAResponse -StatusCode 405 -Description 'Invalid input'

Additional Context:
The OpenAPI Specification (OAS3) clearly states that a request body is not supported in GET operations. This needs to be enforced in the OpenAPI generation within Pode to ensure compliance with the specification.

References:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
1 participant