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

Handle type refs in _map_refs #166

Merged
merged 9 commits into from
Sep 6, 2019
Merged

Handle type refs in _map_refs #166

merged 9 commits into from
Sep 6, 2019

Conversation

jacoblurye
Copy link
Contributor

The _map_ref's update does two main things:

  • fixes the docs description bug for template schemas that use type_ref
  • fixes excel template file generation for template schemas that use type_ref (now validations and comments should appear)

Also, makes a little tweak to macros.j2 to handle consts in schemas.

Copy link
Contributor

@jim-bo jim-bo left a comment

Choose a reason for hiding this comment

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

@jacoblurye No major comments, seems like an elegant solution.

One question is do we know have tests that would detect the reversion (at least for the template generation)?

@jacoblurye
Copy link
Contributor Author

@jim-bo we don't have tests for things like comments or validations appearing in Excel documents - I don't know of a way to automatically test that sort of thing, though.


# Plus concatenated new and old '$comment' fields
# which should be just ignored anyways.
if '$comment' in new_node or '$comment' in node:
Copy link
Member

Choose a reason for hiding this comment

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

As comments contain development related TODOs and stuff and we're now sending links to these docs to people, I think we should leave comments to ourselves and not add them in a visible manner to the docs.

Copy link
Member

Choose a reason for hiding this comment

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

nevermind

# Look for all refs in this mapping
for k, v in node.items():
node[k] = _map_refs(v, on_refs)
if isinstance(node, collections.abc.Mapping):
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure how this works, I though map_refs will be called whenever json schema walker walks into a node with '$ref'. So from that understanding it will not be called at all on some node : {"type_ref": "..."}

Copy link
Contributor Author

@jacoblurye jacoblurye Sep 6, 2019

Choose a reason for hiding this comment

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

I think _map_refs is the json schema walker you're referring to? On the next line, we look for $refs and type_refs, then handle each case slightly differently. The test test_json_validation.test_map_refs might be a bit helpful, too.

Copy link
Member

Choose a reason for hiding this comment

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

never mind

@jacoblurye jacoblurye merged commit c99141b into master Sep 6, 2019
@jacoblurye jacoblurye deleted the handle-type-refs branch September 6, 2019 17:46
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.

4 participants