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

Prism does not take the "required" property into account when validating body param #419

Closed
brianmrock opened this issue Jul 6, 2019 · 1 comment · Fixed by #450
Closed
Assignees
Labels

Comments

@brianmrock
Copy link
Contributor

Prerequisites

{
  "swagger": "2.0",
  "paths": {
    "/pet": {
      "get": {
        "produces": ["application/json"],
        "consumes": ["application/json"],
        "parameters": [
          {
            "in": "body",
            "name": "body",
            "required": false,
            "schema": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "integer",
                  "format": "int64"
                }
              }
            }
          }
        ],
        "responses": {
          "200": {
            "schema": {
              "type": "string"
            }
          }
        }
      }
    }
  }
}

Steps to reproduce

  1. Start prism with the provided endpoint2. curl -X POST http://127.0.0.1:4010/pet3. Observe output

Expected

Should return 200 and a lorem ipsum response

Actual

Returns an error

{"type":"https://stoplight.io/prism/errors#UNPROCESSABLE_ENTITY","title":"Invalid request body payload","status":422,"detail":"Your request body is not valid: [{\"path\":[\"body\"],\"code\":\"type\",\"message\":\"should be object\",\"severity\":0}]"}

Context

We currently don't check the required field when validating body. The proposed solutions is that HttpBodyValidator should extend HttpParamsValidator class.

@brianmrock brianmrock added this to the Quacker Sprint milestone Jul 6, 2019
@XVincentX XVincentX self-assigned this Jul 10, 2019
@XVincentX
Copy link
Contributor

Confirmed. This is happening because the body schema in content is not a regular JSON Schema and needs to be transformed as well.

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 a pull request may close this issue.

2 participants