mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-18 23:52:52 +00:00
refactor: revert json schema changes
This commit is contained in:
@@ -14,8 +14,9 @@
|
||||
*/
|
||||
import {Plugin} from '@openstapps/api-plugin';
|
||||
import * as express from 'express';
|
||||
import {requestSchema, SCMinimalRequest} from './protocol/request.js';
|
||||
import {responseSchema, SCMinimalResponse} from './protocol/response.js';
|
||||
import schema from '../../lib/schema.json';
|
||||
import {SCMinimalRequest} from './protocol/request.js';
|
||||
import {SCMinimalResponse} from './protocol/response.js';
|
||||
|
||||
/**
|
||||
* The Plugin Class
|
||||
@@ -24,9 +25,9 @@ import {responseSchema, SCMinimalResponse} from './protocol/response.js';
|
||||
* TODO: rename the class
|
||||
*/
|
||||
export class MinimalPlugin extends Plugin {
|
||||
requestSchema = requestSchema;
|
||||
requestSchema = schema.SCMinimalRequest;
|
||||
|
||||
responseSchema = responseSchema;
|
||||
responseSchema = schema.SCMinimalResponse;
|
||||
|
||||
/**
|
||||
* Calculates the sum of a list of numbers
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
* 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 {
|
||||
/**
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
* 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 {
|
||||
/**
|
||||
@@ -27,4 +28,4 @@ export interface SCMinimalResponse {
|
||||
sum: number;
|
||||
}
|
||||
|
||||
export {default as responseSchema} from 'schema:#SCMinimalResponse';
|
||||
export {default as requestSchema} from 'schema:#SCMinimalResponse';
|
||||
|
||||
5
examples/minimal-plugin/src/schemas.d.ts
vendored
5
examples/minimal-plugin/src/schemas.d.ts
vendored
@@ -1,5 +0,0 @@
|
||||
declare module 'schema:*' {
|
||||
import {JSONSchema7} from 'json-schema';
|
||||
const schema: JSONSchema7;
|
||||
export default schema;
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import {defineConfig} from 'tsup';
|
||||
import {esbuildJsonSchemaPlugin} from '@openstapps/json-schema-generator';
|
||||
import {jsonSchemaPlugin} from '@openstapps/json-schema-generator';
|
||||
|
||||
export default defineConfig({
|
||||
entry: ['src/app.ts'],
|
||||
@@ -7,6 +7,6 @@ export default defineConfig({
|
||||
clean: true,
|
||||
format: 'esm',
|
||||
outDir: 'lib',
|
||||
noExternal: [/schema:.*/],
|
||||
esbuildPlugins: [esbuildJsonSchemaPlugin],
|
||||
noExternal: [/.*:schema#.*/],
|
||||
plugins: [jsonSchemaPlugin('schema.json')],
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user