Skip to content

Commit

Permalink
feat: application overview issues schema (#6329)
Browse files Browse the repository at this point in the history
  • Loading branch information
sjaanus authored Feb 23, 2024
1 parent 12ff4ab commit 8228518
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useMemo } from 'react';
import { Avatar, CircularProgress, Icon, Link } from '@mui/material';
import { Avatar, Icon, Link } from '@mui/material';
import { Warning } from '@mui/icons-material';
import { styles as themeStyles } from 'component/common';
import { PageContent } from 'component/common/PageContent/PageContent';
Expand Down
2 changes: 2 additions & 0 deletions src/lib/openapi/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ import { projectApplicationSdkSchema } from './spec/project-application-sdk-sche
import { rolesSchema } from './spec/roles-schema';
import { applicationOverviewSchema } from './spec/application-overview-schema';
import { applicationOverviewEnvironmentSchema } from './spec/application-overview-environment-schema';
import { applicationOverviewIssuesSchema } from './spec/application-overview-issues-schema';

// Schemas must have an $id property on the form "#/components/schemas/mySchema".
export type SchemaId = (typeof schemas)[keyof typeof schemas]['$id'];
Expand Down Expand Up @@ -248,6 +249,7 @@ export const schemas: UnleashSchemas = {
apiTokensSchema,
applicationSchema,
applicationOverviewSchema,
applicationOverviewIssuesSchema,
applicationOverviewEnvironmentSchema,
applicationUsageSchema,
applicationsSchema,
Expand Down
30 changes: 30 additions & 0 deletions src/lib/openapi/spec/application-overview-issues-schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { FromSchema } from 'json-schema-to-ts';

export const applicationOverviewIssuesSchema = {
$id: '#/components/schemas/applicationOverviewIssuesSchema',
type: 'object',
description: 'This list of issues that might be wrong with the application',
additionalProperties: false,
required: ['type', 'items'],
properties: {
type: {
type: 'string',
enum: ['missingFeature', 'missingStrategy'],
description: 'The name of this action.',
},
items: {
type: 'array',
items: {
type: 'string',
},
description:
'The list of issues that might be wrong with the application',
example: ['feature1', 'feature2'],
},
},
components: {},
} as const;

export type ApplicationOverviewIssuesSchema = FromSchema<
typeof applicationOverviewIssuesSchema
>;
4 changes: 4 additions & 0 deletions src/lib/openapi/spec/application-overview-schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ test('applicationOverviewSchema', () => {
const app = {
projects: ['default', 'dx'],
featureCount: 12,
issues: [
{ type: 'missingFeature', items: ['feature1'] },
{ type: 'missingStrategy', items: ['strategy1'] },
],
environments: [
{
name: 'production',
Expand Down
10 changes: 10 additions & 0 deletions src/lib/openapi/spec/application-overview-schema.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { FromSchema } from 'json-schema-to-ts';
import { applicationOverviewEnvironmentSchema } from './application-overview-environment-schema';
import { applicationOverviewIssuesSchema } from './application-overview-issues-schema';

export const applicationOverviewSchema = {
$id: '#/components/schemas/applicationOverviewSchema',
Expand Down Expand Up @@ -31,10 +32,19 @@ export const applicationOverviewSchema = {
$ref: '#/components/schemas/applicationOverviewEnvironmentSchema',
},
},
issues: {
description:
'This list of issues that might be wrong with the application',
type: 'array',
items: {
$ref: '#/components/schemas/applicationOverviewIssuesSchema',
},
},
},
components: {
schemas: {
applicationOverviewEnvironmentSchema,
applicationOverviewIssuesSchema,
},
},
} as const;
Expand Down

0 comments on commit 8228518

Please sign in to comment.