Skip to content

Commit

Permalink
added /request-docs/config
Browse files Browse the repository at this point in the history
  • Loading branch information
kevincobain2000 committed Feb 12, 2024
1 parent 93a0606 commit d7cf031
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 5 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
}
],
"require": {
"php": "^7.4|^8.0|^8.1|^8.2",
"php": "^7.4|^8.0|^8.1|^8.2|^8.3",
"illuminate/contracts": "^8.37|^9.0|^10.0",
"kitloong/laravel-app-logger": "^1.0",
"spatie/laravel-package-tools": "^1.4.3",
Expand Down
3 changes: 3 additions & 0 deletions config/request-docs.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
],
// Can be overridden as // @LRDresponses 200|400|401
'default_responses' => [ "200", "400", "401", "403", "404", "405", "422", "429", "500", "503"],
'default_headers' => [
'Content-Type' => 'application/json',
],

// By default, LRD group your routes by the first /path.
// This is a set of regex to group your routes by prefix.
Expand Down
14 changes: 14 additions & 0 deletions src/Controllers/LaravelRequestDocsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,18 @@ public function assets(Request $request)
}
return response()->json(['error' => 'file not found'], 404);
}

/**
* @codeCoverageIgnore
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\JsonResponse
*/
public function config(Request $request)
{
$config = [
'default_responses' => config('request-docs.default_responses'),
'default_headers' => config('request-docs.default_headers'),
];
return response()->json($config);
}
}
4 changes: 4 additions & 0 deletions src/LaravelRequestDocsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ public function packageBooted()
->name('request-docs.api')
->middleware(config('request-docs.middlewares'));

Route::get("request-docs/config", [\Rakutentech\LaravelRequestDocs\Controllers\LaravelRequestDocsController::class, 'config'])
->name('request-docs.config')
->middleware(config('request-docs.middlewares'));

Route::get("request-docs/_astro/{slug}", [\Rakutentech\LaravelRequestDocs\Controllers\LaravelRequestDocsController::class, 'assets'])
// where slug is either js or css
->where('slug', '.*js|.*css|.*png|.*jpg|.*jpeg|.*gif|.*svg|.*ico|.*woff|.*woff2|.*ttf|.*eot|.*otf|.*map')
Expand Down
4 changes: 2 additions & 2 deletions ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ npm run dev

## 1) Mode: Readonly

**Open in Browser**
**Open in Browser**

http://localhost:3000/request-docs?api=http://localhost:3000/request-docs/sample.json
http://localhost:3000/request-docs/?api=http://localhost:3000/request-docs/sample.json


## 2) Mode: Developing with Laravel via npm
Expand Down
1 change: 1 addition & 0 deletions ui/astro.config.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { defineConfig } from 'astro/config'
import compress from 'astro-compress'
import react from '@astrojs/react'
import process from 'process'

import git from 'git-rev-sync'
const version = git.tag()
Expand Down
7 changes: 5 additions & 2 deletions ui/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"extends": "astro/tsconfigs/strict"
}
"extends": "astro/tsconfigs/strict",
"compilerOptions": {
"jsx": "react"
}
}

0 comments on commit d7cf031

Please sign in to comment.