--- /dev/null
+#!/usr/bin/env python3
+
+import os
+
+import jinja2
+
+ROOT_DIR = os.path.dirname(os.path.realpath(__file__))
+VERSIONS = [(1, 0), (1, 1), None]
+LATEST_VERSION = (1, 1)
+
+
+def generate_schema():
+ env = jinja2.Environment(
+ loader=jinja2.FileSystemLoader(ROOT_DIR),
+ trim_blocks=True,
+ lstrip_blocks=True)
+ template = env.get_template('patchwork.j2')
+
+ for version in VERSIONS:
+ version_dir = os.path.join(
+ ROOT_DIR, 'v%d.%d' % version if version else 'latest')
+
+ if not os.path.exists(version_dir):
+ os.mkdir(version_dir)
+
+ version_str = '%d.%d' % (version or LATEST_VERSION)
+ version_url = '%d.%d/' % version if version else ''
+ version = version or LATEST_VERSION
+
+ with open(os.path.join(version_dir, 'patchwork.yaml'), 'wb') as fh:
+ template.stream(version=version, version_str=version_str,
+ version_url=version_url).dump(fh, encoding='utf-8')
+
+
+if __name__ == '__main__':
+ generate_schema()
+{# You can obviously ignore the below when editing this template #}
+# DO NOT EDIT THIS FILE. It is generated from a template. Changes should be
+# proposed against the template.
openapi: '3.0.0'
info:
title: Patchwork API
license:
name: GPL v2 License
url: https://www.gnu.org/licenses/gpl-2.0.html
- version: '1.1'
+ version: '{{ version_str }}'
paths:
- /api/:
+ /api/{{ version_url}}:
get:
description: List API resources.
operationId: api_list
$ref: '#/components/schemas/Index'
tags:
- api
- /api/bundles/:
+ /api/{{ version_url}}bundles/:
get:
description: List bundles.
operationId: bundles_list
$ref: '#/components/schemas/Bundle'
tags:
- bundles
- /api/bundles/{id}/:
+ /api/{{ version_url }}bundles/{id}/:
get:
description: Show a bundle.
operationId: bundles_read
$ref: '#/components/schemas/Error'
tags:
- bundles
- /api/covers/:
+ /api/{{ version_url }}covers/:
get:
description: List cover letters.
operationId: covers_list
$ref: '#/components/schemas/CoverLetterList'
tags:
- covers
- /api/covers/{id}/:
+ /api/{{ version_url }}covers/{id}/:
get:
description: Show a cover letter.
operationId: covers_read
$ref: '#/components/schemas/Error'
tags:
- covers
- /api/covers/{id}/comments/:
+ /api/{{ version_url }}covers/{id}/comments/:
get:
description: List comments
operationId: cover_comments_list
$ref: '#/components/schemas/Error'
tags:
- comments
- /api/events/:
+ /api/{{ version_url }}events/:
get:
description: List events.
operationId: events_list
series-completed: '#/components/schemas/EventSeriesCompleted'
tags:
- events
- /api/patches/:
+ /api/{{ version_url }}patches/:
get:
description: List patches.
operationId: patches_list
$ref: '#/components/schemas/PatchList'
tags:
- patches
- /api/patches/{id}/:
+ /api/{{ version_url }}patches/{id}/:
get:
description: Show a patch.
operationId: patches_read
$ref: '#/components/schemas/Error'
tags:
- patches
- /api/patches/{id}/comments/:
+ /api/{{ version_url }}patches/{id}/comments/:
get:
description: List comments
operationId: patch_comments_list
$ref: '#/components/schemas/Error'
tags:
- comments
- /api/patches/{patch_id}/checks/:
+ /api/{{ version_url }}patches/{patch_id}/checks/:
get:
description: List checks.
operationId: checks_list
$ref: '#/components/schemas/Error'
tags:
- checks
- /api/patches/{patch_id}/checks/{check_id}/:
+ /api/{{ version_url }}patches/{patch_id}/checks/{check_id}/:
get:
description: Show a check.
operationId: checks_read
$ref: '#/components/schemas/Error'
tags:
- checks
- /api/people/:
+ /api/{{ version_url }}people/:
get:
description: List people.
operationId: people_list
$ref: '#/components/schemas/Error'
tags:
- people
- /api/people/{id}/:
+ /api/{{ version_url }}people/{id}/:
get:
description: Show a person.
operationId: people_read
$ref: '#/components/schemas/Error'
tags:
- people
- /api/projects/:
+ /api/{{ version_url }}projects/:
get:
description: List projects.
operationId: projects_list
$ref: '#/components/schemas/Project'
tags:
- projects
- /api/projects/{id}/:
+ /api/{{ version_url }}projects/{id}/:
get:
description: Show a project.
operationId: projects_read
$ref: '#/components/schemas/Error'
tags:
- projects
- /api/series/:
+ /api/{{ version_url }}series/:
get:
description: List series.
operationId: series_list
$ref: '#/components/schemas/Series'
tags:
- series
- /api/series/{id}/:
+ /api/{{ version_url }}series/{id}/:
get:
description: Show a series.
operationId: series_read
$ref: '#/components/schemas/Error'
tags:
- series
- /api/users/:
+ /api/{{ version_url }}users/:
get:
description: List users.
operationId: users_list
$ref: '#/components/schemas/Error'
tags:
- users
- /api/users/{id}/:
+ /api/{{ version_url }}users/{id}/:
get:
description: Show a user.
operationId: users_read
type: string
format: uri
readOnly: true
+{% if version > (1, 0) %}
web_url:
title: Web URL
type: string
format: uri
readOnly: true
+{% endif %}
project:
$ref: '#/components/schemas/ProjectEmbedded'
name:
title: ID
type: integer
readOnly: true
+{% if version > (1, 0) %}
web_url:
title: Web URL
type: string
format: uri
readOnly: true
+{% endif %}
msgid:
title: Message ID
type: string
type: string
format: uri
readOnly: true
+{% if version > (1, 0) %}
web_url:
title: Web URL
type: string
format: uri
readOnly: true
+{% endif %}
project:
$ref: '#/components/schemas/ProjectEmbedded'
msgid:
readOnly: true
allOf:
- $ref: '#/components/schemas/PersonEmbedded'
+{% if version > (1, 0) %}
mbox:
title: Mbox
type: string
format: uri
readOnly: true
+{% endif %}
series:
type: array
items:
$ref: '#/components/schemas/SeriesEmbedded'
readOnly: true
+{% if version > (1, 0) %}
comments:
title: Comments
type: string
format: uri
readOnly: true
+{% endif %}
CoverLetterDetail:
allOf:
- $ref: '#/components/schemas/CoverLetterList'
type: string
format: uri
readOnly: true
+{% if version > (1, 0) %}
web_url:
title: Web URL
type: string
format: uri
readOnly: true
+{% endif %}
project:
$ref: '#/components/schemas/ProjectEmbedded'
msgid:
items:
$ref: '#/components/schemas/SeriesEmbedded'
readOnly: true
+{% if version > (1, 0) %}
comments:
title: Comments
type: string
format: uri
readOnly: true
+{% endif %}
check:
title: Check
type: string
$ref: '#/components/schemas/UserEmbedded'
readOnly: true
uniqueItems: true
+{% if version > (1, 0) %}
subject_match:
title: Subject match
description: Regex to match the subject against if only part of emails
type: string
readOnly: true
maxLength: 64
+{% endif %}
Series:
type: object
properties:
type: string
format: uri
readOnly: true
+{% if version > (1, 0) %}
web_url:
title: Web URL
type: string
format: uri
readOnly: true
+{% endif %}
project:
$ref: '#/components/schemas/ProjectEmbedded'
name:
type: string
format: uri
readOnly: true
+{% if version > (1, 0) %}
web_url:
title: Web URL
type: string
format: uri
readOnly: true
+{% endif %}
msgid:
title: Message ID
type: string
type: string
format: uri
readOnly: true
+{% if version > (1, 0) %}
web_url:
title: Web URL
type: string
format: uri
readOnly: true
+{% endif %}
msgid:
title: Message ID
type: string
type: string
format: uri
readOnly: true
+{% if version > (1, 0) %}
web_url:
title: Web URL
type: string
format: uri
readOnly: true
+{% endif %}
name:
title: Name
description: An optional name to associate with the series, e.g. "John's PCI