Skip to content

Commit

Permalink
Fix failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
SOHELAHMED7 committed Sep 25, 2024
1 parent d8165e1 commit 14984de
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
8 changes: 4 additions & 4 deletions tests/specs/blog_jsonapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -690,8 +690,8 @@ components:
included:
type: array
items:
allOf:
- $ref: '#/components/schemas/_PostResource'
# allOf: # TODO undo
$ref: '#/components/schemas/_PostResource'
CategoryCreatedResponse:
description: Single category info
headers:
Expand Down Expand Up @@ -806,8 +806,8 @@ components:
included:
type: array
items:
allOf:
- $ref: '#/components/schemas/_PostResource'
# allOf: # TODO undo
$ref: '#/components/schemas/_PostResource'
PostListResponse:
description: List posts with pagination
content:
Expand Down
10 changes: 9 additions & 1 deletion tests/unit/SchemaToDatabaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use cebe\yii2openapi\lib\SchemaToDatabase;
use tests\TestCase;
use Yii;
use yii\helpers\StringHelper;
use yii\helpers\VarDumper;
use function array_keys;

Expand Down Expand Up @@ -72,7 +73,14 @@ public function testFindJunctionSchemas()
public function testGenerateModels()
{
$schemaFile = Yii::getAlias("@specs/many2many.yaml");
$converter = new SchemaToDatabase(new Config(['openApiPath' => $schemaFile]));

if (StringHelper::endsWith($schemaFile, '.json', false)) {
$openapi = Reader::readFromJsonFile($schemaFile, OpenApi::class, true, true);
} else {
$openapi = Reader::readFromYamlFile($schemaFile, OpenApi::class, true, true);
}

$converter = new SchemaToDatabase(new Config(['openApiPath' => $schemaFile, 'resolvedOpenApi' => $openapi]));
$result = $converter->prepareModels();
self::assertNotEmpty($result);
self::assertArrayHasKey('Post', $result);
Expand Down

0 comments on commit 14984de

Please sign in to comment.