Skip to content
This repository has been archived by the owner on Feb 4, 2024. It is now read-only.

Add validation #7

Merged
merged 4 commits into from
Oct 16, 2017
Merged

Add validation #7

merged 4 commits into from
Oct 16, 2017

Conversation

allan-silva
Copy link
Member

This PR adds a validation feature.

Usage example:
spec_dict = SpecBuilder().add_spec("api.yml").validate()

@allan-silva allan-silva requested a review from a user August 5, 2017 02:42
@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling ce7d6ee on ex-Dev:validation into 99da164 on MicroarrayTecnologia:master.

@@ -8,4 +8,4 @@ def main():
spec = SpecBuilder()
for f in sys.argv[1:]:
spec.add_spec(f)
print(spec.dump(allow_unicode=True))
print(spec.validate().dump(allow_unicode=True))
Copy link

Choose a reason for hiding this comment

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

What does the output look like when validation fails?

Copy link
Member Author

Choose a reason for hiding this comment

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

The same as connexion, an exception from validator package:

image

@@ -49,3 +50,7 @@ def add_spec(self, file_name):

def dump(self, *args, **kwargs):
return yaml.safe_dump(dict(**self), *args, **kwargs)

def validate(self):
validate_spec(self)
Copy link

Choose a reason for hiding this comment

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

I see you've already filed #8. This brings up a good question though: how should support for different versions of the spec look like? If there will be separate classes, this is probably a fine way to do validation. If multiple versions of the spec need to be supported by this class, you may need to do something different here. That's not a question that needs answering before this can be merged, just something to keep in mind.

Copy link
Member Author

Choose a reason for hiding this comment

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

Researching to fix the mozilla-releng/balrog#360, I read a little of the new spec.
#8 will start with learning the new spec, because maybe https://swagger.io/specification/#referenceObject will kill spec-synthase :(

@allan-silva
Copy link
Member Author

I'm merging this for now. Feel free to ask more questions about validation.

@allan-silva allan-silva merged commit 9a0cfc8 into MicroarrayTecnologia:master Oct 16, 2017
@allan-silva allan-silva deleted the validation branch November 26, 2017 21:48
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants