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

Sway doesn't correctly validate request body #191

Closed
msmol opened this issue Nov 19, 2018 · 1 comment
Closed

Sway doesn't correctly validate request body #191

msmol opened this issue Nov 19, 2018 · 1 comment

Comments

@msmol
Copy link

msmol commented Nov 19, 2018

Given following openapi definition:

{
  "openapi": "3.0.0",
  "info": {
    "description": "Test",
    "version": "1.0.0",
    "title": "Test API"
  },
  "tags": [],
  "paths": {
    "/test": {
      "post": {
        "tags": [],
        "summary": "POST test",
        "description": "A POST test",
        "requestBody": {
          "description": "A test body",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "foo"
                ],
                "properties": {
                  "foo": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {},
        "security": []
      }
    }
  },
  "components": {
    "requestBodies": {},
    "securitySchemes": {},
    "schemas": {}
  }
}

I would expect sway to validate that a POST request to /test must have the key foo in it's body.

In non-strict mode I get no errors, in strict mode I get:

{
  errors: [
    {
      code: 'REQUEST_ADDITIONAL_FORM_DATA',
      message: 'Additional form data field not allowed: foo',
      path: []
    }
  ],
  warnings: []
}

Thanks!

@msmol msmol changed the title Sway doesn't validate request body Sway doesn't correctly validate request body Nov 19, 2018
@whitlockjc
Copy link
Member

[email protected] isn't supported yet, and is tracked in #128.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants