worker: use openapi spec and generated code

Write an openapi spec for the worker API and use `deepmap/oapi-codegen`
to generate scaffolding for the server-side using the `labstack/echo`
server.

Incidentally, echo by default returns the errors in the same format that
worker API always has:

    { "message": "..." }

The API itself is unchanged to make this change easier to understand. It
will be changed to better suit our needs in future commits.
This commit is contained in:
Lars Karlitski 2020-09-05 14:59:30 +02:00 committed by Tom Gundersen
parent 396c2cedce
commit ad11ceecf4
112 changed files with 13721 additions and 389 deletions

View file

@ -0,0 +1,133 @@
openapi: 3.0.0
info:
title: worker
version: '1.0'
servers: []
paths:
/status:
get:
summary: status
tags: []
responses:
'200':
description: OK
headers: {}
content:
application/json:
schema:
type: object
properties:
status:
type: string
enum:
- OK
required:
- status
operationId: get-status
description: Simple status handler to check whether the service is up.
/job-queue/v1/jobs:
post:
summary: create-job
tags: []
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
additionalProperties: false
properties:
id:
type: string
format: uuid
manifest: {}
targets:
type: array
items: {}
required:
- id
- manifest
- targets
operationId: post-job-queue-v1-jobs
requestBody:
content:
application/json:
schema:
type: object
properties: {}
'/job-queue/v1/jobs/{job_id}':
parameters:
- schema:
type: string
name: job_id
in: path
required: true
get:
summary: get-job
tags: []
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
properties:
id:
type: string
format: uuid
canceled:
type: boolean
required:
- id
- canceled
operationId: get-job-queue-v1-jobs-job_id
patch:
summary: update-job
tags: []
responses: {}
operationId: patch-job-queue-v1-jobs-job_id
requestBody:
content:
application/json:
schema:
type: object
properties:
status:
type: string
enum:
- WAITING
- RUNNING
- FINISHED
- FAILED
result: {}
required:
- status
- result
'/job-queue/v1/jobs/{job_id}/artifacts/{name}':
parameters:
- schema:
type: string
name: job_id
in: path
required: true
- schema:
type: string
name: name
in: path
required: true
post:
summary: add-image
tags: []
responses:
'200':
description: OK
operationId: post-job-queue-v1-jobs-job_id-artifacts-name
requestBody:
content:
application/octet-stream:
schema:
type: string
components:
schemas: {}