PHPackages                             horat1us/yii2-model-schema - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. horat1us/yii2-model-schema

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

horat1us/yii2-model-schema
==========================

JSON Schema for Yii2 Model using validation rules

2.0.0(2mo ago)1879[1 PRs](https://github.com/Horat1us/yii2-model-schema/pulls)1MITPHPPHP &gt;=8.4CI passing

Since Feb 14Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/Horat1us/yii2-model-schema)[ Packagist](https://packagist.org/packages/horat1us/yii2-model-schema)[ RSS](/packages/horat1us-yii2-model-schema/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (1)Dependencies (5)Versions (17)Used By (1)

Yii2 Model Schema
=================

[](#yii2-model-schema)

[![Latest Stable Version](https://camo.githubusercontent.com/0c965e20e178a6175ffe6b2dce5b2db83b606037664fc2c7ed526e84b6fe82da/68747470733a2f2f706f7365722e707567782e6f72672f686f7261743175732f796969322d6d6f64656c2d736368656d612f76657273696f6e)](https://packagist.org/packages/horat1us/yii2-model-schema)[![Total Downloads](https://camo.githubusercontent.com/da4e0455d66b3d3d83f4a9a65fe9502576fe0e6836b4e821ee51807b5b4ec185/68747470733a2f2f706f7365722e707567782e6f72672f686f7261743175732f796969322d6d6f64656c2d736368656d612f646f776e6c6f616473)](https://packagist.org/packages/horat1us/yii2-model-schema)[![CI](https://github.com/Horat1us/yii2-model-schema/actions/workflows/ci.yml/badge.svg)](https://github.com/Horat1us/yii2-model-schema/actions/workflows/ci.yml)[![codecov](https://camo.githubusercontent.com/eabfba814da8f7c8be573bf718deb5a645b66eca236c1db64567fb4c5ba50d17/68747470733a2f2f636f6465636f762e696f2f67682f686f7261743175732f796969322d6d6f64656c2d736368656d612f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/horat1us/yii2-model-schema)

Create JSON Schema from Yii2 Model using validation rules and other public methods.

Installation
------------

[](#installation)

Using composer:

```
composer require horat1us/yii2-model-schema:^2.0
```

Usage
-----

[](#usage)

### [base\\Model](https://www.yiiframework.com/doc/api/2.0/yii-base-model) extensions

[](#basemodel-extensions)

Additional interfaces that will be used for generating JsonSchema, when they are implemented in model.

#### [AttributesExamples](./src/Model/AttributesExamples.php)

[](#attributesexamples)

Will be used to generate property [*examples*](https://json-schema.org/understanding-json-schema/reference/generic.html?highlight=examples)

*See [AttributesExamplesTrait](./src/Model/AttributesExamplesTrait.php) for implementation**Since [1.1.0](https://github.com/Horat1us/yii2-model-schema/tree/1.0.3)*

```
