Skip to content

Commit 3c53e35

Browse files
committed
exclude http methods from openapi export condition added
1 parent 81ded4c commit 3c53e35

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

config/request-docs.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@
7171
//openapi 3.0.x doesn't support request body for develop operation
7272
//ref: https://github.com/OAI/OpenAPI-Specification/pull/2117
7373
'include_body_on_delete' => false,
74+
//exclude http methods that will be excluded from openapi export
75+
'exclude_http_methods' => [],
7476
// for now putting default responses for all. This can be changed later based on specific needs
7577
'responses' => [
7678
'200' => [

src/LaravelRequestDocsToOpenApi.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,18 @@ public function openApi(array $docs): LaravelRequestDocsToOpenApi
3333
private function docsToOpenApi(array $docs): void
3434
{
3535
$this->openApi['paths'] = [];
36-
$includeBodyForDelete = config('request-docs.open_api.include_body_on_delete');
36+
$includeBodyForDelete = config('request-docs.open_api.include_body_on_delete', false);
37+
$excludeHttpMethods = array_map(fn ($item) => strtolower($item), config('request-docs.open_api.exclude_http_methods', []));
38+
3739
foreach ($docs as $doc) {
38-
$requestHasFile = false;
40+
3941
$httpMethod = strtolower($doc->getHttpMethod());
42+
43+
if (in_array($httpMethod, $excludeHttpMethods)) {
44+
continue;
45+
}
46+
47+
$requestHasFile = false;
4048
$isGet = $httpMethod == 'get';
4149
$isPost = $httpMethod == 'post';
4250
$isPut = $httpMethod == 'put';

0 commit comments

Comments
 (0)