1616use OpenApiGenerator \Attributes \PropertyInterface ;
1717use OpenApiGenerator \Attributes \PropertyItems ;
1818use OpenApiGenerator \Attributes \PUT ;
19- use OpenApiGenerator \Attributes \RefProperty ;
2019use OpenApiGenerator \Attributes \RequestBody ;
2120use OpenApiGenerator \Attributes \Response ;
2221use OpenApiGenerator \Attributes \Route ;
@@ -113,8 +112,7 @@ public function append(ReflectionClass $reflectionClass): void
113112
114113 /**
115114 * OPAG supports Symfony Request class. This method will build the RequestBody from the Symfony Request class
116- *
117- * @throws ReflectionException|IllegalFieldException
115+ * The request object will be added as a reference to the RequestBody
118116 */
119117 private function buildRequestBodyFromSymfonyRequest (ReflectionMethod $ method ): ?RequestBody
120118 {
@@ -133,22 +131,12 @@ private function buildRequestBodyFromSymfonyRequest(ReflectionMethod $method): ?
133131 return null ;
134132 }
135133
136- // Get the Schema attribute from the Symfony Request class
137- $ requestReflection = new ReflectionClass ($ requestClass ->getType ()->getName ());
138- $ schemaAttributes = $ requestReflection ->getAttributes (Schema::class);
139- $ schemaAttribute = reset ($ schemaAttributes );
140- if (!$ schemaAttribute ) {
141- return null ;
142- }
143-
144- // Build the schema
145- $ schema = $ schemaAttribute ->newInstance ();
146- $ builder = new SchemaBuilder (false );
147- $ builder ->addSchema ($ schema , $ requestClass ->getType ()->getName ());
148- $ builder ->addProperty (new RefProperty ($ schema ->getName ()));
149-
150- // Set the schema to the RequestBody and return it
151- $ requestBody ->setSchema ($ builder ->getComponent ());
134+ $ schema = new Schema ();
135+ $ schema ->setNoMedia (true );
136+ $ requestBody ->setSchema ($ schema );
137+ $ property = new RefProperty ($ requestClass ->getType ()->getName ());
138+ $ property ->setComponentRoutePrefix ("#/components/requestBodies/ " );
139+ $ requestBody ->addProperty ($ property );
152140
153141 return $ requestBody ;
154142 }
0 commit comments