diff --git a/src/components/Layout/MDXWrapper.tsx b/src/components/Layout/MDXWrapper.tsx index acb2a4b0d1..aec18838df 100644 --- a/src/components/Layout/MDXWrapper.tsx +++ b/src/components/Layout/MDXWrapper.tsx @@ -105,7 +105,7 @@ const WrappedCodeSnippet: React.FC<{ activePage: ActivePage } & CodeSnippetProps // Check if this code block contains only a single utility language const utilityLanguageOverride = useMemo(() => { // Utility languages that should be shown without warning (like JSON) - const UTILITY_LANGUAGES = ['html', 'xml', 'css', 'sql']; + const UTILITY_LANGUAGES = ['html', 'xml', 'css', 'sql', 'json']; const childrenArray = React.Children.toArray(processedChildren); diff --git a/src/pages/docs/api/rest-api.mdx b/src/pages/docs/api/rest-api.mdx index 455091a272..fa7f51c146 100644 --- a/src/pages/docs/api/rest-api.mdx +++ b/src/pages/docs/api/rest-api.mdx @@ -215,14 +215,14 @@ Specifying `?fields=[,, ...]` returns the representation ```shell - curl https://main.realtime.ably.net/stats?fields=channels.peak,intervalId \ - -u "{'{{API_KEY}}'}"{""} +curl https://main.realtime.ably.net/stats?fields=channels.peak,intervalId \ + -u "{{API_KEY}}" - # Response - [{ - "channels": { "peak": 2 }, - "intervalId": "2015-11-20:15" - }] +# Response +[{ + "channels": { "peak": 2 }, + "intervalId": "2015-11-20:15" +}] ``` @@ -234,14 +234,14 @@ Specifying `?flatten=true` will result in a flattened representation, with the r ```shell - curl https://main.realtime.ably.net/stats?flatten=true&fields=channels.peak,intervalId \ - -u "{'{{API_KEY}}'}"{""} +curl https://main.realtime.ably.net/stats?flatten=true&fields=channels.peak,intervalId \ + -u "{{API_KEY}}" - # Response - { - "0.channels.peak": 2, - "0.intervalId": "2015-11-20:15" - } +# Response +{ + "0.channels.peak": 2, + "0.intervalId": "2015-11-20:15" +} ``` @@ -255,16 +255,16 @@ The result is a partially-flattened representation, as a map whose keys are the ```shell - curl https://main.realtime.ably.net/stats?select=*.channels.* \ - -u "{'{{API_KEY}}'}"{""} +curl https://main.realtime.ably.net/stats?select=*.channels.* \ + -u "{{API_KEY}}" - # Response - [{ - "0.channels.peak": 5, - "0.channels.min": 1, - "0.channels.mean": 3, - "0.channels.opened": 2 - }] +# Response +[{ + "0.channels.peak": 5, + "0.channels.min": 1, + "0.channels.mean": 3, + "0.channels.opened": 2 +}] ``` @@ -337,7 +337,7 @@ Example request: ```shell curl https://main.realtime.ably.net/channels/rest-example/messages \ - --user "{'{{API_KEY}}'}"{""} + -u "{{API_KEY}}" ``` @@ -418,7 +418,7 @@ Example request: ```shell curl -X POST https://main.realtime.ably.net/channels/rest-example/messages \ - -u "{'{{API_KEY}}'}"{""} \ + -u "{{API_KEY}}" \ -H "Content-Type: application/json" \ --data '{ "name": "publish", "data": "example" }' ``` @@ -491,11 +491,9 @@ Full example of a request publishing a message with a push payload: ```shell curl -X POST https://main.realtime.ably.net/channels/push-enabled:rest-example/messages \ - -u "{'{{API_KEY}}'}"{""} \ + -u "{{API_KEY}}" \ -H "Content-Type: application/json" \ - --data \ - ' -{ + --data '{ "name": "some event name for realtime receivers", "data": "example non-push data for realtime receivers", "extras": { @@ -516,8 +514,7 @@ curl -X POST https://main.realtime.ably.net/channels/push-enabled:rest-example/m } } } -} -' +}' ``` @@ -548,8 +545,11 @@ Example json request: ```shell curl -X POST https://main.realtime.ably.net/channels/rest-example/messages?enveloped=false \ --H 'content-type: application/json' --data '{"some":"json"}' \ --u "{'{{API_KEY}}'}"{""} + -u "{{API_KEY}}" \ + -H 'content-type: application/json' \ + --data '{ + "some":"json" +}' ``` @@ -558,8 +558,9 @@ Example plain text request: ```shell curl -X POST https://main.realtime.ably.net/channels/rest-example/messages?enveloped=false \ --H 'content-type: text/plain' --data 'some plain text' \ --u "{'{{API_KEY}}'}"{""} + -u "{{API_KEY}}" \ + -H 'content-type: text/plain' \ + --data 'some plain text' ``` @@ -596,7 +597,7 @@ Example request: ```shell curl https://main.realtime.ably.net/channels/rest-example/messages \ - -u "{'{{API_KEY}}'}"{""} + -u "{{API_KEY}}" ``` @@ -861,7 +862,7 @@ Example request: ```shell - curl https://main.realtime.ably.net/channels/rest-example/messages/01826232498871-001@abcdefghij:001/versions \ +curl https://main.realtime.ably.net/channels/rest-example/messages/01826232498871-001@abcdefghij:001/versions \ -u "{{API_KEY}}" ``` @@ -958,9 +959,9 @@ Example request: ```shell curl -X POST https://rest.ably.io/channels/mutable:channel/messages/01726585978590-001@abcdefghij:001/annotations \ - -u "{'{{API_KEY}}'}"{""} \ + -u "{{API_KEY}}" \ -H "Content-Type: application/json" \ - --data '[{ "action": 0, "type": "reaction:distinct.v1", "name": ":thumbsup:" }]' + -d '[{"action": 0, "type": "reaction:distinct.v1", "name": ":thumbsup:"}]' ``` @@ -991,7 +992,7 @@ Example request: ```shell curl https://rest.ably.io/channels/rest-example/messages/01726585978590-001@abcdefghij:001/annotations?limit=100 \ - -u "{'{{API_KEY}}'}"{""} + -u "{{API_KEY}}" ``` @@ -1042,7 +1043,7 @@ Example request: ```shell curl https://main.realtime.ably.net/channels/rest-example/presence \ - -u "{'{{API_KEY}}'}"{""} + -u "{{API_KEY}}" ``` @@ -1090,7 +1091,7 @@ Example request: ```shell curl https://main.realtime.ably.net/channels/rest-example/presence/history \ - -u "{'{{API_KEY}}'}"{""} + -u "{{API_KEY}}" ``` @@ -1136,8 +1137,8 @@ Example request: ```shell -curl https://main.realtime.ably.net/channels/\{channelId\} \ - -u "{'{{API_KEY}}'}"{""} +curl https://main.realtime.ably.net/channels/{channelId} \ + -u "{{API_KEY}}" ``` @@ -1156,7 +1157,7 @@ Example request: ```shell curl https://main.realtime.ably.net/channels \ - -u "{'{{API_KEY}}'}" + -u "{{API_KEY}}" ``` @@ -1259,10 +1260,9 @@ Example request: ```shell curl -X POST https://main.realtime.ably.net/push/deviceRegistrations \ - -u "{'{{API_KEY}}'}"{""} + -u "{{API_KEY}}" \ -H "Content-Type: application/json" \ - --data \ -'{ + -d '{ "id": "01ARZ3NDEKTSV4RRFFQ69G5FAV", "platform": "ios", "formFactor": "phone", @@ -1313,10 +1313,9 @@ Example request: ```shell curl -X PUT https://main.realtime.ably.net/push/deviceRegistrations/01ARZ3NDEKTSV4RRFFQ69G5FAV \ - -u "{'{{API_KEY}}'}"{""} + -u "{{API_KEY}}" \ -H "Content-Type: application/json" \ - --data \ -'{ + -d '{ "id": "01ARZ3NDEKTSV4RRFFQ69G5FAV", "platform": "ios", "formFactor": "phone", @@ -1364,14 +1363,13 @@ Example request: ```shell curl -X PATCH https://main.realtime.ably.net/push/deviceRegistrations/01ARZ3NDEKTSV4RRFFQ69G5FAV \ - -u "{'{{API_KEY}}'}"{""} + -u "{{API_KEY}}" \ -H "Content-Type: application/json" \ - --data \ -'{ + -d '{ "metadata": { "myKey": "value" } - }' +}' ``` @@ -1402,7 +1400,7 @@ Example request: ```shell curl https://main.realtime.ably.net/push/deviceRegistrations/01ARZ3NDEKTSV4RRFFQ69G5FAV \ - -u "{'{{API_KEY}}'}"{""} + -u "{{API_KEY}}" ``` @@ -1462,7 +1460,7 @@ Example request: ```shell curl https://main.realtime.ably.net/push/deviceRegistrations \ - -u "{'{{API_KEY}}'}"{""} + -u "{{API_KEY}}" ``` @@ -1515,7 +1513,7 @@ Example request: ```shell curl -X POST https://main.realtime.ably.net/push/01ARZ3NDEKTSV4RRFFQ69G5FAV/resetUpdateToken \ - -u "{'{{API_KEY}}'}"{""} + -u "{{API_KEY}}" ``` @@ -1548,7 +1546,7 @@ Example request: ```shell curl -X DELETE \ https://main.realtime.ably.net/push/deviceRegistrations/01ARZ3NDEKTSV4RRFFQ69G5FAV \ - -u "{'{{API_KEY}}'}"{""} + -u "{{API_KEY}}" ``` @@ -1583,7 +1581,7 @@ Example request: ```shell curl -X DELETE \ https://main.realtime.ably.net/push/deviceRegistrations?deviceId=01ARZ3NDEKTSV4RRFFQ69G5FAV \ - -u "{'{{API_KEY}}'}"{""} + -u "{{API_KEY}}" ``` @@ -1628,15 +1626,12 @@ The request body contains subscription details and is an object of the form: ```shell curl -X POST https://main.realtime.ably.net/push/channelSubscriptions \ - -u "{'{{API_KEY}}'}"{""} + -u "{{API_KEY}}" \ -H "Content-Type: application/json" \ - --data \ - ' -{ + -d '{ "channel": "rest-example", "deviceId": "01ARZ3NDEKTSV4RRFFQ69G5FAV" -} -' +}' ``` @@ -1670,7 +1665,7 @@ Example request: ```shell curl -X DELETE \ https://main.realtime.ably.net/push/channelSubscriptions?deviceId=01ARZ3NDEKTSV4RRFFQ69G5FAV \ - -u "{'{{API_KEY}}'}"{""} + -u "{{API_KEY}}" ``` @@ -1706,7 +1701,7 @@ Example request: ```shell curl https://main.realtime.ably.net/push/channelSubscriptions \ - -u "{'{{API_KEY}}'}"{""} + -u "{{API_KEY}}" ``` @@ -1751,7 +1746,7 @@ Example request: ```shell curl https://main.realtime.ably.net/push/channels \ - -u "{'{{API_KEY}}'}"{""} + -u "{{API_KEY}}" ``` @@ -1803,11 +1798,9 @@ Example request: ```shell curl -X POST https://main.realtime.ably.net/push/publish \ - -u "{'{{API_KEY}}'}"{""} \ + -u "{{API_KEY}}" \ -H "Content-Type: application/json" \ - --data \ - ' -{ + -d '{ "recipient": { "clientId": "myClientId" }, @@ -1926,11 +1919,10 @@ Example request: ```shell curl -X POST https://main.realtime.ably.net/push/admin/batch/publish \ - -u "{'{{API_KEY}}'}"{""} \ + -u "{{API_KEY}}" \ -H "Content-Type: application/json" \ --data \ - ' -[ + '[ { "recipient": { "deviceId": "01ARZ3NDEKTSV4RRFFQ69G5FAV" @@ -1953,8 +1945,7 @@ curl -X POST https://main.realtime.ably.net/push/admin/batch/publish \ } } } -] -' +]' ``` @@ -1974,7 +1965,7 @@ Example request: ```shell curl -X POST "https://main.realtime.ably.net/keys/{'{{API_KEY_NAME}}'}/requestToken" \ - -u "{'{{API_KEY}}'}"{""} \ + -u "{{API_KEY}}" \ -H "Content-Type: application/json" \ --data '{ "keyName": "{'{{API_KEY_NAME}}'}", "timestamp": {'{{MS_SINCE_EPOCH}}'} }' ``` @@ -2019,10 +2010,11 @@ Example request: ```shell -curl -u "{'{{API_KEY}}'}"{""} -X POST https://main.realtime.ably.net/keys/{'{{API_KEY_NAME}}'}/revokeTokens \ - --header "Accept: application/json" \ - --header "Content-Type: application/json" \ - --data '{"targets": [ "clientId:client1@example.com" ]}' +curl -u "{{API_KEY}}" \ + -X POST https://main.realtime.ably.net/keys/{{API_KEY_NAME}}/revokeTokens \ + -H "Accept: application/json" \ + -H "Content-Type: application/json" \ + -d '{"targets": ["clientId:client1@example.com"]}' ``` @@ -2090,7 +2082,7 @@ Example request: ```shell curl https://main.realtime.ably.net/stats?unit=hour \ - -u "{'{{API_KEY}}'}"{""} + -u "{{API_KEY}}" ```