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

Dump partial loading schema still return required fields. #112

Open
lehainam-dev opened this issue May 19, 2020 · 1 comment
Open

Dump partial loading schema still return required fields. #112

lehainam-dev opened this issue May 19, 2020 · 1 comment

Comments

@lehainam-dev
Copy link

lehainam-dev commented May 19, 2020

Hi everyone,

Thank @fuhrysteve for this awesome lib.

As using the lib, I find out that schema with partial loading does not parse correctly to JSON schema. It still has required fields even though it should not. Here is the example test.

from marshmallow import Schema, fields
from marshmallow_jsonschema import JSONSchema


class UserSchema(Schema):
    name = fields.String(required=True)
    email = fields.String(required=True)


schema = UserSchema(partial=True)

assert schema.load({}) == {}

required_fields = JSONSchema().dump(schema)['definitions']['UserSchema']['required']

print(required_fields)  # ['email', 'name']
assert required_fields == []

Expected results

  • The assertion test should run correctly.

Current results

  • required_fields has values email and name.

I'm happy to investigate and make PR to this issue.

@lehainam-dev lehainam-dev changed the title Dump partial loading schema still return require field. Dump partial loading schema still return required fields. May 19, 2020
@lehainam-dev
Copy link
Author

Wow that was quick, thanks for separated get_required method.
I made a PR #113. I'm looking forward to your reply soon.

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

Successfully merging a pull request may close this issue.

1 participant