prism icon indicating copy to clipboard operation
prism copied to clipboard

Request body validation is not working

Open lopenchi opened this issue 1 year ago • 2 comments

Context

When using the Stoplight mock server, I encountered an issue where the validation does not work as expected when there is incorrect data. This issue affects users who rely on accurate validation responses for API testing and mocking.

Current Behavior

Instead of throwing an error for invalid data, the mock server returns a 200 OK status, incorrectly indicating that the validation passed.

Expected Behavior

When an invalid data is sent, throw a 400 error

Possible Workaround/Solution

No ideas

Steps to Reproduce

  1. Define a new path with request body (object) in the Stoplight project
"/v1/Conversations": {
      "description": "A Participant resource represents a member of the conversation.",
      "post": {
        "description": "Add a new participant to the conversation",
        "parameters": [],
        "responses": {
          "201": ...
        },
        "requestBody": {
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "title": "CreateConversationParticipantRequest",
                "properties": {
                  "MessagingBinding.Address": {
                    "type": "string",
                    "description": "The address of the participant's device"
                  }
                }
              },
            }
          }
        }
      }
    },
  1. Send a request with data that does not meet the validation criteria (e.g., missing required fields or invalid field lengths).
curl -X POST "http://127.0.0.1:4010/v1/Conversations" \
--data-urlencode "MessagingBindingAddress=+15558675310" \
  1. Observe that the server incorrectly returns a 200 OK status. MessagingBindingAddress must be MessagingBinding.Address

Environment

  • Version used: 5.11.0
  • macos

lopenchi avatar Aug 13 '24 17:08 lopenchi

Having the same problem, all of our pipelines broke.

rtritean avatar Aug 29 '24 09:08 rtritean

Same here, still with form-urlencoded, using prism-cli 5.12.0

Jean85 avatar Apr 08 '25 13:04 Jean85