diff --git a/.github/workflows/nextjs.yml b/.github/workflows/nextjs.yml new file mode 100644 index 0000000..322116d --- /dev/null +++ b/.github/workflows/nextjs.yml @@ -0,0 +1,32 @@ +on: [push] + +name: "CI Node" + +jobs: + test: + name: Test + + runs-on: ubuntu-latest + + strategy: + matrix: + node-versions: [16, 18] + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-versions }} + + - name: NPM Install + working-directory: ./ui + run: npm install + + - name: Build, lint and export + working-directory: ./ui + run: npm run export + + + diff --git a/.github/workflows/phptest.yml b/.github/workflows/phptest.yml index a672354..39288bb 100644 --- a/.github/workflows/phptest.yml +++ b/.github/workflows/phptest.yml @@ -1,6 +1,6 @@ on: [push] -name: "CI" +name: "CI PHP" jobs: test: diff --git a/.gitignore b/.gitignore index 99e05e4..40f3206 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ node_modules .php-cs-fixer.cache .DS_Store _ide_helper.php +dist diff --git a/resources/dist/app.js b/resources/dist/app.js deleted file mode 100644 index 2a2392b..0000000 --- a/resources/dist/app.js +++ /dev/null @@ -1 +0,0 @@ -console.log("test") diff --git a/resources/views/index.blade.php b/resources/views/index.blade.php index 3dfb299..2e611dc 100644 --- a/resources/views/index.blade.php +++ b/resources/views/index.blade.php @@ -1,759 +1 @@ - - - - - - - {{ config('request-docs.document_name') }} - - - - - - - - - - - - - - - - - - - - - - - -
- -

-
-

- Routes List -

-
-
- @foreach ($docs as $index => $doc) -
-
-

- - {{$doc['methods'][0]}} - - - {{$doc['uri']}} - -

-
- @if (config('request-docs.show_development_metadata')) - - - - - - - - - - - - - - - - - - - @foreach ($doc['middlewares'] as $middleware) - - - - - @endforeach - -
HTTP Method{{$doc['httpMethod']}}
URL - @{{window.location.origin}}/{{$doc['uri']}} -
Controller{{$doc['controller_full_path']}}
Controller Method{{"@" .$doc['method']}}
Middleware {{ $loop->index + 1 }}{{$middleware}}
- @endif -
-

Description

-
- {!! $doc['docBlock'] !!} -
- @if (!empty($doc['rules'])) -
-

Attributes

-
- - - - - - - - - - - - - @foreach ($doc['rules'] as $attribute => $rules) - - - - - - - - - @endforeach - -
No.AttributesTypeNullableBailRules
{{$loop->index+1}} - {{$attribute}} - @foreach ($rules as $rule) - @if (str_contains($rule, 'required')) - *required - @endif - @endforeach - - @foreach ($rules as $rule) - @if (str_contains($rule, 'integer')) - Integer - @endif - @if (str_contains($rule, 'numeric')) - Numeric - @endif - @if (str_contains($rule, 'string')) - String - @endif - @if (str_contains($rule, 'json')) - JSON - @endif - @if (str_contains($rule, 'array')) - Array - @endif - @if (str_contains($rule, 'date')) - Date - @endif - @if (str_contains($rule, 'boolean')) - Boolean - @endif - @if (str_contains($rule, 'file') || str_contains($rule, 'image')) - File - @endif - @endforeach - - @foreach ($rules as $rule) - @if (str_contains($rule, 'nullable')) - Nullable - @endif - @endforeach - - @foreach ($rules as $rule) - @if (str_contains($rule, 'bail')) - Bail - @endif - @endforeach - -
- @foreach ($rules as $rule) - @foreach (explode('|', $rule) as $r) - @if (!in_array($r, ['required', 'integer', 'string', 'boolean', 'array', 'nullable', 'bail', 'file', 'image', 'numeric'])) - {{$r}} - @if (!$loop->last) - | - @endif - @endif - @endforeach - @endforeach -
-
-
- @endif - - - - - - -
-
-
-

REQUEST URL *required

-

Enter your request URL with query params

- -
- @if (!in_array('GET', $doc['methods'])) -

REQUEST BODY *required

-

JSON body for the POST|PUT|DELETE request

