This repository was archived by the owner on Feb 24, 2025. It is now read-only.
File tree 3 files changed +25
-3
lines changed
3 files changed +25
-3
lines changed Original file line number Diff line number Diff line change 11
11
interface ApiMethodInterface
12
12
{
13
13
/**
14
- * @return array<mixed, mixed>
14
+ * This method contains the business logic of the api method
15
+ *
16
+ * @param stdClass $parameter The method parameter as described in the schema
17
+ *
18
+ * @return array<mixed, mixed> The api method response
15
19
*
16
20
* @throws ApiMethodException
17
21
*/
@@ -20,5 +24,8 @@ public function handle(
20
24
stdClass $ parameter
21
25
): array ;
22
26
27
+ /**
28
+ * Return the absolute path to the corresponding json schema
29
+ */
23
30
public function getSchemaFile (): string ;
24
31
}
Original file line number Diff line number Diff line change 2
2
3
3
namespace Usox \JsonSchemaApi \Contract ;
4
4
5
+ /**
6
+ * A method provider should perform a lookup an api method by its name.
7
+ * If api versions are used, the version number gets appended to the method name.
8
+ * e.g. someNamespace.someMethod, someNamespace.someMethod.1
9
+ *
10
+ * If the method name does not exist, lookup is expected to return null.
11
+ */
5
12
interface MethodProviderInterface
6
13
{
7
14
public function lookup (
Original file line number Diff line number Diff line change @@ -59,6 +59,9 @@ public function __construct(
59
59
$ this ->logger = $ logger ;
60
60
}
61
61
62
+ /**
63
+ * Try to execute the api handler and build the response
64
+ */
62
65
public function serve (
63
66
ServerRequestInterface $ request ,
64
67
ResponseInterface $ response
@@ -130,12 +133,17 @@ private function log(
130
133
);
131
134
}
132
135
}
133
-
136
+
137
+ /**
138
+ * Builds the endpoint.
139
+ * The StreamFactory can be omitted, the endpoint will search
140
+ * for any existing PSR17 implementations
141
+ */
134
142
public static function factory (
135
143
MethodProviderInterface $ methodProvider ,
136
144
?StreamFactoryInterface $ streamFactory = null ,
137
145
?LoggerInterface $ logger = null
138
- ): Endpoint {
146
+ ): EndpointInterface {
139
147
$ schemaValidator = new Validator ();
140
148
$ schemaLoader = new SchemaLoader ();
141
149
You can’t perform that action at this time.
0 commit comments