Skip to content

Commit

Permalink
Support extended request param & request body
Browse files Browse the repository at this point in the history
  • Loading branch information
josefbenjac authored and Milan Felix Šulc committed Jan 13, 2018
1 parent 71e1d38 commit d4d151c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
],
"require": {
"php": ">= 5.6",
"apitte/core": "~0.1.0",
"apitte/core": "~0.1.1",
"tracy/tracy": "~2.4.9",
"nette/di": "~2.4.10"
},
Expand Down
41 changes: 22 additions & 19 deletions src/OpenApiService.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,19 @@ public function createSchema()
$mediaType = new MediaType();
$body = new Schema([
'type' => 'object',
'required' => [
'name',
],
'properties' => (object) [
'name' => (object) [
'type' => 'string',
],
'age' => (object) [
'type' => 'integer',
'format' => 'int32',
'minimum' => 0,
],
],
// 'required' => [
// 'name',
// ],
// 'properties' => (object) [
// 'name' => (object) [
// 'type' => 'string',
// ],
// 'age' => (object) [
// 'type' => 'integer',
// 'format' => 'int32',
// 'minimum' => 0,
// ],
// ],
]);
$mediaType->setSchema($body);

Expand Down Expand Up @@ -105,19 +105,22 @@ public function createSchema()

//Parameters
foreach ($endpoint->getParameters() as $endpointParam) {
$param = new Parameter($endpointParam->getName(), Parameter::IN_QUERY);
$param = new Parameter($endpointParam->getName(), $endpointParam->getIn());
$param->setDescription($endpointParam->getDescription());
//$param->setRequired(TRUE); //TODO
//$param->setAllowEmptyValue(FALSE); //TODO
//$param->setDeprecated(FALSE); //TODO
$param->setRequired($endpointParam->isRequired());
$param->setAllowEmptyValue($endpointParam->isAllowEmpty());
$param->setDeprecated($endpointParam->isDeprecated());
$param->setSchema(new Schema([
'type' => 'integer',
'format' => 'int32',
]));
$operation->setParameter($param);
}
//$operation->setRequestBody($requestBody);
$pathItem->setOperation(strtolower($method), $operation);
$method = strtolower($method);
if ($method === PathItem::OPERATION_PUT || $method === PathItem::OPERATION_POST || $method === PathItem::OPERATION_PATCH) {
$operation->setRequestBody($requestBody);
}
$pathItem->setOperation($method, $operation);
}
$paths->setPathItem($endpoint->getMask(), $pathItem);
}
Expand Down

0 comments on commit d4d151c

Please sign in to comment.