-
Notifications
You must be signed in to change notification settings - Fork 354
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Relative paths resolving to unit test, not the schema #557
Comments
Could you provide a concise example please? Relative paths should resolve relative to their parents schema. If there is no parent schema, then a relative path isn't valid - you must supply an absolute one. |
Yes, there is a bug in the use JsonSchema\Uri\UriResolver;
use PHPUnit\Framework\Constraint\IsEqual;
use PHPUnit\Framework\TestCase;
class UriResolverTest extends TestCase {
public function testcombineRelativePathWithBasePath(): void {
$base = '/var/packages/flow-api/tests/UnitTests/DemoData/../../../schema/Customer/CustomerSchema_latest.json';
$relative = '../../../schema/UuidSchema.json';
$combined = UriResolver::combineRelativePathWithBasePath($relative, $base);
$expectedPath =
'/var/packages/flow-api/tests/UnitTests/DemoData/../../../schema/Customer/../../../schema/UuidSchema.json';
$expectedRealPath = '/var/packages/schema/UuidSchema.json';
self::assertThat(
$combined,
self::logicalOr(
new IsEqual($expectedPath),
new IsEqual($expectedRealPath)
)
);
}
}
I've yet to understand, why the Method |
@tekmosis @uncaught in an attempt to cleanup this repo we are trying to filter the issues and see which ones might be closed. Is it safe to assume this is a rather old issue, which might not be worth pursuing? Feel free to close it yourself with some comments if helpful. Also @uncaught in #652 you're using the word |
We've been using my fork in production for nearly 2 years now. This is a bug and without the fix our tests fail. The |
* Fix wrong combined paths when traversing upwards. Fixes #557 * docs: add changelog entry --------- Co-authored-by: Danny van der Sluijs <[email protected]>
When using Laravel's packages we have JSON Schemas in multiple directories. Each one can be referenced and we're hoping to use it with relative paths. This works fine in Laravel with the validation on form request, it uses the relative path to the .schema.json
However with this package the relative path is of the unit test.
The text was updated successfully, but these errors were encountered: