File tree Expand file tree Collapse file tree 5 files changed +68
-6
lines changed
Expand file tree Collapse file tree 5 files changed +68
-6
lines changed Original file line number Diff line number Diff line change @@ -70,6 +70,11 @@ public function __invoke(Analysis $analysis): void
7070 protected function augmentSchemaType (Analysis $ analysis , OA \Schema $ schema ): void
7171 {
7272 $ context = $ schema ->_context ;
73+
74+ if (null === $ context ->reflector || $ context ->is ('nested ' )) {
75+ return ;
76+ }
77+
7378 $ typeResolver = $ this ->generator ->getTypeResolver ();
7479 if (method_exists ($ typeResolver , 'setContext ' )) {
7580 $ typeResolver ->setContext ($ context );
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ public function __invoke(Analysis $analysis): void
2020 {
2121 // Auto-create the OpenApi annotation.
2222 if (!$ analysis ->openapi ) {
23- $ context = new Context ([], $ analysis ->context );
23+ $ context = new Context ([' generated ' => true ], $ analysis ->context );
2424 $ analysis ->addAnnotation (new OA \OpenApi (['_context ' => $ context ]), $ context );
2525 }
2626 $ openapi = $ analysis ->openapi ;
Original file line number Diff line number Diff line change 88
99use OpenApi \Attributes as OAT ;
1010
11+ #[OAT \Schema]
12+ class NestedSchemaOne
13+ {
14+ }
15+
16+ #[OAT \Schema]
17+ class NestedSchemaTwo
18+ {
19+ }
20+
1121#[OAT \Info(
1222 title: 'Parameter Content Scratch ' ,
1323 version: '1.0 '
1424)]
15- #[OAT \Get (
25+ #[OAT \Post (
1626 path: '/api/endpoint ' ,
27+ requestBody: new OAT \RequestBody (content: [new OAT \MediaType (
28+ mediaType: 'application/json ' ,
29+ schema: new OAT \Schema (
30+ required: ['note ' ],
31+ properties: [
32+ new OAT \Property (property: 'note ' , example: 'My note ' ),
33+ new OAT \Property (
34+ property: 'other ' ,
35+ description: 'other ' ,
36+ oneOf: [
37+ new OAT \Schema (type: NestedSchemaOne::class),
38+ new OAT \Schema (type: NestedSchemaTwo::class),
39+ ]
40+ ),
41+ ]
42+ )
43+ )]),
1744 responses: [new OAT \Response (response: 200 , description: 'OK ' )]
1845)]
1946#[OAT \Schema(
Original file line number Diff line number Diff line change 44 version : ' 1.0'
55paths :
66 /api/endpoint :
7- get :
8- operationId : b870e13084c8a89270151bb3e43f215a
7+ post :
8+ operationId : 4dcf657dcdcd504467bc7a4ac7d21084
9+ requestBody :
10+ content :
11+ application/json :
12+ schema :
13+ required :
14+ - note
15+ properties :
16+ note :
17+ example : ' My note'
18+ other :
19+ description : other
20+ oneOf : [{ $ref: '#/components/schemas/NestedSchemaOne' }, { $ref: '#/components/schemas/NestedSchemaTwo' }]
21+ type : object
922 responses :
1023 ' 200 ' :
1124 description : OK
1225components :
1326 schemas :
27+ NestedSchemaOne : { }
28+ NestedSchemaTwo : { }
1429 NestedSchema :
1530 required :
1631 - errors
Original file line number Diff line number Diff line change 44 version : ' 1.0'
55paths :
66 /api/endpoint :
7- get :
8- operationId : b870e13084c8a89270151bb3e43f215a
7+ post :
8+ operationId : 4dcf657dcdcd504467bc7a4ac7d21084
9+ requestBody :
10+ content :
11+ application/json :
12+ schema :
13+ required :
14+ - note
15+ properties :
16+ note :
17+ example : ' My note'
18+ other :
19+ description : other
20+ oneOf : [{ $ref: '#/components/schemas/NestedSchemaOne' }, { $ref: '#/components/schemas/NestedSchemaTwo' }]
21+ type : object
922 responses :
1023 ' 200 ' :
1124 description : OK
1225components :
1326 schemas :
27+ NestedSchemaOne : { }
28+ NestedSchemaTwo : { }
1429 NestedSchema :
1530 required :
1631 - errors
You can’t perform that action at this time.
0 commit comments