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 pull request #31 from php-openapi/30-add-validation-rules-by-at…
…tribute-name-or-pattern Resolve: Add validation rules by attribute name or pattern #30
- Loading branch information
Showing
6 changed files
with
141 additions
and
7 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
14 changes: 14 additions & 0 deletions
14
tests/specs/issue_fix/30_add_validation_rules_by_attribute_name_or_pattern/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/30_add_validation_rules_by_attribute_name_or_pattern/index.yaml', | ||
'generateUrls' => false, | ||
'generateModels' => true, | ||
'excludeModels' => [ | ||
'Error', | ||
], | ||
'generateControllers' => false, | ||
'generateMigrations' => false, | ||
'generateModelFaker' => false, // `generateModels` must be `true` in order to use `generateModelFaker` as `true` | ||
]; | ||
|
45 changes: 45 additions & 0 deletions
45
tests/specs/issue_fix/30_add_validation_rules_by_attribute_name_or_pattern/index.yaml
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,45 @@ | ||
|
||
openapi: 3.0.3 | ||
|
||
info: | ||
title: Add validation rules by attribute name or pattern \#30 | ||
version: 1.0.0 | ||
|
||
components: | ||
schemas: | ||
User: | ||
type: object | ||
required: | ||
- id | ||
- name | ||
properties: | ||
id: | ||
type: integer | ||
readOnly: true | ||
name: | ||
description: name | ||
type: string | ||
maxLength: 128 | ||
photo: | ||
type: string | ||
format: binary | ||
profile_photo: | ||
type: string | ||
format: binary | ||
pdf: | ||
type: string | ||
format: binary | ||
a_file: | ||
type: string | ||
format: binary | ||
profile: | ||
type: string | ||
|
||
paths: | ||
'/': | ||
get: | ||
operationId: opId | ||
summary: summary | ||
responses: | ||
'200': | ||
description: OK |
10 changes: 10 additions & 0 deletions
10
...pecs/issue_fix/30_add_validation_rules_by_attribute_name_or_pattern/mysql/models/User.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 User extends \app\models\base\User | ||
{ | ||
|
||
|
||
} | ||
|
37 changes: 37 additions & 0 deletions
37
...issue_fix/30_add_validation_rules_by_attribute_name_or_pattern/mysql/models/base/User.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,37 @@ | ||
<?php | ||
|
||
namespace app\models\base; | ||
|
||
/** | ||
* | ||
* | ||
* @property int $id | ||
* @property string $name name | ||
* @property string $photo | ||
* @property string $profile_photo | ||
* @property string $pdf | ||
* @property string $a_file | ||
* @property string $profile | ||
* | ||
*/ | ||
abstract class User extends \yii\db\ActiveRecord | ||
{ | ||
public static function tableName() | ||
{ | ||
return '{{%users}}'; | ||
} | ||
|
||
public function rules() | ||
{ | ||
return [ | ||
'trim' => [['name', 'photo', 'profile_photo', 'pdf', 'a_file', 'profile'], 'trim'], | ||
'required' => [['name'], 'required'], | ||
'name_string' => [['name'], 'string', 'max' => 128], | ||
'photo_image' => [['photo'], 'image'], | ||
'profile_photo_image' => [['profile_photo'], 'image'], | ||
'pdf_file' => [['pdf'], 'file'], | ||
'a_file_file' => [['a_file'], 'file'], | ||
'profile_string' => [['profile'], 'string'], | ||
]; | ||
} | ||
} |
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