Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add minProperties/maxProperties to attributes #1376

Merged
merged 1 commit into from
Jan 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/reference/annotations.md
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ The example should match the specified schema and encoding properties if present
The example object is mutually exclusive of the examples object.<br />
Furthermore, if referencing a schema which contains an example, the example value shall override the example provided by the schema.<br />
To represent examples of media types that cannot naturally be represented in JSON or YAML, a string value can contain the example with escaping where necessary.</p></dd>
<dt><strong>content</strong> : <span style="font-family: monospace;">MediaType[]</span></dt>
<dt><strong>content</strong> : <span style="font-family: monospace;">array&lt;MediaType&gt;|JsonContent|XmlContent|Attachable</span></dt>
<dd><p>A map containing the representations for the parameter.<br />
<br />
The key is the media type and the value describes it.<br />
Expand Down
28 changes: 28 additions & 0 deletions docs/reference/attributes.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ In addition to this page, there are also a number of [examples](https://github.c
<dd><p>No details available.</p></dd>
<dt><strong>description</strong> : <span style="font-family: monospace;">string|null</span></dt>
<dd><p>No details available.</p></dd>
<dt><strong>maxProperties</strong> : <span style="font-family: monospace;">int|null</span></dt>
<dd><p>No details available.</p></dd>
<dt><strong>minProperties</strong> : <span style="font-family: monospace;">int|null</span></dt>
<dd><p>No details available.</p></dd>
<dt><strong>required</strong> : <span style="font-family: monospace;">string[]</span></dt>
<dd><p>No details available.</p></dd>
<dt><strong>properties</strong> : <span style="font-family: monospace;">Property[]</span></dt>
Expand Down Expand Up @@ -520,6 +524,10 @@ In addition to this page, there are also a number of [examples](https://github.c
<dd><p>No details available.</p></dd>
<dt><strong>description</strong> : <span style="font-family: monospace;">string|null</span></dt>
<dd><p>No details available.</p></dd>
<dt><strong>maxProperties</strong> : <span style="font-family: monospace;">int|null</span></dt>
<dd><p>No details available.</p></dd>
<dt><strong>minProperties</strong> : <span style="font-family: monospace;">int|null</span></dt>
<dd><p>No details available.</p></dd>
<dt><strong>required</strong> : <span style="font-family: monospace;">string[]</span></dt>
<dd><p>No details available.</p></dd>
<dt><strong>properties</strong> : <span style="font-family: monospace;">Property[]</span></dt>
Expand Down Expand Up @@ -607,6 +615,10 @@ In addition to this page, there are also a number of [examples](https://github.c
<dd><p>No details available.</p></dd>
<dt><strong>description</strong> : <span style="font-family: monospace;">string|null</span></dt>
<dd><p>No details available.</p></dd>
<dt><strong>maxProperties</strong> : <span style="font-family: monospace;">int|null</span></dt>
<dd><p>No details available.</p></dd>
<dt><strong>minProperties</strong> : <span style="font-family: monospace;">int|null</span></dt>
<dd><p>No details available.</p></dd>
<dt><strong>required</strong> : <span style="font-family: monospace;">string[]</span></dt>
<dd><p>No details available.</p></dd>
<dt><strong>properties</strong> : <span style="font-family: monospace;">Property[]</span></dt>
Expand Down Expand Up @@ -885,6 +897,8 @@ In addition to this page, there are also a number of [examples](https://github.c
<dd><p>No details available.</p></dd>
<dt><strong>examples</strong> : <span style="font-family: monospace;">array&lt;string,Examples&gt;</span></dt>
<dd><p>No details available.</p></dd>
<dt><strong>content</strong> : <span style="font-family: monospace;">array&lt;MediaType&gt;|JsonContent|XmlContent|Attachable|null</span></dt>
<dd><p>No details available.</p></dd>
<dt><strong>style</strong> : <span style="font-family: monospace;">string|null</span></dt>
<dd><p>No details available.</p></dd>
<dt><strong>explode</strong> : <span style="font-family: monospace;">bool|null</span></dt>
Expand Down Expand Up @@ -1014,6 +1028,8 @@ In addition to this page, there are also a number of [examples](https://github.c
<dd><p>No details available.</p></dd>
<dt><strong>examples</strong> : <span style="font-family: monospace;">array&lt;string,Examples&gt;</span></dt>
<dd><p>No details available.</p></dd>
<dt><strong>content</strong> : <span style="font-family: monospace;">array&lt;MediaType&gt;|JsonContent|XmlContent|Attachable|null</span></dt>
<dd><p>No details available.</p></dd>
<dt><strong>style</strong> : <span style="font-family: monospace;">string|null</span></dt>
<dd><p>No details available.</p></dd>
<dt><strong>explode</strong> : <span style="font-family: monospace;">bool|null</span></dt>
Expand Down Expand Up @@ -1102,6 +1118,10 @@ In addition to this page, there are also a number of [examples](https://github.c
<dd><p>No details available.</p></dd>
<dt><strong>description</strong> : <span style="font-family: monospace;">string|null</span></dt>
<dd><p>No details available.</p></dd>
<dt><strong>maxProperties</strong> : <span style="font-family: monospace;">int|null</span></dt>
<dd><p>No details available.</p></dd>
<dt><strong>minProperties</strong> : <span style="font-family: monospace;">int|null</span></dt>
<dd><p>No details available.</p></dd>
<dt><strong>required</strong> : <span style="font-family: monospace;">string[]</span></dt>
<dd><p>No details available.</p></dd>
<dt><strong>properties</strong> : <span style="font-family: monospace;">Property[]</span></dt>
Expand Down Expand Up @@ -1302,6 +1322,10 @@ In addition to this page, there are also a number of [examples](https://github.c
<dd><p>No details available.</p></dd>
<dt><strong>description</strong> : <span style="font-family: monospace;">string|null</span></dt>
<dd><p>No details available.</p></dd>
<dt><strong>maxProperties</strong> : <span style="font-family: monospace;">int|null</span></dt>
<dd><p>No details available.</p></dd>
<dt><strong>minProperties</strong> : <span style="font-family: monospace;">int|null</span></dt>
<dd><p>No details available.</p></dd>
<dt><strong>required</strong> : <span style="font-family: monospace;">string[]</span></dt>
<dd><p>No details available.</p></dd>
<dt><strong>properties</strong> : <span style="font-family: monospace;">Property[]</span></dt>
Expand Down Expand Up @@ -1595,6 +1619,10 @@ In addition to this page, there are also a number of [examples](https://github.c
<dd><p>No details available.</p></dd>
<dt><strong>description</strong> : <span style="font-family: monospace;">string|null</span></dt>
<dd><p>No details available.</p></dd>
<dt><strong>maxProperties</strong> : <span style="font-family: monospace;">int|null</span></dt>
<dd><p>No details available.</p></dd>
<dt><strong>minProperties</strong> : <span style="font-family: monospace;">int|null</span></dt>
<dd><p>No details available.</p></dd>
<dt><strong>required</strong> : <span style="font-family: monospace;">string[]</span></dt>
<dd><p>No details available.</p></dd>
<dt><strong>properties</strong> : <span style="font-family: monospace;">Property[]</span></dt>
Expand Down
10 changes: 6 additions & 4 deletions docs/reference/processors.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ Merge reusable annotation into @OA\Schemas.
## [ExpandClasses](https://github.com/zircote/swagger-php/tree/master/src/Processors/ExpandClasses.php)

Iterate over the chain of ancestors of a schema and:
- merge ancestor annotations/methods/properties into the schema if the ancestor doesn't have a schema itself
- inherit from the ancestor if it has a schema (allOf) and stop.
- if the ancestor has a schema
=> inherit from the ancestor if it has a schema (allOf) and stop.
- else
=> merge ancestor properties into the schema.
## [ExpandInterfaces](https://github.com/zircote/swagger-php/tree/master/src/Processors/ExpandInterfaces.php)

Look at all (direct) interfaces for a schema and:
Expand Down Expand Up @@ -53,7 +55,7 @@ Build the openapi->paths using the detected `@OA\PathItem` and `@OA\Operation` (
### Config settings
<dl>
<dt><strong>augmentParameters.augmentOperationParameters</strong> : <span style="font-family: monospace;">bool</span></dt>
<dd><p>If set to <code>true</code>, try to find operation parameter descriptions in the operation docblock.</p> </dd>
<dd><p>If set to <code>true</code> try to find operation parameter descriptions in the operation docblock.</p> </dd>
</dl>


Expand All @@ -72,7 +74,7 @@ Generate the OperationId based on the context of the OpenApi annotation.
### Config settings
<dl>
<dt><strong>operationId.hash</strong> : <span style="font-family: monospace;">bool</span></dt>
<dd><p>If set to <code>true</code>, generate ids (md5) instead of clear text operation ids.</p> </dd>
<dd><p>If set to <code>true</code> generate ids (md5) instead of clear text operation ids.</p> </dd>
</dl>


Expand Down
4 changes: 4 additions & 0 deletions src/Attributes/AdditionalProperties.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public function __construct(
?string $schema = null,
?string $title = null,
?string $description = null,
?int $maxProperties = null,
?int $minProperties = null,
?array $required = null,
?array $properties = null,
?string $type = null,
Expand Down Expand Up @@ -67,6 +69,8 @@ public function __construct(
'schema' => $schema ?? Generator::UNDEFINED,
'title' => $title ?? Generator::UNDEFINED,
'description' => $description ?? Generator::UNDEFINED,
'maxProperties' => $maxProperties ?? Generator::UNDEFINED,
'minProperties' => $minProperties ?? Generator::UNDEFINED,
'required' => $required ?? Generator::UNDEFINED,
'properties' => $properties ?? Generator::UNDEFINED,
'type' => $type ?? Generator::UNDEFINED,
Expand Down
4 changes: 4 additions & 0 deletions src/Attributes/Items.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public function __construct(
?string $schema = null,
?string $title = null,
?string $description = null,
?int $maxProperties = null,
?int $minProperties = null,
?array $required = null,
?array $properties = null,
?string $type = null,
Expand Down Expand Up @@ -69,6 +71,8 @@ public function __construct(
'schema' => $schema ?? Generator::UNDEFINED,
'title' => $title ?? Generator::UNDEFINED,
'description' => $description ?? Generator::UNDEFINED,
'maxProperties' => $maxProperties ?? Generator::UNDEFINED,
'minProperties' => $minProperties ?? Generator::UNDEFINED,
'required' => $required ?? Generator::UNDEFINED,
'properties' => $properties ?? Generator::UNDEFINED,
'type' => $type ?? Generator::UNDEFINED,
Expand Down
4 changes: 4 additions & 0 deletions src/Attributes/JsonContent.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public function __construct(
?string $schema = null,
?string $title = null,
?string $description = null,
?int $maxProperties = null,
?int $minProperties = null,
?array $required = null,
?array $properties = null,
?string $type = null,
Expand Down Expand Up @@ -72,6 +74,8 @@ public function __construct(
'schema' => $schema ?? Generator::UNDEFINED,
'title' => $title ?? Generator::UNDEFINED,
'description' => $description ?? Generator::UNDEFINED,
'maxProperties' => $maxProperties ?? Generator::UNDEFINED,
'minProperties' => $minProperties ?? Generator::UNDEFINED,
'required' => $required ?? Generator::UNDEFINED,
'properties' => $properties ?? Generator::UNDEFINED,
'type' => $type ?? Generator::UNDEFINED,
Expand Down
4 changes: 4 additions & 0 deletions src/Attributes/Property.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public function __construct(
?string $schema = null,
?string $title = null,
?string $description = null,
?int $maxProperties = null,
?int $minProperties = null,
?array $required = null,
?array $properties = null,
?string $type = null,
Expand Down Expand Up @@ -71,6 +73,8 @@ public function __construct(
'schema' => $schema ?? Generator::UNDEFINED,
'title' => $title ?? Generator::UNDEFINED,
'description' => $description ?? Generator::UNDEFINED,
'maxProperties' => $maxProperties ?? Generator::UNDEFINED,
'minProperties' => $minProperties ?? Generator::UNDEFINED,
'required' => $required ?? Generator::UNDEFINED,
'properties' => $properties ?? Generator::UNDEFINED,
'type' => $type ?? Generator::UNDEFINED,
Expand Down
4 changes: 4 additions & 0 deletions src/Attributes/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public function __construct(
?string $schema = null,
?string $title = null,
?string $description = null,
?int $maxProperties = null,
?int $minProperties = null,
?array $required = null,
?array $properties = null,
?string $type = null,
Expand Down Expand Up @@ -70,6 +72,8 @@ public function __construct(
'schema' => $schema ?? Generator::UNDEFINED,
'title' => $title ?? Generator::UNDEFINED,
'description' => $description ?? Generator::UNDEFINED,
'maxProperties' => $maxProperties ?? Generator::UNDEFINED,
'minProperties' => $minProperties ?? Generator::UNDEFINED,
'required' => $required ?? Generator::UNDEFINED,
'properties' => $properties ?? Generator::UNDEFINED,
'type' => $type ?? Generator::UNDEFINED,
Expand Down
4 changes: 4 additions & 0 deletions src/Attributes/XmlContent.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public function __construct(
?string $schema = null,
?string $title = null,
?string $description = null,
?int $maxProperties = null,
?int $minProperties = null,
?array $required = null,
?array $properties = null,
?string $type = null,
Expand Down Expand Up @@ -72,6 +74,8 @@ public function __construct(
'schema' => $schema ?? Generator::UNDEFINED,
'title' => $title ?? Generator::UNDEFINED,
'description' => $description ?? Generator::UNDEFINED,
'maxProperties' => $maxProperties ?? Generator::UNDEFINED,
'minProperties' => $minProperties ?? Generator::UNDEFINED,
'required' => $required ?? Generator::UNDEFINED,
'properties' => $properties ?? Generator::UNDEFINED,
'type' => $type ?? Generator::UNDEFINED,
Expand Down
2 changes: 1 addition & 1 deletion tests/Annotations/AttributesSyncTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
class AttributesSyncTest extends OpenApiTestCase
{
public static $SCHEMA_EXCLUSIONS = ['const', 'maxProperties', 'minProperties', 'multipleOf', 'not', 'additionalItems', 'contains', 'patternProperties', 'dependencies', 'propertyNames'];
public static $SCHEMA_EXCLUSIONS = ['const', 'multipleOf', 'not', 'additionalItems', 'contains', 'patternProperties', 'dependencies', 'propertyNames'];
public static $PATHITEM_EXCLUSIONS = ['ref', 'get', 'put', 'post', 'delete', 'options', 'head', 'patch', 'trace'];
public static $PARAMETER_EXCLUSIONS = ['matrix', 'label', 'form', 'simple', 'deepObject'];

Expand Down