From 2a3312e77955dcdab6542d7bd118d9244d6e3001 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rom=C3=A1n=20Jim=C3=A9nez?= Date: Thu, 22 Aug 2019 18:12:27 +0200 Subject: [PATCH] Fix cURL docs for Windows users by using files --- docs/reference/swagger.yaml | 245 ++++++++++++++++++++---------------- 1 file changed, 135 insertions(+), 110 deletions(-) diff --git a/docs/reference/swagger.yaml b/docs/reference/swagger.yaml index 416f1d4a..d6cd8967 100644 --- a/docs/reference/swagger.yaml +++ b/docs/reference/swagger.yaml @@ -90,10 +90,26 @@ paths: x-code-samples: - lang: Curl source: | - curl -X POST -H "Content-Type: application/json" -d '{ \ - "q": "SELECT count(*) FROM cities", \ - "filename": "number_of_cities.json" \ - }' "https://username.carto.com/api/v2/sql" + # body.json + { + "version": "1.3.0", + "layers": [ + { + "type": "mapnik", + "options": { + "cartocss_version": "2.1.1", + "cartocss": "#layer { polygon-fill: #FFF; }", + "sql": "select * from european_countries_e", + "interactivity": [ + "cartodb_id", + "iso3" + ] + } + } + ] + } + + curl -X POST -H "Content-Type: application/json" -d @body.json "https://username.carto.com/api/v2/sql" '/map/{layergroupid}/{z}/{x}/{y}.png': get: parameters: @@ -277,57 +293,60 @@ paths: x-code-samples: - lang: Curl source: | - curl -X POST -H "Content-Type: application/json" -d '{ \ - "version": "0.0.1", \ - "name": "template_name", \ - "auth": { \ - "method": "token", \ - "valid_tokens": [ \ - "auth_token1", \ - "auth_token2" \ - ] \ - }, \ - "placeholders": { \ - "color": { \ - "type": "css_color", \ - "default": "red" \ - }, \ - "cartodb_id": { \ - "type": "number", \ - "default": 1 \ - } \ - }, \ - "layergroup": { \ - "version": "1.7.0", \ - "layers": [ \ - { \ - "type": "cartodb", \ - "options": { \ - "cartocss_version": "2.3.0", \ - "cartocss": "#layer { polygon-fill: <%= color %>; }", \ - "sql": "select * from european_countries_e WHERE cartodb_id = <%= cartodb_id %>" \ - } \ - } \ - ] \ - }, \ - "view": { \ - "zoom": 4, \ - "center": { \ - "lng": 0, \ - "lat": 0 \ - }, \ - "bounds": { \ - "west": -45, \ - "south": -45, \ - "east": 45, \ - "north": 45 \ - }, \ - "preview_layers": { \ - "0": true, \ - "layer1": false \ - } \ - } \ - }' "https://{username}.carto.com/api/v1/map/named?api_key={api_key}" + # body.json + { + "version": "0.0.1", + "name": "template_name", + "auth": { + "method": "token", + "valid_tokens": [ + "auth_token1", + "auth_token2" + ] + }, + "placeholders": { + "color": { + "type": "css_color", + "default": "red" + }, + "cartodb_id": { + "type": "number", + "default": 1 + } + }, + "layergroup": { + "version": "1.7.0", + "layers": [ + { + "type": "cartodb", + "options": { + "cartocss_version": "2.3.0", + "cartocss": "#layer { polygon-fill: <%= color %>; }", + "sql": "select * from european_countries_e WHERE cartodb_id = <%= cartodb_id %>" + } + } + ] + }, + "view": { + "zoom": 4, + "center": { + "lng": 0, + "lat": 0 + }, + "bounds": { + "west": -45, + "south": -45, + "east": 45, + "north": 45 + }, + "preview_layers": { + "0": true, + "layer1": false + } + } + } + + curl -X POST -H "Content-Type: application/json" -d @body.json "https://{username}.carto.com/api/v1/map/named?api_key={api_key}" get: summary: List user's templates description: | @@ -424,59 +443,62 @@ paths: x-code-samples: - lang: Curl source: | + # body.json + { + "version": "0.0.1", + "name": "template_name", + "auth": { + "method": "token", + "valid_tokens": [ + "auth_token1", + "auth_token2" + ] + }, + "placeholders": { + "color": { + "type": "css_color", + "default": "red" + }, + "cartodb_id": { + "type": "number", + "default": 1 + } + }, + "layergroup": { + "version": "1.7.0", + "layers": [ + { + "type": "cartodb", + "options": { + "cartocss_version": "2.3.0", + "cartocss": "#layer { polygon-fill: <%= color %>; }", + "sql": "select * from european_countries_e WHERE cartodb_id = <%= cartodb_id %>" + } + } + ] + }, + "view": { + "zoom": 4, + "center": { + "lng": 0, + "lat": 0 + }, + "bounds": { + "west": -45, + "south": -45, + "east": 45, + "north": 45 + }, + "preview_layers": { + "0": true, + "layer1": false + } + } + } + curl -X PUT \ -H 'Content-Type: application/json' \ - -d '{ \ - "version": "0.0.1", \ - "name": "template_name", \ - "auth": { \ - "method": "token", \ - "valid_tokens": [ \ - "auth_token1", \ - "auth_token2" \ - ] \ - }, \ - "placeholders": { \ - "color": { \ - "type": "css_color", \ - "default": "red" \ - }, \ - "cartodb_id": { \ - "type": "number", \ - "default": 1 \ - } \ - }, \ - "layergroup": { \ - "version": "1.7.0", \ - "layers": [ \ - { \ - "type": "cartodb", \ - "options": { \ - "cartocss_version": "2.3.0", \ - "cartocss": "#layer { polygon-fill: <%= color %>; }", \ - "sql": "select * from european_countries_e WHERE cartodb_id = <%= cartodb_id %>" \ - } \ - } \ - ] \ - }, \ - "view": { \ - "zoom": 4, \ - "center": { \ - "lng": 0, \ - "lat": 0 \ - }, \ - "bounds": { \ - "west": -45, \ - "south": -45, \ - "east": 45, \ - "north": 45 \ - }, \ - "preview_layers": { \ - "0": true, \ - "layer1": false \ - } \ - } \ - }' \ + -d @body.json 'https://{username}.carto.com/api/v1/map/named/{template_name}?api_key={api_key}' delete: summary: Delete template @@ -548,12 +570,15 @@ paths: x-code-samples: - lang: Curl source: | + # body.json + { + "color": "#ff0000", + "cartodb_id": 3 + } + curl -X POST \ -H 'Content-Type: application/json' \ - -d '{ \ - "color": "#ff0000", \ - "cartodb_id": 3 \ - }' \ + -d @body.json 'https://{username}.carto.com/api/v1/map/named/{template_name}?auth_token={auth_token}' '/map/named/{template_name}/jsonp': get: