Last modified by Ashterix on 2024/07/11 10:08

From version 1.2
edited by Ashterix
on 2024/05/10 11:09
Change comment: There is no comment for this version
To version 3.2
edited by Ashterix
on 2024/07/11 09:57
Change comment: Updated the relative links.

Summary

Details

Page properties
Content
... ... @@ -53,7 +53,6 @@
53 53  - RFC Standards: Header requirements are regulated by RFC documents that define standards for Internet protocols. For example, common headers and their use are described in RFC 7231.
54 54  {{/spoiler}}
55 55  
56 -
57 57  == Parameter {{code language="none"}}clients_tokens{{/code}} ==
58 58  
59 59  Now you need to specify an array of client tokens that will have access to the API.
... ... @@ -127,7 +127,7 @@
127 127  
128 128   public function __construct(protected UserService $userService) {}
129 129  
130 - public function isValid(string $token): bool
129 + public function isValid(string $token): true
131 131   {
132 132   try {
133 133   this.userService.getUserByToken(token);
... ... @@ -160,6 +160,24 @@
160 160   class: App\Services\RpcSecurity\UserTokenValidator
161 161  {{/code}}
162 162  
162 += Block {{code language="none"}}async{{/code}} =
163 +
164 +This block is for configuring [[asynchronous transport>>doc:docs.JsonRpcBundle.functionality.async.WebHome]].
165 +
166 +Add the parameter {{code language="none"}}rpc_async{{/code}} which contains a string in DSN format. This string is the configuration for [[Symfony Messenger>>https://symfony.com/doc/current/messenger.html]], and it points to the asynchronous transport where the RPC Server will be waiting for incoming requests if you have a consumer running ({{code language="none"}}php bin/console messenger:consume rpc_async{{/code}}). For a more detailed understanding of this process, read the [[Symfony Messenger documentation>>https://symfony.com/doc/current/messenger.html]].
167 +
168 +{{code language="yaml" layout="LINENUMBERS" title="config/packages/ufo_json_rpc.yaml"}}
169 +ufo_json_rpc:
170 + async:
171 + rpc_async: '%env(resolve:RPC_TRANSPORT_DSN)%'
172 +
173 +{{/code}}
174 +
175 +(% class="box warningmessage" %)
176 +(((
177 +This configuration implies that you have an environment variable RPC_TRANSPORT_DSN set, which contains the DSN string.
178 +)))
179 +
163 163  = The {{code language="none"}}docs{{/code}} block =
164 164  
165 165  This block configures the generation of documentation when you make a GET request on the RPC Server
... ... @@ -192,6 +192,65 @@
192 192   key_for_methods: some_custom_key
193 193  {{/code}}
194 194  
212 +=== Parameter {{code language="none"}}async_dsn_info{{/code}} ===
213 +
214 +Responsible for displaying information about asynchronous transport in the documentation.
215 +
216 +{{code language="yaml" layout="LINENUMBERS" title="config/packages/ufo_json_rpc.yaml"}}
217 +ufo_json_rpc:
218 + async_dsn_info: true # or false
219 +{{/code}}
220 +
221 +==== **Documentation Example** ====
222 +
223 +{{code language="json" layout="LINENUMBERS" title="GET: /api"}}
224 +{
225 + "envelope": "JSON-RPC-2.0/UFO-RPC-6",
226 + "contentType": "application/json",
227 + "description": "",
228 + "transport": {
229 + "sync": {
230 + "scheme": "http",
231 + "host": "example.com",
232 + "path": "/api",
233 + "method": "POST"
234 + },
235 + "async": {
236 + "scheme": "amqp",
237 + "user": "{user}",
238 + "pass": "{pass}",
239 + "host": "async_rabbit",
240 + "port": 5672,
241 + "path": "/%2f/json-rpc"
242 + }
243 + },
244 + "methods": {
245 + ...
246 + }
247 +}
248 +{{/code}}
249 +
250 +{{info}}
251 +Do not worry about the security of your authorization data contained in the DSN.
252 +
253 +The documenter is designed in such a way that before displaying DSN information, it removes user data and passwords, as well as other sensitive information, such as tokens, secret keys, etc.
254 +
255 +The template for protecting data is {{code language="none"}}/([\w\d_]*(?:secret|access|token|key)[_\w]*)=((?:\w|\d)+(?=&?))/{{/code}}.
256 +
257 +Example:
258 +
259 +{{code language="json" layout="LINENUMBERS" title="RPC_TRANSPORT_DSN=https://sqs.eu-west-3.amazonaws.com/123456789012/messages?access_key=AKIAIOSFODNN7EXAMPLE&secret_key=j17M97ffSVoKI0briFoo9a"}}
260 +{
261 + "async": {
262 + "scheme": "https",
263 + "host": "sqs.eu-west-3.amazonaws.com",
264 + "path": "/123456789012/messages",
265 + "query": "access_key={access_key}&secret_key={secret_key}"
266 + }
267 +}
268 +{{/code}}
269 +{{/info}}
270 +
195 195  === Parameter {{code language="none"}}validations{{/code}} ===
196 196  
197 197  Responsible for displaying in the documentation methods additional blocks that indicate data validation requirements.
... ... @@ -216,7 +216,7 @@
216 216  (% class="box infomessage" %)
217 217  (((
218 218  In this example, I removed the content of the objects symfony_assertions to simplify the example.
219 -For more information on method validation, see the page **[[Validate procedures>>doc:.add_rpc_service.assertions.WebHome]]**
295 +For more information on method validation, see the page **[[Validate procedures>>doc:docs.JsonRpcBundle.add_rpc_service.assertions.WebHome]]**
220 220  )))
221 221  
222 222  {{code language="json" layout="LINENUMBERS" title="GET: /api"}}