chore: use the original schema type intead
Signed-off-by: benjdlambert <ben@blam.sh>
This commit is contained in:
@@ -20,7 +20,7 @@ import { JsonObject, JsonValue } from '@backstage/types';
|
||||
import { TaskSecrets } from '../tasks';
|
||||
import { TemplateInfo } from '@backstage/plugin-scaffolder-common';
|
||||
import { UserEntity } from '@backstage/catalog-model';
|
||||
import { JSONSchema7 } from 'json-schema';
|
||||
import { Schema } from 'jsonschema';
|
||||
import {
|
||||
BackstageCredentials,
|
||||
LoggerService,
|
||||
@@ -175,8 +175,8 @@ export type TemplateAction<
|
||||
examples?: { description: string; example: string }[];
|
||||
supportsDryRun?: boolean;
|
||||
schema?: {
|
||||
input?: JSONSchema7;
|
||||
output?: JSONSchema7;
|
||||
input?: Schema;
|
||||
output?: Schema;
|
||||
};
|
||||
handler: (
|
||||
ctx: ActionContext<TActionInput, TActionOutput, TSchemaType>,
|
||||
|
||||
@@ -21,7 +21,7 @@ import { ScmIntegrationRegistry } from '@backstage/integration';
|
||||
import { TemplateActionOptions } from './createTemplateAction';
|
||||
import zodToJsonSchema from 'zod-to-json-schema';
|
||||
import { z } from 'zod';
|
||||
import { JSONSchema7 } from 'json-schema';
|
||||
import { Schema } from 'jsonschema';
|
||||
|
||||
/**
|
||||
* @public
|
||||
@@ -145,16 +145,16 @@ const isNativeZodSchema = (
|
||||
|
||||
export const parseSchemas = (
|
||||
action: TemplateActionOptions,
|
||||
): { inputSchema?: JSONSchema7; outputSchema?: JSONSchema7 } => {
|
||||
): { inputSchema?: Schema; outputSchema?: Schema } => {
|
||||
if (!action.schema) {
|
||||
return { inputSchema: undefined, outputSchema: undefined };
|
||||
}
|
||||
|
||||
if (isZodSchema(action.schema.input)) {
|
||||
return {
|
||||
inputSchema: zodToJsonSchema(action.schema.input) as JSONSchema7,
|
||||
inputSchema: zodToJsonSchema(action.schema.input) as Schema,
|
||||
outputSchema: isZodSchema(action.schema.output)
|
||||
? (zodToJsonSchema(action.schema.output) as JSONSchema7)
|
||||
? (zodToJsonSchema(action.schema.output) as Schema)
|
||||
: undefined,
|
||||
};
|
||||
}
|
||||
@@ -167,7 +167,7 @@ export const parseSchemas = (
|
||||
);
|
||||
|
||||
return {
|
||||
inputSchema: zodToJsonSchema(input) as JSONSchema7,
|
||||
inputSchema: zodToJsonSchema(input) as Schema,
|
||||
outputSchema: isNativeZodSchema(action.schema.output)
|
||||
? (zodToJsonSchema(
|
||||
z.object(
|
||||
@@ -175,7 +175,7 @@ export const parseSchemas = (
|
||||
Object.entries(action.schema.output).map(([k, v]) => [k, v(z)]),
|
||||
),
|
||||
),
|
||||
) as JSONSchema7)
|
||||
) as Schema)
|
||||
: undefined,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user