Skip to content

Commit 626818b

Browse files
committed
Add failing test - WIP
1 parent 9232b45 commit 626818b

File tree

5 files changed

+62
-2
lines changed

5 files changed

+62
-2
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -779,4 +779,3 @@ Professional support, consulting as well as software development services are av
779779
https://www.cebe.cc/en/contact
780780

781781
Development of this library is sponsored by [cebe.:cloud: "Your Professional Deployment Platform"](https://cebe.cloud).
782-

src/lib/AttributeResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ protected function resolvePropertyRef(PropertySchema $property, Attribute $attri
498498
$attribute->setPhpType($fkProperty->guessPhpType())
499499
->setDbType($fkProperty->guessDbType(true))
500500
->setSize($fkProperty->getMaxLength())
501-
->setDescription($fkProperty->getAttr('description'))
501+
->setDescription($fkProperty->getAttr('description', ''))
502502
->setDefault($fkProperty->guessDefault())
503503
->setLimits($min, $max, $fkProperty->getMinLength());
504504
$this->attributes[$property->getName()] =
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
return [
4+
'openApiPath' => '@specs/issue_fix/74_invalid_schema_reference_error/index.yaml',
5+
'generateUrls' => true,
6+
'generateModels' => true,
7+
'excludeModels' => [
8+
'Error',
9+
],
10+
'generateControllers' => true,
11+
'generateMigrations' => true,
12+
'generateModelFaker' => true, // `generateModels` must be `true` in order to use `generateModelFaker` as `true`
13+
'ignoreSpecErrors' => true,
14+
];
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
openapi: "3.0.0"
2+
info:
3+
version: 1.0.0
4+
title: Invalid schema reference error \#74
5+
paths:
6+
/:
7+
get:
8+
responses:
9+
'200':
10+
description: The information
11+
12+
components:
13+
schemas:
14+
Invoice:
15+
type: object
16+
properties:
17+
id:
18+
type: integer
19+
vat_rate:
20+
$ref: '#/components/schemas/Product/properties/vat_rate'
21+
Product:
22+
type: object
23+
properties:
24+
id:
25+
type: integer
26+
vat_rate:
27+
type: string
28+
enum:
29+
- normal
30+
- none
31+
default: normal

tests/unit/IssueFixTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -962,4 +962,20 @@ public function test63JustColumnNameRename()
962962
$this->checkFiles($actualFiles, $expectedFiles);
963963
Yii::$app->db->createCommand('DROP TABLE IF EXISTS {{%fruits}}')->execute();
964964
}
965+
966+
// https://github.com/php-openapi/yii2-openapi/issues/63
967+
public function test74InvalidSchemaReferenceError()
968+
{
969+
$testFile = Yii::getAlias("@specs/issue_fix/74_invalid_schema_reference_error/index.php");
970+
971+
$this->runGenerator($testFile);
972+
// $this->runActualMigrations('mysql', 1);
973+
// $actualFiles = FileHelper::findFiles(Yii::getAlias('@app'), [
974+
// 'recursive' => true,
975+
// ]);
976+
// $expectedFiles = FileHelper::findFiles(Yii::getAlias("@specs/issue_fix/74_invalid_schema_reference_error/mysql"), [
977+
// 'recursive' => true,
978+
// ]);
979+
// $this->checkFiles($actualFiles, $expectedFiles);
980+
}
965981
}

0 commit comments

Comments
 (0)