Skip to content

Commit a4167cb

Browse files
committed
ignore head methods by default
1 parent e9d2730 commit a4167cb

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

config/laravel-swagger.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,17 @@
3434
'produces' => [
3535
// 'application/json',
3636
],
37+
38+
/*
39+
|--------------------------------------------------------------------------
40+
| Ignore methods
41+
|--------------------------------------------------------------------------
42+
|
43+
| Methods in the following array will be ignored in the paths array
44+
|
45+
*/
46+
47+
'ignoredMethods' => [
48+
'head',
49+
],
3750
];

src/Generator.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ public function generate()
4343
foreach ($methods as $method) {
4444
$this->method = strtolower($method);
4545

46+
if (in_array($this->method, $this->config['ignoredMethods'])) continue;
47+
4648
$this->generatePath();
4749
}
4850
}

tests/GeneratorTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public function testHasPaths($docs)
5454
public function testPathData($paths)
5555
{
5656
$this->assertArrayHasKey('get', $paths['/users']);
57+
$this->assertArrayNotHasKey('head', $paths['/users']);
5758
$this->assertArrayHasKey('post', $paths['/users']);
5859

5960
$this->assertArrayHasKey('description', $paths['/users']['get']);
@@ -65,6 +66,15 @@ public function testPathData($paths)
6566
$this->assertArrayHasKey('parameters', $paths['/users']['post']);
6667
}
6768

69+
public function testOverwriteIgnoreMethods()
70+
{
71+
$this->config['ignoredMethods'] = [];
72+
73+
$docs = (new Generator($this->config))->generate();
74+
75+
$this->assertArrayHasKey('head', $docs['paths']['/users']);
76+
}
77+
6878
public function testOptionalData()
6979
{
7080
$optionalData = [

0 commit comments

Comments
 (0)