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

Enforce that spec has string keys (JSON does not support integer keys) #763

Merged
merged 2 commits into from
Nov 9, 2018

Conversation

dtkav
Copy link
Collaborator

@dtkav dtkav commented Nov 8, 2018

Fixes #756

Spec files are typically written in YAML, which allows keys to be integers.
We convert specs to JSON and serve them up through the API. JSON does not support integer keys.

Previously we were using the ExtendedSafeLoader when reading in YAML files, but this meant that users who loaded their specs manually with yaml.safe_loader() were still at risk of having integer keys.

Rather than force the user to use the ExtendedSafeLoader, this diff recurses through the spec and casts integer keys to string, regardless of if it came from a dict, or file path.

Changes proposed in this pull request:

  • Remove ExtendedSafeLoader (replaces integer keys with strings on YAML load)
  • replace integer keys with strings in the same way, whether the user passes a dict or a path.

@dtkav dtkav changed the title WIP: enforce that spec has string keys (JSON does not support integer keys) Enforce that spec has string keys (JSON does not support integer keys) Nov 9, 2018
@dtkav dtkav requested a review from jmcs November 9, 2018 02:01
@jmcs
Copy link
Contributor

jmcs commented Nov 9, 2018

👍

@jmcs jmcs merged commit 296f892 into spec-first:master Nov 9, 2018
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.

2 participants