Skip to content

Commit

Permalink
feat(ocm): Incorporate openapi router
Browse files Browse the repository at this point in the history
  • Loading branch information
dzemanov committed Aug 13, 2024
1 parent d5cc1fe commit 840ef26
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions plugins/ocm-backend/src/service/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import {
import { createPermissionIntegrationRouter } from '@backstage/plugin-permission-node';

import express from 'express';
import Router from 'express-promise-router';
import { Request } from 'express-serve-static-core';

import {
Expand Down Expand Up @@ -63,6 +62,7 @@ import {
translateOCMToResource,
translateResourceToOCM,
} from '../helpers/parser';
import { createOpenApiRouter } from '../schema/openapi.generated';
import { ManagedClusterInfo } from '../types';

export interface RouterOptions {
Expand All @@ -73,13 +73,13 @@ export interface RouterOptions {
httpAuth?: HttpAuthService;
}

const buildRouter = (
const buildRouter = async (
config: Config,
logger: LoggerService,
httpAuth: HttpAuthService,
permissions: PermissionsService,
) => {
const router = Router();
const router = await createOpenApiRouter();

const permissionsIntegrationRouter = createPermissionIntegrationRouter({
permissions: ocmEntityPermissions,
Expand Down Expand Up @@ -198,7 +198,7 @@ export async function createRouter(

const { httpAuth } = createLegacyAuthAdapters(options);

return buildRouter(config, logger, httpAuth, permissions);
return await buildRouter(config, logger, httpAuth, permissions);
}

export const ocmPlugin = createBackendPlugin({
Expand All @@ -213,7 +213,7 @@ export const ocmPlugin = createBackendPlugin({
permissions: coreServices.permissions,
},
async init({ config, logger, http, httpAuth, permissions }) {
http.use(buildRouter(config, logger, httpAuth, permissions));
http.use(await buildRouter(config, logger, httpAuth, permissions));
},
});
},
Expand Down

0 comments on commit 840ef26

Please sign in to comment.