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/Services/SwaggerService.php
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ protected function saveObjectResponseDefinitions(array $content, array &$schemaP
$properties = Arr::get($this->data['definitions'], $definition, []);

foreach ($content as $name => $value) {
$property = Arr::get($properties, $name, []);
$property = Arr::get($properties, "properties.{$name}", []);

if (is_null($value)) {
$property['nullable'] = true;
Expand Down
21 changes: 21 additions & 0 deletions tests/SwaggerServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,27 @@ public function testAddDataWithPathParameters()
$service->addData($request, $response);
}

public function testAddDataWithTypeNameInResponse()
{
$this->mockDriverGetTpmData($this->getJsonFixture('tmp_data_get_user_request'));

$service = app(SwaggerService::class);

$request = $this->generateRequest('get', 'users/{id}/assign-role/{role-id}', [
'with' => ['role'],
'with_likes_count' => true
], [
'id' => 1,
'role-id' => 5
]);

$response = $this->generateResponse('example_success_user_response.json', 200, [
'Content-type' => 'application/json'
]);

$service->addData($request, $response);
}

public function testAddDataClosureRequest()
{
config(['auto-doc.security' => 'jwt']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
"role": {
"id": 2,
"name": "client"
}
},
"type": "reader"
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@
"role": {
"id": 2,
"name": "client"
}
},
"type": "reader"
},
"$ref": "#/definitions/getUsers{id}assignRole{roleId}200ResponseObject"
}
Expand Down Expand Up @@ -87,6 +88,9 @@
},
"role": {
"type": "array"
},
"type": {
"type": "string"
}
}
}
Expand Down
15 changes: 9 additions & 6 deletions tests/support/Traits/SwaggerServiceMockTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ protected function mockDriverGetEmptyAndSaveTpmData(
$tmpData,
$savedTmpData = null,
$driverClass = LocalDriver::class
) {
): void {
$driver = $this->mockClass($driverClass, ['getTmpData', 'saveTmpData']);

$driver
Expand All @@ -32,8 +32,11 @@ protected function mockDriverGetEmptyAndSaveTpmData(
$this->app->instance($driverClass, $driver);
}

protected function mockDriverGetPreparedAndSaveTpmData($getTmpData, $saveTmpData, $driverClass = LocalDriver::class)
{
protected function mockDriverGetPreparedAndSaveTpmData(
$getTmpData,
$saveTmpData,
$driverClass = LocalDriver::class
): void {
$driver = $this->mockClass($driverClass, ['getTmpData', 'saveTmpData']);

$driver
Expand All @@ -49,7 +52,7 @@ protected function mockDriverGetPreparedAndSaveTpmData($getTmpData, $saveTmpData
$this->app->instance($driverClass, $driver);
}

protected function mockDriverGetTpmData($tmpData, $driverClass = LocalDriver::class)
protected function mockDriverGetTpmData($tmpData, $driverClass = LocalDriver::class): void
{
$driver = $this->mockClass($driverClass, ['getTmpData']);

Expand All @@ -61,7 +64,7 @@ protected function mockDriverGetTpmData($tmpData, $driverClass = LocalDriver::cl
$this->app->instance($driverClass, $driver);
}

protected function mockDriverGetDocumentation($data, $driverClass = LocalDriver::class)
protected function mockDriverGetDocumentation($data, $driverClass = LocalDriver::class): void
{
$driver = $this->mockClass($driverClass, ['getDocumentation']);

Expand All @@ -73,7 +76,7 @@ protected function mockDriverGetDocumentation($data, $driverClass = LocalDriver:
$this->app->instance($driverClass, $driver);
}

protected function mockDriverSaveData($driverClass = LocalDriver::class)
protected function mockDriverSaveData($driverClass = LocalDriver::class): void
{
$driver = $this->mockClass($driverClass, ['saveData']);

Expand Down