forked from cebe/yii2-openapi
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge #56 remote-tracking branch 'php-openapi/52-bug-dependenton-allo…
…f-with-x-faker-false' * php-openapi/52-bug-dependenton-allof-with-x-faker-false: Fix test Fix failing tests Complete the implementation Complete the test Add test - WIP Implementation Create PR
- Loading branch information
Showing
22 changed files
with
654 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,7 +43,6 @@ public static function dependentOn() | |
{ | ||
return [ | ||
// just model class names | ||
'Invoice', | ||
|
||
]; | ||
} | ||
|
14 changes: 14 additions & 0 deletions
14
tests/specs/issue_fix/52_bug_dependenton_allof_with_x_faker_false/index.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
return [ | ||
'openApiPath' => '@specs/issue_fix/52_bug_dependenton_allof_with_x_faker_false/index.yml', | ||
'generateUrls' => false, | ||
'generateModels' => true, | ||
'excludeModels' => [ | ||
'Error', | ||
], | ||
'generateControllers' => false, | ||
'generateMigrations' => false, | ||
'generateModelFaker' => true, // `generateModels` must be `true` in order to use `generateModelFaker` as `true` | ||
]; | ||
|
64 changes: 64 additions & 0 deletions
64
tests/specs/issue_fix/52_bug_dependenton_allof_with_x_faker_false/index.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
openapi: 3.0.3 | ||
|
||
info: | ||
title: 'Bug: dependentOn: allOf with "x-faker: false" #52' | ||
version: 1.0.0 | ||
|
||
components: | ||
schemas: | ||
User: | ||
type: object | ||
properties: | ||
id: | ||
type: integer | ||
name: | ||
type: string | ||
Fruit: | ||
type: object | ||
properties: | ||
id: | ||
type: integer | ||
name: | ||
type: string | ||
Animal: | ||
type: object | ||
properties: | ||
id: | ||
type: integer | ||
name: | ||
type: string | ||
Invoice: | ||
title: Invoice | ||
x-table: invoices | ||
type: object | ||
properties: | ||
id: | ||
type: integer | ||
reference_invoice: | ||
allOf: | ||
- $ref: '#/components/schemas/Invoice' | ||
- x-faker: false | ||
- description: This field is only set on invoices of type "cancellation_invoice" | ||
reference_invoice_2: | ||
allOf: | ||
- $ref: '#/components/schemas/Invoice' | ||
- x-faker: true | ||
user: | ||
$ref: '#/components/schemas/User' | ||
user_2: | ||
allOf: | ||
- $ref: '#/components/schemas/User' | ||
- x-faker: false | ||
fruit: | ||
$ref: '#/components/schemas/Fruit' | ||
animal: | ||
allOf: | ||
- $ref: '#/components/schemas/Animal' | ||
- x-faker: false | ||
|
||
paths: | ||
'/': | ||
get: | ||
responses: | ||
'200': | ||
description: OK |
10 changes: 10 additions & 0 deletions
10
tests/specs/issue_fix/52_bug_dependenton_allof_with_x_faker_false/mysql/models/Animal.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace app\models; | ||
|
||
class Animal extends \app\models\base\Animal | ||
{ | ||
|
||
|
||
} | ||
|
41 changes: 41 additions & 0 deletions
41
.../specs/issue_fix/52_bug_dependenton_allof_with_x_faker_false/mysql/models/AnimalFaker.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
namespace app\models; | ||
|
||
use Faker\UniqueGenerator; | ||
|
||
/** | ||
* Fake data generator for Animal | ||
* @method static Animal makeOne($attributes = [], ?UniqueGenerator $uniqueFaker = null); | ||
* @method static Animal saveOne($attributes = [], ?UniqueGenerator $uniqueFaker = null); | ||
* @method static Animal[] make(int $number, $commonAttributes = [], ?UniqueGenerator $uniqueFaker = null) | ||
* @method static Animal[] save(int $number, $commonAttributes = [], ?UniqueGenerator $uniqueFaker = null) | ||
*/ | ||
class AnimalFaker extends BaseModelFaker | ||
{ | ||
|
||
/** | ||
* @param array|callable $attributes | ||
* @return Animal|\yii\db\ActiveRecord | ||
* @example | ||
* $model = (new PostFaker())->generateModels(['author_id' => 1]); | ||
* $model = (new PostFaker())->generateModels(function($model, $faker, $uniqueFaker) { | ||
* $model->scenario = 'create'; | ||
* $model->author_id = 1; | ||
* return $model; | ||
* }); | ||
**/ | ||
public function generateModel($attributes = []) | ||
{ | ||
$faker = $this->faker; | ||
$uniqueFaker = $this->uniqueFaker; | ||
$model = new Animal(); | ||
//$model->id = $uniqueFaker->numberBetween(0, 1000000); | ||
$model->name = $faker->sentence; | ||
if (!is_callable($attributes)) { | ||
$model->setAttributes($attributes, false); | ||
} else { | ||
$model = $attributes($model, $faker, $uniqueFaker); | ||
} | ||
return $model; | ||
} | ||
} |
Oops, something went wrong.