add schema for manifests

This commit is contained in:
Jacob Overgaard
2022-08-24 16:03:35 +02:00
parent a185c1a885
commit d1b3f9464e
3 changed files with 163 additions and 0 deletions

View File

@@ -57,6 +57,22 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/ProblemDetails'
/manifests:
get:
operationId: Manifests
responses:
'200':
description: 200 response
content:
application/json:
schema:
$ref: '#/components/schemas/ManifestsResponse'
default:
description: default response
content:
application/json:
schema:
$ref: '#/components/schemas/ProblemDetails'
/server/status:
get:
operationId: GetStatus
@@ -341,6 +357,99 @@ components:
required:
- user
- telemetryLevel
ManifestStandardTypes:
type: string
enum:
- section
- propertyEditorUI
- dashboard
MetaSection:
type: object
properties:
pathname:
type: string
weight:
type: number
format: float
required:
- pathname
- weight
MetaPropertyEditorUI:
type: object
properties:
icon:
type: string
group:
type: string
required:
- icon
- group
MetaDashboard:
type: object
properties:
sections:
type: array
items:
type: string
pathname:
type: string
weight:
type: number
format: float
required:
- sections
- pathname
- weight
IManifestElement:
type: object
properties:
type:
$ref: '#/components/schemas/ManifestStandardTypes'
alias:
type: string
name:
type: string
js:
type: string
elementName:
type: string
meta:
oneOf:
- $ref: '#/components/schemas/MetaSection'
- $ref: '#/components/schemas/MetaPropertyEditorUI'
- $ref: '#/components/schemas/MetaDashboard'
required:
- type
- alias
- name
- js
- elementName
- meta
IManifestEntrypoint:
type: object
properties:
type:
type: string
enum:
- entrypoint
js:
type: string
required:
- type
- js
Manifest:
oneOf:
- $ref: '#/components/schemas/IManifestElement'
- $ref: '#/components/schemas/IManifestEntrypoint'
ManifestsResponse:
type: object
properties:
manifests:
type: array
items:
$ref: '#/components/schemas/Manifest'
required:
- manifests
ServerStatus:
type: string
enum:

View File

@@ -1,4 +1,5 @@
import './installer';
import './manifests';
import './server';
import './upgrader';
import './user';

View File

@@ -0,0 +1,53 @@
import { body, defaultResponse, endpoint, response } from '@airtasker/spot';
import { ProblemDetails } from './models';
@endpoint({ method: 'GET', path: '/manifests' })
export class Manifests {
@response({ status: 200 })
response(@body body: ManifestsResponse) {}
@defaultResponse
default(@body body: ProblemDetails) {}
}
export type Manifest = IManifestElement | IManifestEntrypoint;
export type ManifestStandardTypes = 'section' | 'propertyEditorUI' | 'dashboard';
export interface ManifestsResponse {
manifests: Manifest[];
}
export interface IManifest {
type: string;
}
export interface MetaSection {
pathname: string;
weight: number;
}
export interface MetaPropertyEditorUI {
icon: string;
group: string;
}
export interface MetaDashboard {
sections: string[];
pathname: string;
weight: number;
}
export interface IManifestElement extends IManifest {
type: ManifestStandardTypes;
alias: string;
name: string;
js: string;
elementName: string;
meta: MetaSection | MetaPropertyEditorUI | MetaDashboard;
}
export interface IManifestEntrypoint extends IManifest {
type: 'entrypoint';
js: string;
}