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

Adding a mapping for the fields.Method #175

Merged
merged 1 commit into from
Jul 3, 2023
Merged

Conversation

psaiz
Copy link
Contributor

@psaiz psaiz commented Jun 30, 2023

❤️ Thank you for your contribution!

Description

The current user_administration fails because the marshmallow schema fails to convert to json, since it needs something for a field called is_current_user which maps to a method. This is a workaround. It should be better handled during ticket

#174

It addresses inveniosoftware/invenio-app-rdm#2232

Checklist

Ticks in all boxes and 🟢 on all GitHub actions status checks are required to merge:

Third-party code

If you've added third-party code (copy/pasted or new dependencies), please reach out to an architect.

Reminder

By using GitHub, you have already agreed to the GitHub’s Terms of Service including that:

  1. You license your contribution under the same terms as the current repository’s license.
  2. You agree that you have the right to license your contribution under the current repository’s license.

@zzacharo zzacharo merged commit d98f9f1 into inveniosoftware:main Jul 3, 2023
# TODO: This is needed for the is_current_user in the administration
# of the user resources. It might be better to implement also a handler for this.
# See https://github.com/inveniosoftware/invenio-administration/issues/174
fields.Method: None,
Copy link
Member

@ppanero ppanero Jul 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: how does jsonschema behaves with None or null as type? This value will be used below

schema_dict[field].update({
                    "type": custom_mapping[field_type_name],
                })

We might need to add a check in the jsonify_schema function. Or tests....

(edit) if fails...

>>> from jsonschema import validate
>>>
>>> schema = {
...       "type" : "object",
...       "properties" : {
...           "price" : {"type" : "number"},
...           "name" : {"type" : None},
...       },
...   }
>>>
>>> validate(instance={"name" : "Eggs", "price" : 34.99}, schema=schema)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/ppanero/.virtualenvs/invenio-rdm-migrator/lib/python3.9/site-packages/jsonschema/validators.py", line 1117, in validate
    cls.check_schema(schema)
  File "/Users/ppanero/.virtualenvs/invenio-rdm-migrator/lib/python3.9/site-packages/jsonschema/validators.py", line 231, in check_schema
    raise exceptions.SchemaError.create_from(error)
jsonschema.exceptions.SchemaError: None is not valid under any of the given schemas

Failed validating 'anyOf' in metaschema['allOf'][1]['properties']['properties']['additionalProperties']['$dynamicRef']['allOf'][3]['properties']['type']:
    {'anyOf': [{'$ref': '#/$defs/simpleTypes'},
               {'items': {'$ref': '#/$defs/simpleTypes'},
                'minItems': 1,
                'type': 'array',
                'uniqueItems': True}]}

On schema['properties']['name']['type']:
    None

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 this pull request may close these issues.

administration: add user management panel
3 participants