Skip to content
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
2 changes: 1 addition & 1 deletion src/Routing/RouteLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ private function getRouteRequirementsForPathParameters(stdClass $operation, stdC
'|',
array_map(function ($value) {
return preg_quote($value, '/');
}, $parameter->enum)
}, $parameterSchema->enum)
)
);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
openapi: 3.0.0

info:
title: OpenAPI bundle enum path parameter test specification
version: 0.1.0

paths:
/pets/{status}:
get:
responses:
'200':
description: Returns a pet status.
parameters:
- name: status
in: path
required: true
schema:
type: string
enum:
- available
- pending
- sold
9 changes: 9 additions & 0 deletions tests/Routing/RouteLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,15 @@ public function testCanLoadRouteWithAdditionalRouteAttributesFromOpenapiBundleSp
static::assertSame('bar', $route->getDefault('foo'));
}

public function testCanLoadRouteWithEnumPathParameterRequirement(): void
{
$routes = $this->routeLoader->load('route-loader-enum-path-parameter.yaml', 'openapi');
$route = $routes->get('pets_status_get');

static::assertInstanceOf(Route::class, $route);
static::assertSame(['status' => '(available|pending|sold)'], $route->getRequirements());
}

private function createFileLocator(): FileLocator
{
return new FileLocator([
Expand Down
Loading