Skip to content
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

Draft: Wrong error message when using an undefined property for a schema object property definition #219

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions tests/IssueTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

class IssueTest extends \PHPUnit\Framework\TestCase
{
// https://github.com/cebe/php-openapi/issues/165
public function test165WrongErrorMessageWhenUsingAnUndefinedPropertyForASchemaObjectPropertyDefinition()
{
// $openapi = Reader::readFromYamlFile(__DIR__.'/data/issue/165/spec.yml');
// $openapi->performValidation();
// $this->assertTrue($openapi->getErrors());
// $this->assertTrue($openapi->validate());

// exec('echo hi', $output, $code);
exec('bin/php-openapi validate tests/data/issue/165/spec.yml 2>&1', $output, $code);
$this->assertSame($output, [
'OpenAPI v3.0 schema violations:',
'- [components.schemas.answer.properties.id] The property summary is not defined and the definition does not allow additional properties',
]);
// $this->assertSame(0, $code);
}
}
19 changes: 19 additions & 0 deletions tests/data/issue/165/spec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
openapi: 3.0.3
info:
title: Test
version: 0.1.0
paths:
/test:
get:
responses:
"200":
description: Test

components:
schemas:
answer:
type: object
properties:
id:
type: integer
summary: Unique answer ID
Loading