Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Error when using primitive data type "file" #45

Closed
MasonM opened this issue Aug 31, 2017 · 1 comment
Closed

Error when using primitive data type "file" #45

MasonM opened this issue Aug 31, 2017 · 1 comment

Comments

@MasonM
Copy link
Contributor

MasonM commented Aug 31, 2017

The Swagger 2.0 spec supports having a Schema object with root type "file", which is an extension to JSON Schema:

As an extension to the Schema Object, its root type value may also be "file". This SHOULD be accompanied by a relevant produces mime-type.
https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#responseObject

Doing this results in an assertion failure with the message "is an invalid type for file". Here's a branch with a test case showing that: master...MasonM:bug-with-schema-file

Output on my machine:

$  ./vendor/bin/phpunit      
PHPUnit 6.2.4 by Sebastian Bergmann and contributors.

.E............................................................... 65 / 93 ( 69%)
............................                                      93 / 93 (100%)

Time: 93 ms, Memory: 10.00MB

There was 1 error:

1) FR3D\SwaggerAssertions\PhpUnit\AssertsTraitTest::testAssertResponseBodyMatchWithFile
JsonSchema\Exception\InvalidArgumentException: GIF89a,; is an invalid type for file

/Users/mmalone/src/SwaggerAssertions/vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/TypeConstraint.php:143
/Users/mmalone/src/SwaggerAssertions/vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/TypeConstraint.php:73
/Users/mmalone/src/SwaggerAssertions/vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/Constraint.php:201
/Users/mmalone/src/SwaggerAssertions/vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/UndefinedConstraint.php:130
/Users/mmalone/src/SwaggerAssertions/vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/UndefinedConstraint.php:36
/Users/mmalone/src/SwaggerAssertions/vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/Constraint.php:217
/Users/mmalone/src/SwaggerAssertions/vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/SchemaConstraint.php:29
/Users/mmalone/src/SwaggerAssertions/vendor/justinrainbow/json-schema/src/JsonSchema/Validator.php:36
/Users/mmalone/src/SwaggerAssertions/src/PhpUnit/JsonSchemaConstraint.php:41
/Users/mmalone/src/SwaggerAssertions/src/PhpUnit/AssertsTrait.php:37
/Users/mmalone/src/SwaggerAssertions/tests/PhpUnit/AssertsTraitTest.php:43

ERRORS!
Tests: 93, Assertions: 211, Errors: 1.
@Maks3w Maks3w closed this as completed in c4c3a67 Sep 3, 2017
@Maks3w
Copy link
Owner

Maks3w commented Sep 3, 2017

Done

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants