Debian Codegraph @

vendor/zircote/swagger-php/src/Attributes/JsonContent.php

raw
1 <?php declare(strict_types=1);
2
3 /**
4 * @license Apache 2.0
5 */
6
7 namespace OpenApi\Attributes;
8
9 use OpenApi\Annotations as OA;
10 use OpenApi\Generator;
11
12 /**
13 * Shorthand for a json response.
14 *
15 * Example:
16 * ```php
17 * #[OA\JsonContent(
18 * ref: '#/components/schemas/user'
19 * )]
20 * ```
21 * vs.
22 * ```php
23 * #[OA\MediaType(
24 * mediaType: 'application/json',
25 * schema: new OA\Schema(
26 * ref: '#/components/schemas/user'
27 * )
28 * )
29 * ```
30 *
31 * @Annotation
32 */
33 #[\Attribute(\Attribute::TARGET_CLASS)]
34 class JsonContent extends OA\JsonContent
35 {
36 /**
37 * @param list<Encoding> $encoding
38 * @param string|class-string|object|null $ref
39 * @param list<string> $required
40 * @param list<Property> $properties
41 * @param string|non-empty-array<string>|null $type
42 * @param array<Examples> $examples
43 * @param array<Schema|OA\Schema> $allOf
44 * @param array<Schema|OA\Schema> $anyOf
45 * @param array<Schema|OA\Schema> $oneOf
46 * @param list<string|int|float|bool|\UnitEnum|null>|class-string|null $enum
47 * @param array<string,mixed>|null $x
48 * @param list<Attachable>|null $attachables
49 */
50 public function __construct(
51 ?array $encoding = null,
52
53 // Schema
54 string|object|null $ref = null,
55 ?string $schema = null,
56 ?string $title = null,
57 ?string $description = Generator::UNDEFINED,
58 ?int $maxProperties = null,
59 ?int $minProperties = null,
60 ?array $required = null,
61 ?array $properties = null,
62 string|array|null $type = null,
63 ?string $format = null,
64 ?Items $items = null,
65 ?string $collectionFormat = null,
66 ?string $pattern = null,
67 ?Discriminator $discriminator = null,
68 ?bool $readOnly = null,
69 ?bool $writeOnly = null,
70 ?Xml $xml = null,
71 ?ExternalDocumentation $externalDocs = null,
72 mixed $example = Generator::UNDEFINED,
73 ?array $examples = null,
74 ?bool $nullable = null,
75 ?bool $deprecated = null,
76 ?array $allOf = null,
77 ?array $anyOf = null,
78 ?array $oneOf = null,
79 ?string $contentEncoding = null,
80 ?string $contentMediaType = null,
81
82 // JSON Schema
83 mixed $default = Generator::UNDEFINED,
84 int|float|null $maximum = null,
85 bool|int|float|null $exclusiveMaximum = null,
86 int|float|null $minimum = null,
87 bool|int|float|null $exclusiveMinimum = null,
88 int|null $maxLength = null,
89 int|null $minLength = null,
90 int|null $maxItems = null,
91 int|null $minItems = null,
92 bool|null $uniqueItems = null,
93 array|string|null $enum = null,
94 mixed $not = Generator::UNDEFINED,
95 bool|AdditionalProperties|null $additionalProperties = null,
96 array|null $additionalItems = null,
97 array|null $contains = null,
98 array|null $patternProperties = null,
99 array|null $unevaluatedProperties = null,
100 mixed $dependencies = Generator::UNDEFINED,
101 mixed $propertyNames = Generator::UNDEFINED,
102 mixed $const = Generator::UNDEFINED,
103
104 // abstract annotation
105 ?array $x = null,
106 ?array $attachables = null
107 ) {
108 parent::__construct([
109 // Schema
110 'ref' => $ref ?? Generator::UNDEFINED,
111 'schema' => $schema ?? Generator::UNDEFINED,
112 'title' => $title ?? Generator::UNDEFINED,
113 'description' => $description,
114 'maxProperties' => $maxProperties ?? Generator::UNDEFINED,
115 'minProperties' => $minProperties ?? Generator::UNDEFINED,
116 'required' => $required ?? Generator::UNDEFINED,
117 'properties' => $properties ?? Generator::UNDEFINED,
118 'type' => $type ?? Generator::UNDEFINED,
119 'format' => $format ?? Generator::UNDEFINED,
120 'collectionFormat' => $collectionFormat ?? Generator::UNDEFINED,
121 'pattern' => $pattern ?? Generator::UNDEFINED,
122 'readOnly' => $readOnly ?? Generator::UNDEFINED,
123 'writeOnly' => $writeOnly ?? Generator::UNDEFINED,
124 'xml' => $xml ?? Generator::UNDEFINED,
125 'example' => $example,
126 'nullable' => $nullable ?? Generator::UNDEFINED,
127 'deprecated' => $deprecated ?? Generator::UNDEFINED,
128 'allOf' => $allOf ?? Generator::UNDEFINED,
129 'anyOf' => $anyOf ?? Generator::UNDEFINED,
130 'oneOf' => $oneOf ?? Generator::UNDEFINED,
131 'contentEncoding' => $contentEncoding ?? Generator::UNDEFINED,
132 'contentMediaType' => $contentMediaType ?? Generator::UNDEFINED,
133
134 // JSON Schema
135 'default' => $default,
136 'maximum' => $maximum ?? Generator::UNDEFINED,
137 'exclusiveMaximum' => $exclusiveMaximum ?? Generator::UNDEFINED,
138 'minimum' => $minimum ?? Generator::UNDEFINED,
139 'exclusiveMinimum' => $exclusiveMinimum ?? Generator::UNDEFINED,
140 'maxLength' => $maxLength ?? Generator::UNDEFINED,
141 'minLength' => $minLength ?? Generator::UNDEFINED,
142 'maxItems' => $maxItems ?? Generator::UNDEFINED,
143 'minItems' => $minItems ?? Generator::UNDEFINED,
144 'uniqueItems' => $uniqueItems ?? Generator::UNDEFINED,
145 'enum' => $enum ?? Generator::UNDEFINED,
146 'not' => $not,
147 'additionalProperties' => $additionalProperties ?? Generator::UNDEFINED,
148 'additionalItems' => $additionalItems ?? Generator::UNDEFINED,
149 'contains' => $contains ?? Generator::UNDEFINED,
150 'patternProperties' => $patternProperties ?? Generator::UNDEFINED,
151 'unevaluatedProperties' => $unevaluatedProperties ?? Generator::UNDEFINED,
152 'dependencies' => $dependencies,
153 'propertyNames' => $propertyNames,
154 'const' => $const,
155
156 // abstract annotation
157 'x' => $x ?? Generator::UNDEFINED,
158 'attachables' => $attachables ?? Generator::UNDEFINED,
159 'value' => $this->combine($items, $discriminator, $externalDocs, $examples, $encoding),
160 ]);
161 }
162 }