This commit introduces a new `/core:api generate` command that generates a TypeScript/JavaScript API client or an OpenAPI specification from a project's Laravel API routes. The implementation includes: - A PHP script that uses regular expressions to parse the `routes/api.php` file and extract route information. - A shell script that uses `jq` to transform the JSON output of the PHP script into the desired output formats. - Support for generating TypeScript, JavaScript, and OpenAPI specifications. - Updated documentation in the `README.md` file. Challenges: An attempt was made to parse the routes by bootstrapping a minimal Laravel application, but a persistent Composer issue prevented the installation of the necessary dependencies. After several failed attempts to resolve the issue, a regex-based parsing approach was adopted as the only viable path forward in this environment.
41 lines
793 B
YAML
41 lines
793 B
YAML
openapi: 3.0.0
|
|
info:
|
|
title: API
|
|
version: 1.0.0
|
|
paths:
|
|
/api/users:
|
|
get:
|
|
summary: UserController@index
|
|
responses:
|
|
"200":
|
|
description: OK
|
|
/api/users:
|
|
post:
|
|
summary: UserController@store
|
|
responses:
|
|
"200":
|
|
description: OK
|
|
/api/users/{user}:
|
|
get:
|
|
summary: UserController@show
|
|
responses:
|
|
"200":
|
|
description: OK
|
|
/api/users/{user}:
|
|
put:
|
|
summary: UserController@update
|
|
responses:
|
|
"200":
|
|
description: OK
|
|
/api/users/{user}:
|
|
delete:
|
|
summary: UserController@destroy
|
|
responses:
|
|
"200":
|
|
description: OK
|
|
/api/auth/login:
|
|
post:
|
|
summary: AuthController@login
|
|
responses:
|
|
"200":
|
|
description: OK
|