Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions packages/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -954,11 +954,6 @@ yargs
describe: 'Output File name',
type: 'string',
},
extended: {
describe:
'Generate config with populated values from description using success criteria',
type: 'boolean',
},
});
},
async (argv) => {
Expand Down
1 change: 0 additions & 1 deletion packages/respect-core/src/handlers/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { type CommandArgs } from '../types';
export type GenerateArazzoFileOptions = {
descriptionPath: string;
'output-file'?: string;
extended?: boolean;
};

const logger = DefaultLogger.getInstance();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,56 +42,12 @@ const BUNDLED_DESCRIPTION_MOCK = {
};

describe('generateTestConfig', () => {
it('should generate test config', async () => {
(bundleOpenApi as jest.Mock).mockReturnValue(BUNDLED_DESCRIPTION_MOCK);
expect(
await generateTestConfig({
descriptionPath: 'description.yaml',
extended: false,
})
).toEqual({
arazzo: '1.0.1',
info: {
title: 'Swagger Petstore',
version: '1.0.0',
},
sourceDescriptions: [
{
name: 'description',
type: 'openapi',
url: 'description.yaml',
},
],
workflows: [
{
workflowId: 'get-pet-workflow',
steps: [
{
operationId: '$sourceDescriptions.description.getPet',
stepId: 'get-pet-step',
},
],
},
{
workflowId: 'get-fact-workflow',
steps: [
{
operationId: '$sourceDescriptions.description.getFact',
stepId: 'get-fact-step',
},
],
},
],
});
});

it('should generate test config when output file is provided', async () => {
(bundleOpenApi as jest.Mock).mockReturnValue(BUNDLED_DESCRIPTION_MOCK);
expect(
await generateTestConfig({
descriptionPath: 'description.yaml',
'output-file': './final-test-location/output.yaml',
extended: false,
})
).toEqual({
arazzo: '1.0.1',
Expand All @@ -113,6 +69,7 @@ describe('generateTestConfig', () => {
{
operationId: '$sourceDescriptions.description.getPet',
stepId: 'get-pet-step',
successCriteria: [{ condition: '$statusCode == 200' }],
},
],
},
Expand All @@ -129,7 +86,7 @@ describe('generateTestConfig', () => {
});
});

it('should generate test config with extended', async () => {
it('should generate test config with', async () => {
(bundleOpenApi as jest.Mock).mockReturnValue(BUNDLED_DESCRIPTION_MOCK);
(getOperationFromDescription as jest.Mock).mockReturnValue({
responses: {
Expand All @@ -154,7 +111,6 @@ describe('generateTestConfig', () => {
expect(
await generateTestConfig({
descriptionPath: 'description.yaml',
extended: true,
})
).toEqual({
arazzo: '1.0.1',
Expand Down Expand Up @@ -193,12 +149,11 @@ describe('generateTestConfig', () => {
});
});

it('should generate extended test config with not existing description', async () => {
it('should generate test config with not existing description', async () => {
(bundleOpenApi as jest.Mock).mockReturnValue(undefined);
expect(
await generateTestConfig({
descriptionPath: 'description.yaml',
extended: false,
})
).toEqual({
arazzo: '1.0.1',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ import type { GenerateArazzoFileOptions } from '../../handlers/generate';
type WorkflowsFromDescriptionInput = {
descriptionPaths: any;
sourceDescriptionName: string;
options: {
extended?: boolean;
};
};

function generateParametersWithSuccessCriteria(
Expand All @@ -32,10 +29,8 @@ function generateOperationId(path: string, method: OperationMethod) {

function generateWorkflowsFromDescription({
descriptionPaths,
options,
sourceDescriptionName,
}: WorkflowsFromDescriptionInput): Workflow[] {
const { extended } = options;
const workflows = [] as Workflow[];

for (const pathItemKey in descriptionPaths) {
Expand Down Expand Up @@ -72,10 +67,9 @@ function generateWorkflowsFromDescription({
{
stepId: pathKey ? `${method}-${pathKey}-step` : `${method}-step`,
operationId: `$sourceDescriptions.${sourceDescriptionName}.${resolvedOperationId}`,
...(extended &&
generateParametersWithSuccessCriteria(
descriptionPaths[pathItemKey][method].responses
)),
...generateParametersWithSuccessCriteria(
descriptionPaths[pathItemKey][method].responses
),
} as unknown as Step,
],
});
Expand All @@ -98,7 +92,6 @@ function resolveDescriptionNameFromPath(descriptionPath: string): string {
export async function generateTestConfig({
descriptionPath,
'output-file': outputFile,
extended,
}: GenerateArazzoFileOptions) {
const { paths: pathsObject, info } = (await bundleOpenApi(descriptionPath, '')) || {};
const sourceDescriptionName = resolveDescriptionNameFromPath(descriptionPath);
Expand All @@ -121,7 +114,6 @@ export async function generateTestConfig({
],
workflows: generateWorkflowsFromDescription({
descriptionPaths: pathsObject,
options: { extended },
sourceDescriptionName,
}),
};
Expand Down
Loading