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
21 changes: 6 additions & 15 deletions src/OpenAPI/Builder/OpenAPIRequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,21 +91,12 @@ private function fromParameters(OpenAPIRequest $specification): array

private function findSchema(Parameter $parameter): Schema
{
$schemaLocations = null;
// Membrane\OpenAPIReader\Reader ensures parameters have a schema xor non-empty content
$schema = $parameter->schema ??
$parameter->content['application/json']?->schema ??
throw CannotProcessOpenAPI::unsupportedMediaTypes(array_keys($parameter->content));

if ($parameter->schema !== null) {
$schemaLocations = $parameter->schema;
}

if ($parameter->content !== []) {
$schemaLocations = $parameter->content['application/json']?->schema
??
throw CannotProcessOpenAPI::unsupportedMediaTypes(array_keys($parameter->content));
}

// Cebe library already validates that parameters MUST have either a schema or content but not both.
assert($schemaLocations instanceof Schema);

return $schemaLocations;
assert($schema instanceof Schema);
return $schema;
}
}
14 changes: 0 additions & 14 deletions tests/fixtures/OpenAPI/noReferences.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,20 +148,6 @@
}
},
"/requestpathexceptions": {
"get": {
"operationId": "no-schema-nor-content",
"parameters": [
{
"name": "id",
"in": "query"
}
],
"responses": {
"200": {
"description": ""
}
}
},
"post": {
"operationId": "unsupported-content-type",
"parameters": [
Expand Down