-
Notifications
You must be signed in to change notification settings - Fork 1
Add validation #7
Add validation #7
Conversation
@@ -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)) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 :(
I'm merging this for now. Feel free to ask more questions about validation. |
This PR adds a validation feature.
Usage example:
spec_dict = SpecBuilder().add_spec("api.yml").validate()