Closed xeptore closed 6 months ago
Latest commit: f3ae8ef13afc52f4c6b33b0c5adddfea1b5bcf3a
The changes in this PR will be included in the next version bump.
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
Also, please add a patch changeset for both
core
andcli
packages describing the changes. Thanks!
Done in 82869150e676cf1d59d35e2f09cc6faf86027474.
P.S. Please don't forget to run prettier 🙂
Done in cf02cec879c8e9e557fae2f2f7093f802741da80.
Thank you @xeptore for spending your time on this! 👍
Thank you @xeptore for spending your time on this! 👍
Happy to help! Cheers
What/Why/How?
Currently, when an example object has
externalValue
propertyno-invalid-media-type-examples
lint rule fails as it is validating the example object (the parent object) against the schema definition.I could assume there are couple of ways to handle this case. However, as there is already another lint rule (
no-example-value-and-externalValue
), which is kind of related to this one, and its default severity level causes either one ofvalue
, orexternalValue
properties to exist for a specific example object, I decided to go with the simple exclusion condition, which basically deactivates the validation for example objects that hasexternalValue
set. I also intentionally didn't implement the logic to verify the specified URL set forexternalValue
to check whether the target resource actually matches the schema definition or not (by issuing HTTP request for example) as it's both complex to implement properly due to various cases including relative URLs, and for external resources being unpredictable by nature, e.g., the server might be unavailable at the time of linting, or returing a temporary failure due to network issues.Reference
I faced the issue while I was trying to add file examples for request, and response bodies of an API according to the official documentation (here).
Testing
Relevant tests are updated to cover this scenario.
Screenshots (optional)
It can be tested by disabling the condition I added to the lint rule.
Check yourself
Security