From 7ae3dc50de6cefab727cea31440aff4a1d69ddef Mon Sep 17 00:00:00 2001 From: Martin Rademacher Date: Mon, 26 Aug 2024 17:03:30 +1200 Subject: [PATCH] Add more variations to request body scratch (#1640) --- tests/Fixtures/Scratch/RequestBody.php | 31 +++++++++++++++++--- tests/Fixtures/Scratch/RequestBody3.0.0.yaml | 24 ++++++++++++--- tests/Fixtures/Scratch/RequestBody3.1.0.yaml | 24 ++++++++++++--- 3 files changed, 67 insertions(+), 12 deletions(-) diff --git a/tests/Fixtures/Scratch/RequestBody.php b/tests/Fixtures/Scratch/RequestBody.php index 95515ca1..316f6f51 100644 --- a/tests/Fixtures/Scratch/RequestBody.php +++ b/tests/Fixtures/Scratch/RequestBody.php @@ -8,6 +8,11 @@ use OpenApi\Attributes as OAT; +#[OAT\Schema] +class RequestBodySchema +{ +} + #[OAT\RequestBody()] class RequestBodyRef { @@ -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: [ @@ -36,7 +59,7 @@ class RequestBodyController ), ] )] - public function post() + public function postSchemaRef() { } diff --git a/tests/Fixtures/Scratch/RequestBody3.0.0.yaml b/tests/Fixtures/Scratch/RequestBody3.0.0.yaml index 04151991..72473223 100644 --- a/tests/Fixtures/Scratch/RequestBody3.0.0.yaml +++ b/tests/Fixtures/Scratch/RequestBody3.0.0.yaml @@ -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' @@ -30,6 +44,8 @@ paths: '200': description: 'All good' components: + schemas: + RequestBodySchema: { } requestBodies: RequestBodyRef: { } foo: { } diff --git a/tests/Fixtures/Scratch/RequestBody3.1.0.yaml b/tests/Fixtures/Scratch/RequestBody3.1.0.yaml index 0b959744..7f2ae181 100644 --- a/tests/Fixtures/Scratch/RequestBody3.1.0.yaml +++ b/tests/Fixtures/Scratch/RequestBody3.1.0.yaml @@ -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' @@ -30,6 +44,8 @@ paths: '200': description: 'All good' components: + schemas: + RequestBodySchema: { } requestBodies: RequestBodyRef: { } foo: { }