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

Restore script to work without pyyaml #565

Merged
merged 1 commit into from Jul 19, 2018
Merged

Conversation

kylef
Copy link
Member

@kylef kylef commented Jul 18, 2018

As yaml.Loader etc is used in the arguments for the function, even due to our other checks for if yaml the script fails on invocation without first installing pyyaml. This PR fixes the script to work with JSON if you don't have pyyaml installed.

Before

$ ./tools/refract-filter.py test/fixtures/schema/array-fixed-inline-samples.json
Traceback (most recent call last):
  File "./tools/refract-filter.py", line 17, in <module>
    def yaml_load(stream, Loader=yaml.Loader, object_pairs_hook=OrderedDict):
AttributeError: 'NoneType' object has no attribute 'Loader'

After

$ ./tools/refract-filter.py test/fixtures/schema/array-fixed-inline-samples.json
{
  "address": [
    "city"
  ]
}
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "address": {
      "type": "array",
      "minItems": 3,
      "items": [
        {
          "type": "string"
        },
        {
          "type": "string",
          "enum": [
            "city"
          ]
        },
        {
          "type": "string"
        }
      ],
      "additionalItems": false
    }
  }
}

@tjanc tjanc merged commit cd11dc5 into master Jul 19, 2018
@tjanc tjanc deleted the kylef/refractfilter-yamlless branch July 19, 2018 06:55
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.

None yet

2 participants