Output sections which should be printed after return value
(schema, name)
| 508 | |
| 509 | |
| 510 | def generate_footer(schema, name): |
| 511 | """Output sections which should be printed after return value""" |
| 512 | for key in FOOTER_KEY_SEQUENCE: |
| 513 | if key not in schema: |
| 514 | continue |
| 515 | if key == 'see_also': |
| 516 | output_title(key.replace('_', ' ').upper(), '-', 1) |
| 517 | # Wrap see_also list with comma separated values |
| 518 | output(esc_underscores(', '.join(schema[key]))) |
| 519 | elif key == 'example_notifications' and len(schema[key]) > 0: |
| 520 | output_title(key.replace('_', ' ').upper(), '-', 1) |
| 521 | for i, notification in enumerate(schema.get(key, [])): |
| 522 | output('{}**Notification {}**: {}\n'.format('' if i == 0 else '\n\n', i + 1, '\n'.join(notification.get('description', '')))) |
| 523 | output('```json\n') |
| 524 | output(json.dumps(notification, indent=2).strip() + '\n') |
| 525 | output('```') |
| 526 | elif key == 'examples' and len(schema[key]) > 0: |
| 527 | output_title(key.replace('_', ' ').upper(), '-', 1) |
| 528 | for i, example in enumerate(schema.get('examples', [])): |
| 529 | output('\n{}**Example {}**: {}\n'.format('' if i == 0 else '\n', i + 1, '\n'.join(example.get('description', '')))) |
| 530 | output('\nRequest:\n') |
| 531 | create_shell_command(name, example) |
| 532 | output('```json\n') |
| 533 | output(json.dumps(example['request'], indent=2).strip() + '\n') |
| 534 | output('```\n') |
| 535 | output('\nResponse:\n') |
| 536 | output('```json\n') |
| 537 | output(json.dumps(example['response'], indent=2).strip() + '\n') |
| 538 | output('```') |
| 539 | else: |
| 540 | output_title(key.replace('_', ' ').upper(), '-', 1) |
| 541 | outputs(schema[key], '\n') |
| 542 | output('\n') |
| 543 | |
| 544 | |
| 545 | def get_schema_type(schema, capitalize=False): |
no test coverage detected