mirror of
https://github.com/Unleash/unleash.git
synced 2025-07-26 13:48:33 +02:00
feat: preliminary project applications schema (#6152)
Currently keeping flat structure and separate out into multiple requests(schemas) if needed. In future, we will also add dates.
This commit is contained in:
parent
bb2f88980c
commit
4a4196c66a
@ -193,6 +193,8 @@ import { advancedPlaygroundEnvironmentFeatureSchema } from './spec/advanced-play
|
|||||||
import { createFeatureNamingPatternSchema } from './spec/create-feature-naming-pattern-schema';
|
import { createFeatureNamingPatternSchema } from './spec/create-feature-naming-pattern-schema';
|
||||||
import { segmentStrategiesSchema } from './spec/segment-strategies-schema';
|
import { segmentStrategiesSchema } from './spec/segment-strategies-schema';
|
||||||
import { featureDependenciesSchema } from './spec/feature-dependencies-schema';
|
import { featureDependenciesSchema } from './spec/feature-dependencies-schema';
|
||||||
|
import { projectApplicationsSchema } from './spec/project-applications-schema';
|
||||||
|
import { projectApplicationSchema } from './spec/project-application-schema';
|
||||||
|
|
||||||
// Schemas must have an $id property on the form "#/components/schemas/mySchema".
|
// Schemas must have an $id property on the form "#/components/schemas/mySchema".
|
||||||
export type SchemaId = (typeof schemas)[keyof typeof schemas]['$id'];
|
export type SchemaId = (typeof schemas)[keyof typeof schemas]['$id'];
|
||||||
@ -322,6 +324,8 @@ export const schemas: UnleashSchemas = {
|
|||||||
playgroundSegmentSchema,
|
playgroundSegmentSchema,
|
||||||
playgroundStrategySchema,
|
playgroundStrategySchema,
|
||||||
profileSchema,
|
profileSchema,
|
||||||
|
projectApplicationSchema,
|
||||||
|
projectApplicationsSchema,
|
||||||
projectEnvironmentSchema,
|
projectEnvironmentSchema,
|
||||||
projectSchema,
|
projectSchema,
|
||||||
projectsSchema,
|
projectsSchema,
|
||||||
|
36
src/lib/openapi/spec/project-application-schema.ts
Normal file
36
src/lib/openapi/spec/project-application-schema.ts
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
import { FromSchema } from 'json-schema-to-ts';
|
||||||
|
|
||||||
|
export const projectApplicationSchema = {
|
||||||
|
$id: '#/components/schemas/projectApplicationSchema',
|
||||||
|
type: 'object',
|
||||||
|
additionalProperties: false,
|
||||||
|
required: ['appName', 'instanceId', 'sdkVersion', 'environment'],
|
||||||
|
description: 'A project application instance.',
|
||||||
|
properties: {
|
||||||
|
appName: {
|
||||||
|
type: 'string',
|
||||||
|
description:
|
||||||
|
'Name of the application that is using the SDK. This is the same as the appName in the SDK configuration.',
|
||||||
|
},
|
||||||
|
instanceId: {
|
||||||
|
type: 'string',
|
||||||
|
description:
|
||||||
|
'The unique identifier of the application instance. This is the same as the instanceId in the SDK configuration',
|
||||||
|
},
|
||||||
|
sdkVersion: {
|
||||||
|
type: 'string',
|
||||||
|
description:
|
||||||
|
'The version of the SDK that is being used by the application',
|
||||||
|
},
|
||||||
|
environment: {
|
||||||
|
type: 'string',
|
||||||
|
description:
|
||||||
|
'The environment that the application is running in. This is coming from token configured in the SDK configuration.',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
components: {},
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
export type ProjectApplicationSchema = FromSchema<
|
||||||
|
typeof projectApplicationSchema
|
||||||
|
>;
|
17
src/lib/openapi/spec/project-applications-schema.test.ts
Normal file
17
src/lib/openapi/spec/project-applications-schema.test.ts
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import { validateSchema } from '../validate';
|
||||||
|
import { ProjectApplicationsSchema } from './project-applications-schema';
|
||||||
|
|
||||||
|
test('projectApplicationsSchema', () => {
|
||||||
|
const data: ProjectApplicationsSchema = [
|
||||||
|
{
|
||||||
|
appName: 'my-weba-app',
|
||||||
|
instanceId: 'app1:3:4',
|
||||||
|
sdkVersion: '4.1.1',
|
||||||
|
environment: 'production',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
expect(
|
||||||
|
validateSchema('#/components/schemas/projectApplicationsSchema', data),
|
||||||
|
).toBeUndefined();
|
||||||
|
});
|
20
src/lib/openapi/spec/project-applications-schema.ts
Normal file
20
src/lib/openapi/spec/project-applications-schema.ts
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import { FromSchema } from 'json-schema-to-ts';
|
||||||
|
import { projectApplicationSchema } from './project-application-schema';
|
||||||
|
|
||||||
|
export const projectApplicationsSchema = {
|
||||||
|
$id: '#/components/schemas/projectApplicationsSchema',
|
||||||
|
type: 'array',
|
||||||
|
description: 'A list of project applications',
|
||||||
|
items: {
|
||||||
|
$ref: '#/components/schemas/projectApplicationSchema',
|
||||||
|
},
|
||||||
|
components: {
|
||||||
|
schemas: {
|
||||||
|
projectApplicationSchema,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
export type ProjectApplicationsSchema = FromSchema<
|
||||||
|
typeof projectApplicationsSchema
|
||||||
|
>;
|
Loading…
Reference in New Issue
Block a user