Skip to content

Commit

Permalink
Add more variations to request body scratch (zircote#1640)
Browse files Browse the repository at this point in the history
  • Loading branch information
DerManoMann authored Aug 26, 2024
1 parent 08b48bb commit 7ae3dc5
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 12 deletions.
31 changes: 27 additions & 4 deletions tests/Fixtures/Scratch/RequestBody.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@

use OpenApi\Attributes as OAT;

#[OAT\Schema]
class RequestBodySchema
{
}

#[OAT\RequestBody()]
class RequestBodyRef
{
Expand All @@ -21,12 +26,30 @@ class RequestBodyRefFoo
#[OAT\Info(title: 'RequestBody', version: '1.0')]
class RequestBodyController
{
#[OAT\Get(
path: '/endpoint',
#[OAT\Post(
path: '/endpoint/schema-ref-json',
requestBody: new OAT\RequestBody(
description: 'Information about a new pet in the system',
content: new OAT\JsonContent(ref: RequestBodySchema::class),
),
responses: [
new OAT\Response(
response: 200,
description: 'All good'
),
]
)]
public function postSchemaRefJson()
{
}

#[OAT\Post(
path: '/endpoint/schema-ref',
requestBody: new OAT\RequestBody(
description: 'Information about a new pet in the system',
content: new OAT\MediaType(
mediaType: 'application/json'
mediaType: 'application/json',
schema: new OAT\Schema(ref: RequestBodySchema::class)
),
),
responses: [
Expand All @@ -36,7 +59,7 @@ class RequestBodyController
),
]
)]
public function post()
public function postSchemaRef()
{
}

Expand Down
24 changes: 20 additions & 4 deletions tests/Fixtures/Scratch/RequestBody3.0.0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,27 @@ info:
title: RequestBody
version: '1.0'
paths:
/endpoint:
get:
operationId: 30597cf43b480393042f6b01a9d7980c
/endpoint/schema-ref-json:
post:
operationId: 8d1f9c9f0437712695d337f1c11badc7
requestBody:
description: 'Information about a new pet in the system'
content:
application/json:
schema:
$ref: '#/components/schemas/RequestBodySchema'
responses:
'200':
description: 'All good'
/endpoint/schema-ref:
post:
operationId: 7fa3f3456b14a4a8eb3a0357283ecd15
requestBody:
description: 'Information about a new pet in the system'
content:
application/json: { }
application/json:
schema:
$ref: '#/components/schemas/RequestBodySchema'
responses:
'200':
description: 'All good'
Expand All @@ -30,6 +44,8 @@ paths:
'200':
description: 'All good'
components:
schemas:
RequestBodySchema: { }
requestBodies:
RequestBodyRef: { }
foo: { }
24 changes: 20 additions & 4 deletions tests/Fixtures/Scratch/RequestBody3.1.0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,27 @@ info:
title: RequestBody
version: '1.0'
paths:
/endpoint:
get:
operationId: 30597cf43b480393042f6b01a9d7980c
/endpoint/schema-ref-json:
post:
operationId: 8d1f9c9f0437712695d337f1c11badc7
requestBody:
description: 'Information about a new pet in the system'
content:
application/json:
schema:
$ref: '#/components/schemas/RequestBodySchema'
responses:
'200':
description: 'All good'
/endpoint/schema-ref:
post:
operationId: 7fa3f3456b14a4a8eb3a0357283ecd15
requestBody:
description: 'Information about a new pet in the system'
content:
application/json: { }
application/json:
schema:
$ref: '#/components/schemas/RequestBodySchema'
responses:
'200':
description: 'All good'
Expand All @@ -30,6 +44,8 @@ paths:
'200':
description: 'All good'
components:
schemas:
RequestBodySchema: { }
requestBodies:
RequestBodyRef: { }
foo: { }

0 comments on commit 7ae3dc5

Please sign in to comment.