Skip to content

Commit

Permalink
Documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Sören committed Sep 21, 2022
1 parent fa08268 commit 8cf9276
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
28 changes: 17 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

Adapter that reads [OpenApi](https://spec.openapis.org) schema and add included routes to [Slim](https://www.slimframework.com).

Current version supports PHP `^7.4 || ^8.0`.
Current version supports PHP `^7.4 | ^8.0`.

## Installation

Expand Down Expand Up @@ -33,31 +33,37 @@ $openapi->route($slim);
## How to define controllers

In order for automatic mapping to work, the `operationId` must be set on all defined routes in OpenApi source.
The following definitions are supported;
* `Classname`
* `Namespace/Classname`
* `Namespace\\Classname`
* `Classname:httpMethod`
* `Namespace/Classname:httpMethod`
* `Namespace\\Classname:httpMethod`
If no method is specified, class method `::invoke()` will be called on class.

| With invoke | With method |
| --- | --- |
| `Classname` | `Classname:httpMethod` |
| `Namespace/Classname` | `Namespace/Classname:httpMethod` |
| `Namespace\\Classname` | `Namespace\\Classname:httpMethod` |

### Example

```json
{
"openapi": "3.0.0",
"info": {},
"paths": {
"/test": {
"get": {
"operationId": "Test/MyController",
"description": "Will invoke class Test\MyController"
"description": "Will invoke class Test\\MyController"
},
"put": {
"operationId": "Test\\MyController:put",
"description": "Will call method put() on class Test\MyController"
"description": "Will call method put() on class Test\\MyController"
}
}
}
}
```

## Versions

| Version | PHP | |
| --- | --- | --- |
| `1.0` | `^7.4 | ^8.0` | Route registry |

4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"type": "library",
"description": "OpenApi implementation for Slim 4.",
"homepage": "https://phrity.sirn.se/slim-openapi",
"keywords": [],
"keywords": ["slim", "openapi", "routing", "router"],
"license": "MIT",
"authors": [
{
Expand All @@ -23,7 +23,7 @@
}
},
"require": {
"php": "^7.4 || ^8.0",
"php": "^7.4 | ^8.0",
"cebe/php-openapi": "^1.4",
"slim/slim": "^4.0"
},
Expand Down

0 comments on commit 8cf9276

Please sign in to comment.