- - @endif -
-
-
-
-
-

- RESPONSE -

- Response status, code and time. -

-

- - - - - - - - - - - - - - - - - - - -
Status - - SUCCESS - - - ERROR - -
Status Code - - - - -
Memory Usage - - -
Response Time - - -
-

- Response headers. -

- -
-
-

Response from the server

- -
-
-

- SQL -

-

- No SQL queries executed for this request. -

-

- SQL queries executed for this request. - - - - - - - - - - - -
Total Queries -
-
Total Query time - - ms - -
-

-
-
-

- SQL queries -

-
-

@{{index+1}}. - - @{{query.time}}ms - -

- -
-
-
-
-
- @endforeach -
-
- - - +{{ include public_path() . '/vendor/rakutentech/laravel-request-docs/resources/dist/index.html'; }} diff --git a/src/Controllers/LaravelRequestDocsController.php b/src/Controllers/LaravelRequestDocsController.php index cc42156..a8872f1 100644 --- a/src/Controllers/LaravelRequestDocsController.php +++ b/src/Controllers/LaravelRequestDocsController.php @@ -32,6 +32,17 @@ public function index(Request $request) JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ); } + if ($request->json) { + return response()->json( + $docs, + Response::HTTP_OK, + [ + 'Content-type'=> 'application/json; charset=utf-8' + ], + JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE + ); + } + // nextjs static page rendered via blade return view('request-docs::index')->with(compact('docs')); } } diff --git a/ui/.eslintrc.json b/ui/.eslintrc.json new file mode 100644 index 0000000..dc98177 --- /dev/null +++ b/ui/.eslintrc.json @@ -0,0 +1,13 @@ +{ + "extends": [ + "next/core-web-vitals", + "plugin:react/recommended", + "plugin:react-hooks/recommended" + ], + "rules": { + "jsx-quotes": ["warn", "prefer-double"], + "quotes": ["warn", "double"], + "semi": ["warn", "never"], + "react/prop-types": ["error", { "ignore": ["children", "className"] }] + } +} diff --git a/ui/.gitignore b/ui/.gitignore new file mode 100644 index 0000000..c87c9b3 --- /dev/null +++ b/ui/.gitignore @@ -0,0 +1,36 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# dependencies +/node_modules +/.pnp +.pnp.js + +# testing +/coverage + +# next.js +/.next/ +/out/ + +# production +/build + +# misc +.DS_Store +*.pem + +# debug +npm-debug.log* +yarn-debug.log* +yarn-error.log* +.pnpm-debug.log* + +# local env files +.env*.local + +# vercel +.vercel + +# typescript +*.tsbuildinfo +next-env.d.ts diff --git a/ui/.vscode/settings.json b/ui/.vscode/settings.json new file mode 100644 index 0000000..d067910 --- /dev/null +++ b/ui/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "typescript.tsdk": "node_modules/typescript/lib", + "typescript.enablePromptUseWorkspaceTsdk": true +} \ No newline at end of file diff --git a/ui/README.md b/ui/README.md new file mode 100644 index 0000000..c87e042 --- /dev/null +++ b/ui/README.md @@ -0,0 +1,34 @@ +This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app). + +## Getting Started + +First, run the development server: + +```bash +npm run dev +# or +yarn dev +``` + +Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. + +You can start editing the page by modifying `pages/index.tsx`. The page auto-updates as you edit the file. + +[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.ts`. + +The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages. + +## Learn More + +To learn more about Next.js, take a look at the following resources: + +- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. +- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. + +You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome! + +## Deploy on Vercel + +The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. + +Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details. diff --git a/ui/app/error.tsx b/ui/app/error.tsx new file mode 100644 index 0000000..b9b4a0d --- /dev/null +++ b/ui/app/error.tsx @@ -0,0 +1,7 @@ +"use client" + +import React from "react" + +export default function Error() { + return

Error

+} \ No newline at end of file diff --git a/ui/app/head.tsx b/ui/app/head.tsx new file mode 100644 index 0000000..f9b8a7a --- /dev/null +++ b/ui/app/head.tsx @@ -0,0 +1,12 @@ +import Script from "next/script" +import React from "react" + +export default function Head({ params }: { params: { slug: string } }) { + return ( + <> + Laravel Request Docs + + {/*