-
Notifications
You must be signed in to change notification settings - Fork 24
regex to support alt application/*json types #284
Conversation
Codecov Report
@@ Coverage Diff @@
## master #284 +/- ##
========================================
- Coverage 98.7% 98.5% -0.2%
========================================
Files 7 7
Lines 474 480 +6
Branches 77 80 +3
========================================
+ Hits 468 473 +5
Misses 4 4
- Partials 2 3 +1
|
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.
Would you mind adding a test for this, to ensure no one accidentally breaks it in the future?
And just have one quick question about the logic 🙂
if use_regex: | ||
compiled_pattern = re.compile(key) | ||
for key_ in schema.keys(): | ||
if compiled_pattern.match(key_): | ||
return schema[key_] |
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.
Why are we iterating over key in schema.keys()
here instead of just doing this?
if compiled_pattern.match(key):
return schema[key_]
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.
This is to find a str match in the schema list.
For example schema.keys()
in one instance has dict_keys(['application/xml', 'application/json'])
and in this case key_
will return schema["application/json"]
as opposed to schema["^application\/.*json$"]
(which will break).
Absolutely - I was trying to understand how to add a test for this and was unsure where to add a test and what additional files are needed. |
Yes you could add a new schema file, or identify a way to run the (previously) failing code directly and send in a partial schema as a dict. You should be able to test The ideal thing, if you're comfortable with git rebasing, would be to:
But don't worry about that if you're not sure how to do it 👍 |
dd49a0d
to
f1101c1
Compare
f1101c1
to
d05bf91
Compare
To avoid this, I tried moving the import under this TYPE_CHECKING conditional as suggested.
But this didn't fix, and then suggested I move it out of this block :) ? Hopefully, we can get this PR with updated tests through soon 👍 |
This looks good @darduf, let's try it out 👍 I'll fix the linting error |
Yes, sorry about that 🙇 I'm flying this evening to visit family over the weekend, so I will not be free to fix this until Monday most likely. If you want to create a new PR with a fix, I will make the time to merge and release a new version, but if not I'll try to get this done then, and look at whatever other issues/PRs are remaining |
So create a new PR with the exact same fix as this PR? |
Ive created a new PR - with an initial commit showing the failing test on |
In relation to this issue - where schema tester was failing with an
UndocumentedSchemaSectionError
on our OAS defintitions that hadapplication/vnd.api+json
content types.