Skip to content

Commit

Permalink
fix(disatch): Fix open api schema
Browse files Browse the repository at this point in the history
  • Loading branch information
bilalshaikh42 committed Apr 16, 2021
1 parent 1f6c4fc commit ff15503
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import {
Post,
} from '@nestjs/common';
import { ClientProxy } from '@nestjs/microservices';
import { ApiBody, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
import { ApiBody, ApiOperation, ApiTags } from '@nestjs/swagger';
import { refreshImageBody } from './image.dto';

@Controller('images')
@ApiResponse({})

@ApiTags('Internal management')
export class ImagesController {
constructor(@Inject('NATS_CLIENT') private client: ClientProxy) {}
Expand Down
5 changes: 5 additions & 0 deletions biosimulations/apps/dispatch-api/src/logs/logs.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export class LogsController {
throw new NotImplementedException('Not Implemented');
}
@ApiResponse({
status: 200,
type: CombineArchiveLog,
})
@Get(':id')
Expand All @@ -65,6 +66,10 @@ export class LogsController {
}

@Post()
@ApiResponse({
status: 201,
type: CombineArchiveLog,
})
public async createLogs(
@Body() body: CreateSimulationRunLogBody,
): Promise<CombineArchiveLog> {
Expand Down
24 changes: 15 additions & 9 deletions biosimulations/apps/dispatch-api/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ import { NestFactory } from '@nestjs/core';
import { AppModule } from './app/app.module';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
import { CustomOrigin } from '@nestjs/common/interfaces/external/cors-options.interface';
import { SecuritySchemeObject } from '@nestjs/swagger/dist/interfaces/open-api-spec.interface';
import {
ScopesObject,
SecuritySchemeObject,
} from '@nestjs/swagger/dist/interfaces/open-api-spec.interface';
import { ConfigService } from '@nestjs/config';
import { json } from 'body-parser';
import { Resolver } from '@stoplight/json-ref-resolver';
Expand Down Expand Up @@ -79,7 +82,7 @@ async function bootstrap() {
{
name: 'Authentication testing',
description:
'Operations for checking whether a user is logged in and retrieving information about a user\'s privileges.',
"Operations for checking whether a user is logged in and retrieving information about a user's privileges.",
},
{
name: 'Internal management',
Expand Down Expand Up @@ -112,11 +115,12 @@ async function bootstrap() {
builder.addTag(tag.name, tag.description);
}

const scopes = [
'read:SimulationRuns',
'write:SimulationRuns',
'delete:SimulationsRuns',
];
const scopes: ScopesObject = {
'read:SimulationRuns': 'Get information about a submitted run',
'write:SimulationRuns': 'Modify a run, including status',
'delete:SimulationsRuns': 'Delete runs from the database',
// TODO add all scopes/find a way to automate this from auth0
};
const authorizationUrl =
'https://auth.biosimulations.org/authorize?audience=dispatch.biosimulations.org';
const openIdConnectUrl =
Expand Down Expand Up @@ -163,7 +167,7 @@ async function bootstrap() {
customCss: removeIcon,
swaggerOptions: {
oauth: {
clientId: 'pMatIe0TqLPbnXBn6gcDjdjnpIrlKG3a',
clientId: clientId,
},
//tagsSorter: 'alpha',
operationsSorter: 'alpha',
Expand All @@ -177,7 +181,9 @@ async function bootstrap() {
const resolver = new Resolver();
const resolvedDocument = await resolver.resolve(document);
const schema = resolvedDocument.result.components.schemas.CombineArchiveLog;
httpAdapter.get('/schema/CombineArchiveLog.json', (req, res) => res.json(toJsonSchema(schema)));
httpAdapter.get('/schema/CombineArchiveLog.json', (req, res) =>
res.json(toJsonSchema(schema)),
);

const configService = app.get(ConfigService);
const limit = configService.get('server.limit');
Expand Down
10 changes: 10 additions & 0 deletions biosimulations/apps/dispatch-service/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Module, HttpModule } from '@nestjs/common';
import { BullModule } from '@nestjs/bull';

import { HpcService } from './services/hpc/hpc.service';
import { SbatchService } from './services/sbatch/sbatch.service';
Expand Down Expand Up @@ -27,6 +28,15 @@ import { LogService } from './results/log.service';
SharedNatsClientModule,
DispatchNestClientModule,
ScheduleModule.forRoot(),
BullModule.forRoot({
redis: {
host: 'localhost',
port: 6379,
},
}),
BullModule.registerQueue({
name: 'jobmonitor',
}),
],
controllers: [SubmissionController, ResultsController],
providers: [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Injectable } from '@nestjs/common';
import { Queue } from 'bull';
import { InjectQueue } from '@nestjs/bull';

@Injectable()
export class MonitoringService {
constructor(@InjectQueue('jobmonitoring') private monitorQueue: Queue) {}
}
10 changes: 7 additions & 3 deletions biosimulations/apps/dispatch/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ const routes: Routes = [
{
path: 'create',
loadChildren: () =>
import('apps/dispatch/src/app/components/create-simulation-project/create-simulation-project.module').then(
(m) => m.CreateSimulationProjectModule,
),
// eslint-disable-next-line @nrwl/nx/enforce-module-boundaries
import(
'apps/dispatch/src/app/components/create-simulation-project/create-simulation-project.module'
).then((m) => m.CreateSimulationProjectModule),
data: {
breadcrumb: 'Create simulation project',
},
Expand All @@ -40,6 +41,7 @@ const routes: Routes = [
{
path: 'run',
loadChildren: () =>
// eslint-disable-next-line @nrwl/nx/enforce-module-boundaries
import('apps/dispatch/src/app/components/run/run.module').then(
(m) => m.RunModule,
),
Expand All @@ -51,6 +53,7 @@ const routes: Routes = [
{
path: 'simulations',
loadChildren: () =>
// eslint-disable-next-line @nrwl/nx/enforce-module-boundaries
import(
'apps/dispatch/src/app/components/simulations/simulations.module'
).then((m) => m.SimulationsModule),
Expand All @@ -61,6 +64,7 @@ const routes: Routes = [
{
path: 'help',
loadChildren: () =>
// eslint-disable-next-line @nrwl/nx/enforce-module-boundaries
import('apps/dispatch/src/app/components/help/help.module').then(
(m) => m.HelpModule,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class SimulationRun {
@ApiProperty({
type: String,
description: 'The name of a BioSimulators compliant simulator',
examples: ['vcell', 'gillespy2', 'cobrapy', 'copasi', 'bionetgen', 'tellurium'],
example: 'vcell',
externalDocs: {
url: 'https://biosimulators.org/simulators',
description: 'Simulators List',
Expand Down

0 comments on commit ff15503

Please sign in to comment.