Skip to content

Commit

Permalink
Definitions Update kalm
Browse files Browse the repository at this point in the history
Fix validation
  • Loading branch information
Anton Benkevich committed Jun 30, 2020
1 parent 39e50ac commit 4c103ed
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions alsdkdefs/apis/kalm/kalm.v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ paths:
- asset_count
from: v_vulnerability_by_date_range
where:
=:
"=":
- asset_type
- $asset_type_param
group_by:
Expand Down Expand Up @@ -137,7 +137,7 @@ paths:
- asset_count
from: v_vulnerability_by_date_range
where:
=:
"=":
- asset_type
- $asset_type_param
group_by:
Expand Down
3 changes: 2 additions & 1 deletion scripts/validate_my_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import requests
from argparse import ArgumentParser
import glob
from almdrlib.client import _YamlOrderedLoader

OPENAPI_SCHEMA_URL = 'https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/schemas/v3.0/schema.json'

Expand All @@ -17,7 +18,7 @@ def validate_definition(definition_file):
spec = f.read()
if spec:
try:
obj = yaml.load(spec, Loader=yaml.SafeLoader)
obj = yaml.load(spec, Loader=_YamlOrderedLoader)
jsonschema.validate(obj, schema)
except YAMLError as e:
print(f"Validation has failed - failed to load YAML {e}")
Expand Down
2 changes: 1 addition & 1 deletion scripts/validate_my_definition.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fi

if $PYTHON -m venv $TEMP; then
source $TEMP/bin/activate
pip3 install requests jsonschema PyYaml
pip3 install requests jsonschema PyYaml alertlogic-sdk-python
curl https://raw.githubusercontent.com/alertlogic/alertlogic-sdk-definitions/master/scripts/validate_my_definition.py -o $TEMP/validate_my_definition.py
if [ $# -eq 0 ]
then
Expand Down
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
long_description=readme,
long_description_content_type='text/markdown',
scripts=[],
tests_require=['jsonschema', 'PyYaml', 'requests'],
# yeah yeah i know, circular dependency, but we need it for test now, later i'll think how to decouple
# definitions parsing/loading and client
tests_require=['jsonschema', 'PyYaml', 'requests', 'alertlogic-sdk-python'],
packages=find_packages(exclude=['contrib', 'docs', 'tests*', 'troubleshooting']),
include_package_data=True,
zip_safe=False,
Expand Down
4 changes: 2 additions & 2 deletions tests/test_apis_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import yaml
import unittest
import alsdkdefs

from almdrlib.client import _YamlOrderedLoader

OPENAPI_SCHEMA_URL = 'https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/schemas/v3.0/schema.json'

Expand All @@ -30,5 +30,5 @@ def test_validate_definitions(self):
print("Validating def", definition)
with open(definition, 'r') as f:
spec = f.read()
obj = yaml.load(spec, Loader=yaml.FullLoader)
obj = yaml.load(spec, Loader=_YamlOrderedLoader)
jsonschema.validate(obj, self.schema)
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ deps =
requests
PyYaml
jsonschema
alertlogic-sdk-python
setenv =
PYTHONPATH = {toxinidir}

Expand Down

0 comments on commit 4c103ed

Please sign in to comment.