feat: json-schema updates\nfeat: new route proposal

This commit is contained in:
2023-11-01 14:31:12 +01:00
parent 8466976b3c
commit 0de613969e
20 changed files with 327 additions and 131 deletions

View File

@@ -14,9 +14,8 @@
*/
import {Plugin} from '@openstapps/api-plugin';
import * as express from 'express';
import schema from '../../lib/schema.json';
import {SCMinimalRequest} from './protocol/request.js';
import {SCMinimalResponse} from './protocol/response.js';
import {requestSchema, SCMinimalRequest} from './protocol/request.js';
import {responseSchema, SCMinimalResponse} from './protocol/response.js';
/**
* The Plugin Class
@@ -25,9 +24,9 @@ import {SCMinimalResponse} from './protocol/response.js';
* TODO: rename the class
*/
export class MinimalPlugin extends Plugin {
requestSchema = schema.SCMinimalRequest;
requestSchema = requestSchema;
responseSchema = schema.SCMinimalResponse;
responseSchema = responseSchema;
/**
* Calculates the sum of a list of numbers

View File

@@ -19,7 +19,6 @@
* All incoming requests will look like this, this is being checked by the backend. You need to add the @validatable tag
* like shown below for the plugin to work. The request can have any layout you like.
* TODO: remove body of the interface and replace with your own layout
* @validatable
*/
export interface SCMinimalRequest {
/**

View File

@@ -19,7 +19,6 @@
* All your responses to the backend are required to look like this. You need to add the @validatable tag like shown
* below for the plugin to work. The response can have any layout you like.
* TODO: remove body of the interface and replace with your own layout
* @validatable
*/
export interface SCMinimalResponse {
/**
@@ -28,4 +27,4 @@ export interface SCMinimalResponse {
sum: number;
}
export {default as requestSchema} from 'schema:#SCMinimalResponse';
export {default as responseSchema} from 'schema:#SCMinimalResponse';

View File

@@ -0,0 +1,5 @@
declare module 'schema:*' {
import {JSONSchema7} from 'json-schema';
const schema: JSONSchema7;
export default schema;
}