fix(scaffolder): schema adjusted

This commit is contained in:
Ivan Shmidt
2020-07-01 18:51:33 +02:00
parent e4dd9bd5b2
commit 34399824a6
6 changed files with 42 additions and 4 deletions
+1
View File
@@ -22,6 +22,7 @@
"dependencies": {
"@backstage/config": "^0.1.1-alpha.12",
"@types/yup": "^0.28.2",
"json-schema": "^0.2.5",
"lodash": "^4.17.15",
"uuid": "^8.0.0",
"yup": "^0.29.1"
@@ -33,6 +33,22 @@ describe('TemplateEntityV1alpah1', () => {
},
spec: {
type: 'cookiecutter',
schema: {
$schema: 'http://json-schema.org/draft-07/schema#',
required: ['storePath', 'owner'],
properties: {
owner: {
type: 'string',
title: 'Owner',
description: 'Who is going to own this component',
},
storePath: {
type: 'string',
title: 'Store path',
description: 'GitHub store path in org/repo format',
},
},
},
},
};
policy = new TemplateEntityV1alpha1Policy();
@@ -16,7 +16,7 @@
import * as yup from 'yup';
import type { Entity } from '../entity/Entity';
import type { EntityPolicy } from '../types';
import type { EntityPolicy, JSONSchema } from '../types';
const API_VERSION = ['backstage.io/v1alpha1', 'backstage.io/v1beta1'] as const;
const KIND = 'Template' as const;
@@ -27,6 +27,7 @@ export interface TemplateEntityV1alpha1 extends Entity {
spec: {
type: string;
path?: string;
schema: JSONSchema;
};
}
@@ -41,6 +42,7 @@ export class TemplateEntityV1alpha1Policy implements EntityPolicy {
.object({
type: yup.string().required().min(1),
path: yup.string(),
schema: yup.object().required(),
})
.required(),
});
+4
View File
@@ -14,6 +14,8 @@
* limitations under the License.
*/
import { JsonValue } from '@backstage/config';
import { JSONSchema7 } from 'json-schema';
import type { Entity } from './entity/Entity';
/**
@@ -30,3 +32,5 @@ export type EntityPolicy = {
*/
enforce(entity: Entity): Promise<Entity>;
};
export type JSONSchema = JSONSchema7 & { [key in string]?: JsonValue };