Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 394a85ef45 |
@ -7,6 +7,9 @@ The project also generates frontend clients:
|
||||
- JavaScript client: `format=javascript` (`.js`)
|
||||
- TypeScript client: `format=typescript` (`.ts`, real typed output)
|
||||
|
||||
The HTML help page is also interactive:
|
||||
- HTML help: `format=html` includes endpoint docs, a built-in request tester, and optional Bearer token support stored in browser `localStorage`
|
||||
|
||||
## Core files
|
||||
- `src/APIlite.php`: runtime, routing, docs JSON/HTML/client generation
|
||||
- `src/help.tpl.php`: HTML documentation template
|
||||
@ -19,7 +22,9 @@ The project also generates frontend clients:
|
||||
- Maintain both generated clients:
|
||||
- JavaScript stays plain JS.
|
||||
- TypeScript stays typed (interfaces + typed method signatures).
|
||||
- Keep the HTML help page usable both as documentation and as a lightweight in-browser tester.
|
||||
- If you change output field names in JSON help, update README and templates consistently.
|
||||
- If you change request metadata or tester behavior, update `README.md` and keep `src/help.tpl.php` aligned with the actual runtime request model.
|
||||
- Prefer small, focused changes over broad rewrites.
|
||||
|
||||
## Verification checklist
|
||||
@ -29,6 +34,8 @@ The project also generates frontend clients:
|
||||
- `php -l src/javascript.tpl.php`
|
||||
- `php -l src/typescript.tpl.php`
|
||||
- `php -l bin/apilite-files`
|
||||
- If HTML help changes, also render it once:
|
||||
- `php test/APIcalculator.php --html`
|
||||
- If client generation changes, test with:
|
||||
- `php test/APIcalculator.php --javascript`
|
||||
- `php test/APIcalculator.php --typescript`
|
||||
|
||||
13
README.md
13
README.md
@ -231,6 +231,8 @@ and there is also an HTML version available
|
||||
|
||||
<img src="test/Example.APIcalculator.png" />
|
||||
|
||||
The HTML documentation page also includes a built-in interactive tester. Each endpoint can be expanded with `Try it`, filled directly in the browser, and executed against the current API endpoint. If needed, you can set a shared Bearer token at the top of the page. The token is stored in `localStorage` and is sent as `Authorization: Bearer ...` for test requests made from that page.
|
||||
|
||||
You can also download generated frontend clients:
|
||||
|
||||
* JavaScript: `?format=javascript`
|
||||
@ -263,3 +265,14 @@ These outputs can also be generated in command line:
|
||||
* HTML: `$> php APIcalculator.php --html`
|
||||
* JavaScript: `$> php APIcalculator.php --javascript > backend.js` (`--js` alias is available)
|
||||
* TypeScript: `$> php APIcalculator.php --typescript > backend.ts`
|
||||
|
||||
## HTML help tester notes
|
||||
|
||||
The built-in HTML tester currently follows the default APIlite request model:
|
||||
|
||||
* request method is `POST`
|
||||
* endpoint action is sent as query parameter `action`
|
||||
* request fields are sent as top-level form fields
|
||||
* object and array field values are serialized as JSON strings
|
||||
|
||||
Because the current metadata does not explicitly distinguish path params, query params and request body schemas, the HTML tester renders the parts that are reliably available today and keeps the rest minimal.
|
||||
|
||||
1140
src/help.tpl.php
1140
src/help.tpl.php
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user