1919use Astral \Serialize \OpenApi \Storage \OpenAPI \SchemaStorage ;
2020use Astral \Serialize \Resolvers \GroupResolver ;
2121use Astral \Serialize \Serialize ;
22- use Astral \Serialize \SerializeContainer ;
2322use Astral \Serialize \Support \Factories \ContextFactory ;
2423use Psr \SimpleCache \InvalidArgumentException ;
2524use ReflectionMethod ;
@@ -32,8 +31,8 @@ public function __construct(
3231 public string $ methodName ,
3332 public reflectionMethod $ reflectionMethod ,
3433 public Tag $ tag ,
35- public Summary $ summary ,
36- public Route $ route ,
34+ public Summary | null $ summary ,
35+ public Route | null $ route ,
3736 public Headers |null $ headers ,
3837 public array $ attributes ,
3938 public RequestBody |null $ requestBody ,
@@ -58,7 +57,7 @@ public function build(): Method
5857 $ requestBody = $ this ->buildRequestBody (
5958 className:$ this ->getRequestBodyClass (),
6059 contentType:$ this ->requestBody ->contentType ?? ContentTypeEnum::JSON ,
61- groups: $ this ->requestBody ->groups ?? []
60+ groups: $ this ->requestBody ->groups ?? []
6261 );
6362
6463 $ response = $ this ->buildResponse (
@@ -71,10 +70,9 @@ className:$this->getResponseClass(),
7170 return $ openAPIMethod ;
7271 }
7372
74-
7573 public function getRequestBodyClass (): string
7674 {
77- if ($ this ->requestBody ?->className){
75+ if ($ this ->requestBody ?->className) {
7876 return $ this ->requestBody ->className ;
7977 }
8078
@@ -88,12 +86,11 @@ public function getRequestBodyClass(): string
8886 return '' ;
8987 }
9088
91-
92- public function buildRequestBody (string $ className ,ContentTypeEnum $ contentType ,array $ groups = []): RequestBodyStorage
89+ public function buildRequestBody (string $ className , ContentTypeEnum $ contentType , array $ groups = []): RequestBodyStorage
9390 {
9491 $ openAPIRequestBody = new RequestBodyStorage ($ contentType );
9592 if (is_subclass_of ($ className , Serialize::class)) {
96- $ schemaStorage = (new SchemaStorage ())->build ($ this ->buildRequestParameterCollections ($ className ,$ groups ));
93+ $ schemaStorage = (new SchemaStorage ())->build ($ this ->buildRequestParameterCollections ($ className , $ groups ));
9794 $ openAPIRequestBody ->withParameter ($ schemaStorage );
9895 }
9996
@@ -102,7 +99,7 @@ public function buildRequestBody(string $className,ContentTypeEnum $contentType,
10299
103100 public function getResponseClass (): string
104101 {
105- if ($ this ->response ?->className){
102+ if ($ this ->response ?->className) {
106103 return $ this ->response ->className ;
107104 }
108105
@@ -118,18 +115,18 @@ public function getResponseClass(): string
118115 /**
119116 * @throws InvalidArgumentException
120117 */
121- public function buildResponse (string $ className ,array $ groups = []): ResponseStorage
118+ public function buildResponse (string $ className , array $ groups = []): ResponseStorage
122119 {
123120 $ responseStorage = new ResponseStorage ();
124121
125- $ baseResponse = Config::get ('response ' ,[]);
122+ $ baseResponse = Config::get ('response ' , []);
126123
127124 if ($ className ) {
128- $ schemaStorage = (new SchemaStorage ())->build ($ this ->buildResponseParameterCollections ($ className ,$ groups ));
125+ $ schemaStorage = (new SchemaStorage ())->build ($ this ->buildResponseParameterCollections ($ className , $ groups ));
129126 $ responseStorage ->withParameter ($ schemaStorage );
130127 }
131128
132- if ($ baseResponse ){
129+ if ($ baseResponse ) {
133130 $ responseStorage ->addGlobParameters ($ baseResponse );
134131 }
135132
@@ -148,13 +145,13 @@ public function buildRequestParameterCollections(string $className, array $group
148145 $ serializeContext = ContextFactory::build ($ className );
149146 $ serializeContext ->setGroups ($ groups )->from ();
150147 $ properties = $ serializeContext ->getGroupCollection ()->getProperties ();
151- $ groups = $ groups ?: [$ className ];
148+ $ groups = $ groups ?: [$ className ];
152149
153150 $ vols = [];
154151 foreach ($ properties as $ property ) {
155152
156153
157- if ($ property ->isInputIgnoreByGroups ($ groups ) || !$ this ->groupResolver ->resolveExistsGroupsByDataCollection ($ property , $ groups , $ className )){
154+ if ($ property ->isInputIgnoreByGroups ($ groups ) || !$ this ->groupResolver ->resolveExistsGroupsByDataCollection ($ property , $ groups , $ className )) {
158155 continue ;
159156 }
160157
@@ -192,12 +189,12 @@ public function buildResponseParameterCollections(string $className, array $grou
192189 $ serializeContext = ContextFactory::build ($ className );
193190 $ serializeContext ->from ();
194191 $ properties = $ serializeContext ->getGroupCollection ()->getProperties ();
195- $ groups = $ groups ?: [$ className ];
192+ $ groups = $ groups ?: [$ className ];
196193
197194 $ vols = [];
198195 foreach ($ properties as $ property ) {
199196
200- if ($ property ->isOutIgnoreByGroups ($ groups ) || !$ this ->groupResolver ->resolveExistsGroupsByDataCollection ($ property , $ groups , $ className )){
197+ if ($ property ->isOutIgnoreByGroups ($ groups ) || !$ this ->groupResolver ->resolveExistsGroupsByDataCollection ($ property , $ groups , $ className )) {
201198 continue ;
202199 }
203200
0 commit comments