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
4 changes: 2 additions & 2 deletions features/json/input_output.feature
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Feature: JSON DTO input and output

@createSchema
Scenario: Request a password reset
And I send a "POST" request to "/users/password_reset_request" with body:
And I send a "POST" request to "/users_reset/password_reset_request" with body:
"""
{
"email": "user@example.com"
Expand All @@ -27,7 +27,7 @@ Feature: JSON DTO input and output

@createSchema
Scenario: Request a password reset for a non-existent user
And I send a "POST" request to "/users/password_reset_request" with body:
And I send a "POST" request to "/users_reset/password_reset_request" with body:
"""
{
"email": "does-not-exist@example.com"
Expand Down
4 changes: 3 additions & 1 deletion src/OpenApi/Factory/OpenApiFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -498,11 +498,13 @@ private function collectPaths(ApiResource $resource, ResourceMetadataCollection

private function buildOpenApiResponse(array $existingResponses, int|string $status, string $description, ?Operation $openapiOperation = null, ?HttpOperation $operation = null, ?array $responseMimeTypes = null, ?array $operationOutputSchemas = null, ?ResourceMetadataCollection $resourceMetadataCollection = null): Operation
{
$noOutput = \is_array($operation?->getOutput()) && null === $operation->getOutput()['class'];

if (isset($existingResponses[$status])) {
return $openapiOperation;
}
$responseLinks = $responseContent = null;
if ($responseMimeTypes && $operationOutputSchemas) {
if ($responseMimeTypes && $operationOutputSchemas && !$noOutput) {
$responseContent = $this->buildContent($responseMimeTypes, $operationOutputSchemas);
}
if ($resourceMetadataCollection && $operation) {
Expand Down
2 changes: 1 addition & 1 deletion src/State/Exception/ParameterNotSupportedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function getType(): string
return '/error/400';
}

public function getTitle(): ?string
public function getTitle(): string
{
return $this->message;
}
Expand Down
17 changes: 9 additions & 8 deletions tests/Fixtures/TestBundle/ApiResource/WithParameter.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,36 +96,37 @@
uriTemplate: 'validate_parameters{._format}',
parameters: [
'enum' => new QueryParameter(
schema: ['enum' => ['a', 'b'], 'uniqueItems' => true],
schema: ['enum' => ['a', 'b'], 'uniqueItems' => true, 'type' => 'array'],
castToArray: true,
openApi: new OpenApiParameter(name: 'enum', in: 'query', style: 'deepObject')
),
'enumNotDeepObject' => new QueryParameter(
schema: ['enum' => ['a', 'b'], 'uniqueItems' => true],
schema: ['enum' => ['a', 'b'], 'uniqueItems' => true, 'type' => 'string'],
castToArray: true,
castToNativeType: true,
),
'num' => new QueryParameter(
schema: ['minimum' => 1, 'maximum' => 3],
schema: ['minimum' => 1, 'maximum' => 3, 'type' => 'integer'],
nativeType: new BuiltinType(TypeIdentifier::STRING),
),
'numMultipleType' => new QueryParameter(
schema: ['minimum' => 1, 'maximum' => 3],
schema: ['minimum' => 1, 'maximum' => 3, 'type' => 'array'],
),
'exclusiveNum' => new QueryParameter(
schema: ['exclusiveMinimum' => 1, 'exclusiveMaximum' => 3],
schema: ['exclusiveMinimum' => 1, 'exclusiveMaximum' => 3, 'type' => 'integer'],
nativeType: new BuiltinType(TypeIdentifier::STRING),
),
'blank' => new QueryParameter(
openApi: new OpenApiParameter(name: 'blank', in: 'query', allowEmptyValue: false),
nativeType: new BuiltinType(TypeIdentifier::STRING),
),
'length' => new QueryParameter(
schema: ['maxLength' => 1, 'minLength' => 3],
schema: ['maxLength' => 1, 'minLength' => 3, 'type' => 'integer'],
nativeType: new BuiltinType(TypeIdentifier::STRING),
),
'array' => new QueryParameter(schema: ['minItems' => 2, 'maxItems' => 3]),
'array' => new QueryParameter(schema: ['minItems' => 2, 'maxItems' => 3, 'type' => 'integer']),
'multipleOf' => new QueryParameter(
schema: ['multipleOf' => 2],
schema: ['multipleOf' => 2, 'type' => 'integer'],
nativeType: new BuiltinType(TypeIdentifier::STRING),
),
'int' => new QueryParameter(
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/TestBundle/Entity/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
*/
#[ApiResource(operations: [
new Post(
uriTemplate: '/users/password_reset_request',
uriTemplate: '/users_reset/password_reset_request',
messenger: 'input',
input: PasswordResetRequest::class,
output: PasswordResetRequestResult::class,
Expand Down
3 changes: 0 additions & 3 deletions tests/Functional/Parameters/ValidationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ public static function provideQueryStrings(): array
[
'enumNotDeepObject[]=c&enumNotDeepObject[]=c',
[
[
'propertyPath' => 'enumNotDeepObject', 'message' => 'The value you selected is not a valid choice.',
],
[
'propertyPath' => 'enumNotDeepObject', 'message' => 'The value you selected is not a valid choice.',
],
Expand Down
Loading