diff --git a/src/Annotations/HeaderParameter.php b/src/Annotations/HeaderParameter.php index 439a2c01..6b946eab 100644 --- a/src/Annotations/HeaderParameter.php +++ b/src/Annotations/HeaderParameter.php @@ -6,6 +6,8 @@ namespace OpenApi\Annotations; +use OpenApi\Annotations as OA; + /** * A `@OA\Request` header parameter. * diff --git a/src/Annotations/JsonContent.php b/src/Annotations/JsonContent.php index 357db5ce..531e4ff7 100644 --- a/src/Annotations/JsonContent.php +++ b/src/Annotations/JsonContent.php @@ -7,6 +7,7 @@ namespace OpenApi\Annotations; use OpenApi\Generator; +use OpenApi\Annotations as OA; /** * Shorthand for a json response. diff --git a/src/Annotations/Operation.php b/src/Annotations/Operation.php index e4d1e9ac..bc089dc1 100644 --- a/src/Annotations/Operation.php +++ b/src/Annotations/Operation.php @@ -7,6 +7,7 @@ namespace OpenApi\Annotations; use OpenApi\Generator; +use OpenApi\Annotations as OA; /** * Base class for `@OA\Get`, `@OA\Post`, `@OA\Put`, etc. diff --git a/src/Annotations/PathParameter.php b/src/Annotations/PathParameter.php index 4e3d42c8..e8d15737 100644 --- a/src/Annotations/PathParameter.php +++ b/src/Annotations/PathParameter.php @@ -6,6 +6,8 @@ namespace OpenApi\Annotations; +use OpenApi\Annotations as OA; + /** * A `@OA\Request` path parameter. * diff --git a/src/Annotations/QueryParameter.php b/src/Annotations/QueryParameter.php index 6ee3e47f..311341a0 100644 --- a/src/Annotations/QueryParameter.php +++ b/src/Annotations/QueryParameter.php @@ -6,6 +6,8 @@ namespace OpenApi\Annotations; +use OpenApi\Annotations as OA; + /** * A `@OA\Request` query parameter. * diff --git a/src/Annotations/XmlContent.php b/src/Annotations/XmlContent.php index 59f76511..3c81bc30 100644 --- a/src/Annotations/XmlContent.php +++ b/src/Annotations/XmlContent.php @@ -7,6 +7,7 @@ namespace OpenApi\Annotations; use OpenApi\Generator; +use OpenApi\Annotations as OA; /** * Shorthand for a xml response. diff --git a/tests/Fixtures/Scratch/Examples.php b/tests/Fixtures/Scratch/Examples.php index f459c71f..36f040de 100644 --- a/tests/Fixtures/Scratch/Examples.php +++ b/tests/Fixtures/Scratch/Examples.php @@ -19,12 +19,16 @@ class ExampleSchema #[OAT\Get( path: '/endpoint/{name}/{other}', parameters: [ - new OAT\QueryParameter( + new OAT\PathParameter( name: 'name', + required: true, + schema: new OAT\Schema(type: 'string'), example: 'Fritz' ), - new OAT\QueryParameter( + new OAT\PathParameter( name: 'other', + required: true, + schema: new OAT\Schema(type: 'string'), examples: [ new OAT\Examples( example: 'o1', diff --git a/tests/Fixtures/Scratch/Examples.yaml b/tests/Fixtures/Scratch/Examples.yaml index 1d620518..8e220811 100644 --- a/tests/Fixtures/Scratch/Examples.yaml +++ b/tests/Fixtures/Scratch/Examples.yaml @@ -9,11 +9,17 @@ paths: parameters: - name: name - in: query + in: path + required: true + schema: + type: string example: Fritz - name: other - in: query + in: path + required: true + schema: + type: string examples: o1: summary: 'other example 1' diff --git a/tests/Fixtures/Scratch/UsingRefs.php b/tests/Fixtures/Scratch/UsingRefs.php index 33093a38..9e6d9a6c 100644 --- a/tests/Fixtures/Scratch/UsingRefs.php +++ b/tests/Fixtures/Scratch/UsingRefs.php @@ -8,7 +8,7 @@ use OpenApi\Attributes as OAT; -#[OAT\PathParameter(name: 'itemName', description: 'The item name')] +#[OAT\PathParameter(name: 'item_name', description: 'The item name', required: true, schema: new OAT\Schema(type: 'string'))] class UsingRefsParameter { } @@ -22,7 +22,7 @@ class UsingRefsResponse #[OAT\Get( path: '/item/{item_name}', parameters: [ - new OAT\Parameter(ref: '#/components/parameters/itemName'), + new OAT\Parameter(ref: '#/components/parameters/item_name'), ], responses: [ new OAT\Response(response: 200, ref: '#/components/responses/item'), diff --git a/tests/Fixtures/Scratch/UsingRefs.yaml b/tests/Fixtures/Scratch/UsingRefs.yaml index 71bbeb87..99cd107a 100644 --- a/tests/Fixtures/Scratch/UsingRefs.yaml +++ b/tests/Fixtures/Scratch/UsingRefs.yaml @@ -8,7 +8,7 @@ paths: operationId: 6ecb3788642c6ba8ce8d99cbcd554dbe parameters: - - $ref: '#/components/parameters/itemName' + $ref: '#/components/parameters/item_name' responses: '200': $ref: '#/components/responses/item' @@ -17,7 +17,10 @@ components: item: description: 'Item response' parameters: - itemName: - name: itemName + item_name: + name: item_name in: path description: 'The item name' + required: true + schema: + type: string diff --git a/tests/ScratchTest.php b/tests/ScratchTest.php index af9cb415..916a4490 100644 --- a/tests/ScratchTest.php +++ b/tests/ScratchTest.php @@ -45,7 +45,7 @@ public function testScratch(string $scratch, string $spec, array $expectedLog): $openapi = (new Generator($this->getTrackingLogger())) ->generate([$scratch]); - if (true || !file_exists($spec)) { + if (!file_exists($spec)) { file_put_contents($spec, $openapi->toYaml()); }