|
155 | 155 | "source": [ |
156 | 156 | "def save_yaml_config(config, path):\n", |
157 | 157 | " def multiline_str_handler(dumper, data):\n", |
158 | | - " if '\\n' in data:\n", |
159 | | - " return dumper.represent_scalar('tag:yaml.org,2002:str', data.strip() + '\\n', style='|')\n", |
160 | | - " return dumper.represent_scalar('tag:yaml.org,2002:str', data)\n", |
| 158 | + " if \"\\n\" in data:\n", |
| 159 | + " return dumper.represent_scalar(\n", |
| 160 | + " \"tag:yaml.org,2002:str\", data.strip() + \"\\n\", style=\"|\"\n", |
| 161 | + " )\n", |
| 162 | + " return dumper.represent_scalar(\"tag:yaml.org,2002:str\", data)\n", |
161 | 163 | "\n", |
162 | 164 | " yaml.add_representer(str, multiline_str_handler)\n", |
163 | 165 | "\n", |
|
195 | 197 | " \"sections\": [\n", |
196 | 198 | " {\n", |
197 | 199 | " \"title\": \"API Examples\",\n", |
198 | | - " \"subsections\": [\n", |
199 | | - " {\n", |
200 | | - " \"title\": \"Basic HTTP Methods\",\n", |
201 | | - " \"components\": []\n", |
202 | | - " }\n", |
203 | | - " ]\n", |
| 200 | + " \"subsections\": [{\"title\": \"Basic HTTP Methods\", \"components\": []}],\n", |
204 | 201 | " }\n", |
205 | | - " ]\n", |
| 202 | + " ],\n", |
206 | 203 | "}" |
207 | 204 | ] |
208 | 205 | }, |
|
235 | 232 | " \"title\": \"GET request\",\n", |
236 | 233 | " \"component_type\": \"apicall\",\n", |
237 | 234 | " \"api_url\": \"https://jsonplaceholder.typicode.com/todos/1\",\n", |
238 | | - " \"method\": \"GET\"\n", |
| 235 | + " \"method\": \"GET\",\n", |
239 | 236 | "}\n", |
240 | 237 | "\n", |
241 | 238 | "config[\"sections\"][0][\"subsections\"][0][\"components\"].append(get_component)\n", |
|
272 | 269 | " \"component_type\": \"apicall\",\n", |
273 | 270 | " \"api_url\": \"https://jsonplaceholder.typicode.com/todos\",\n", |
274 | 271 | " \"method\": \"POST\",\n", |
275 | | - " \"request_body\": '''{\n", |
| 272 | + " \"request_body\": \"\"\"{\n", |
276 | 273 | " \"userId\": 1,\n", |
277 | 274 | " \"title\": \"Go running\",\n", |
278 | 275 | " \"completed\": false\n", |
279 | | - "}'''\n", |
| 276 | + "}\"\"\",\n", |
280 | 277 | "}\n", |
281 | 278 | "\n", |
282 | 279 | "config[\"sections\"][0][\"subsections\"][0][\"components\"].append(post_component)\n", |
|
319 | 316 | " \"title\": \"Play the guitar\",\n", |
320 | 317 | " \"completed\": true\n", |
321 | 318 | "}\n", |
322 | | - "\"\"\"\n", |
| 319 | + "\"\"\",\n", |
323 | 320 | "}\n", |
324 | 321 | "\n", |
325 | 322 | "config[\"sections\"][0][\"subsections\"][0][\"components\"].append(put_component)\n", |
|
361 | 358 | "{\n", |
362 | 359 | " \"title\": \"Go for a hike\"\n", |
363 | 360 | "}\n", |
364 | | - "\"\"\"\n", |
| 361 | + "\"\"\",\n", |
365 | 362 | "}\n", |
366 | 363 | "\n", |
367 | 364 | "config[\"sections\"][0][\"subsections\"][0][\"components\"].append(patch_component)\n", |
|
397 | 394 | " \"title\": \"DELETE request\",\n", |
398 | 395 | " \"component_type\": \"apicall\",\n", |
399 | 396 | " \"api_url\": \"https://jsonplaceholder.typicode.com/todos/10\",\n", |
400 | | - " \"method\": \"DELETE\"\n", |
| 397 | + " \"method\": \"DELETE\",\n", |
401 | 398 | "}\n", |
402 | 399 | "\n", |
403 | 400 | "config[\"sections\"][0][\"subsections\"][0][\"components\"].append(delete_component)\n", |
|
419 | 416 | "metadata": {}, |
420 | 417 | "outputs": [], |
421 | 418 | "source": [ |
422 | | - "# Save the report config file \n", |
| 419 | + "# Save the report config file\n", |
423 | 420 | "config_path = \"apicall_config.yaml\"\n", |
424 | 421 | "save_yaml_config(config, config_path)" |
425 | 422 | ] |
|
514 | 511 | ], |
515 | 512 | "source": [ |
516 | 513 | "# run_streamlit = False\n", |
517 | | - "run_streamlit = True # uncomment line to run the streamlit report\n", |
| 514 | + "run_streamlit = True # uncomment line to run the streamlit report\n", |
518 | 515 | "# Launch the Streamlit report depneding on the platform\n", |
519 | 516 | "if not IN_COLAB and run_streamlit:\n", |
520 | 517 | " !streamlit run streamlit_report/sections/report_manager.py\n", |
|
0 commit comments