Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more variations to request body scratch #1640

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: { }