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

With nested api model expect is raising error with key not found. #802

Open
BHAUTIK04 opened this issue Aug 14, 2020 · 0 comments
Open

With nested api model expect is raising error with key not found. #802

BHAUTIK04 opened this issue Aug 14, 2020 · 0 comments

Comments

@BHAUTIK04
Copy link

We have flask_restplus for our API, in one of the post requests we have a nested structure. When we validate input json with expect decorator it is raising the key error. API model is

user_expected_field = api.model('UserRequest', {
            "user_email": fields.String(example='[email protected]', required=True),
            "user_name": fields.String(example="user", required=True),
            "user_gender": fields.String(example="Male", required=True),
            "user_address":fields.List(fields.Nested(api.model(
                       "AddressModel", {
                                "street1": field.String(required=True),
                                "street2": field.String(required=True),
                                "city": field.String(required=True),
                                "state": field.String(required=True),
                                "country": field.String(required=True),
                        }
            )))
        },
    )

Error:

Traceback (most recent call last):
File "/lib/python3.6/site-packages/jsonschema/validators.py", line 812, in resolve_fragment
document = document[part]
KeyError: 'AddressModel'

Any help will be highly appreciated.

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

1 participant