Giter Club home page Giter Club logo

flasgger_validation's Introduction

Repo to illustrate flasgger validation issues

(Built with Python 3.6, on MacOS.)

This is attempting to show that the validation=True option on the swag_from decorator isn't doing anything, and the validate() call (which IS doing something) doesn't like following Swagger's allOf option.

The Swagger definition is an entity called Bar, which pulls in fields from FooMixin. I can't get validation=True to fail validation at all, and calling validate() fails if Bar's fields are all correct, as it can't find FooMixin.

Steps to reproduce environment

  1. Pull this repo :-) and go to repo directory in terminal
  2. virtualenv -p python3 venv
  3. source venv/bin/activate
  4. pip install -r requirements.txt
  5. python -m flasgger_broken

Tests to run

With validation=True, valid data produces correct response
$ curl -X POST -H "Content-Type: application/json" -d '{ "bar_uuid": "uuid1234", "bar_email": "[email protected]", "foo1": "I make it valid", "foo2": "something" }' http://localhost:5000/bar

{
  "message": "it worked!"
}

With validation=True, invalid data produces wrong response
$ curl -X POST -H "Content-Type: application/json" -d '{ "iaminvalid": "hahaha" }' http://localhost:5000/bar
{
  "message": "it worked!"
}

With validate(), direct invalid data produces correct response
$ curl -X POST -H "Content-Type: application/json" -d '{ "bar_uuid": "uuid1234", "bar_email": "[email protected]" }' http://localhost:5000/bar_manual
'foo2' is a required property

Failed validating 'required' in schema:
    {'allOf': [{'$ref': '#/definitions/FooMixin'}],
     'definitions': {},
     'example': {'bar_email': '[email protected]',
                 'bar_uuid': '1ab091c8-7567-4420-ab01-5427c991ef2f',
                 'foo1': 'A good foo',
                 'foo2': 'Another good foo'},
     'properties': {'bar_email': {'description': 'The bar email',
                                  'example': '[email protected]',
                                  'type': 'string'},
                    'bar_uuid': {'description': 'the bar uuid',
                                 'example': '1ab091c8-7567-4420-ab01-5427c991ef2f',
                                 'type': 'string'}},
     'required': ['bar_uuid', 'bar_email', 'foo2'],
     'title': 'Bar',
     'type': 'object'}

On instance:
    {'bar_email': '[email protected]', 'bar_uuid': 'uuid1234'}

With validate(), inherited invalid data produces wrong response (should say foo1 is required, as FooMixin needs it)
$ curl -X POST -H "Content-Type: application/json" -d '{ "bar_uuid": "uuid1234", "bar_email": "[email protected]", "foo2": "something" }' http://localhost:5000/bar_manual

Unresolvable JSON pointer: 'definitions/FooMixin'

With validate(), valid data produces wrong response
$ curl -X POST -H "Content-Type: application/json" -d '{ "bar_uuid": "uuid1234", "bar_email": "[email protected]", "foo2": "something" }' http://localhost:5000/bar_manual

Unresolvable JSON pointer: 'definitions/FooMixin'

flasgger_validation's People

Contributors

robertlagrant avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.