Skip to content

Commit 7cd0a37

Browse files
feat: remove extendend option from generate-arazzo command (#1930)
1 parent 61b3877 commit 7cd0a37

File tree

4 files changed

+6
-65
lines changed

4 files changed

+6
-65
lines changed

packages/cli/src/index.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -954,11 +954,6 @@ yargs
954954
describe: 'Output File name',
955955
type: 'string',
956956
},
957-
extended: {
958-
describe:
959-
'Generate config with populated values from description using success criteria',
960-
type: 'boolean',
961-
},
962957
});
963958
},
964959
async (argv) => {

packages/respect-core/src/handlers/generate.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { type CommandArgs } from '../types';
99
export type GenerateArazzoFileOptions = {
1010
descriptionPath: string;
1111
'output-file'?: string;
12-
extended?: boolean;
1312
};
1413

1514
const logger = DefaultLogger.getInstance();

packages/respect-core/src/modules/__tests__/test-config-generator/generate-test-config.test.ts

Lines changed: 3 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -42,56 +42,12 @@ const BUNDLED_DESCRIPTION_MOCK = {
4242
};
4343

4444
describe('generateTestConfig', () => {
45-
it('should generate test config', async () => {
46-
(bundleOpenApi as jest.Mock).mockReturnValue(BUNDLED_DESCRIPTION_MOCK);
47-
expect(
48-
await generateTestConfig({
49-
descriptionPath: 'description.yaml',
50-
extended: false,
51-
})
52-
).toEqual({
53-
arazzo: '1.0.1',
54-
info: {
55-
title: 'Swagger Petstore',
56-
version: '1.0.0',
57-
},
58-
sourceDescriptions: [
59-
{
60-
name: 'description',
61-
type: 'openapi',
62-
url: 'description.yaml',
63-
},
64-
],
65-
workflows: [
66-
{
67-
workflowId: 'get-pet-workflow',
68-
steps: [
69-
{
70-
operationId: '$sourceDescriptions.description.getPet',
71-
stepId: 'get-pet-step',
72-
},
73-
],
74-
},
75-
{
76-
workflowId: 'get-fact-workflow',
77-
steps: [
78-
{
79-
operationId: '$sourceDescriptions.description.getFact',
80-
stepId: 'get-fact-step',
81-
},
82-
],
83-
},
84-
],
85-
});
86-
});
87-
8845
it('should generate test config when output file is provided', async () => {
8946
(bundleOpenApi as jest.Mock).mockReturnValue(BUNDLED_DESCRIPTION_MOCK);
9047
expect(
9148
await generateTestConfig({
9249
descriptionPath: 'description.yaml',
9350
'output-file': './final-test-location/output.yaml',
94-
extended: false,
9551
})
9652
).toEqual({
9753
arazzo: '1.0.1',
@@ -113,6 +69,7 @@ describe('generateTestConfig', () => {
11369
{
11470
operationId: '$sourceDescriptions.description.getPet',
11571
stepId: 'get-pet-step',
72+
successCriteria: [{ condition: '$statusCode == 200' }],
11673
},
11774
],
11875
},
@@ -129,7 +86,7 @@ describe('generateTestConfig', () => {
12986
});
13087
});
13188

132-
it('should generate test config with extended', async () => {
89+
it('should generate test config with', async () => {
13390
(bundleOpenApi as jest.Mock).mockReturnValue(BUNDLED_DESCRIPTION_MOCK);
13491
(getOperationFromDescription as jest.Mock).mockReturnValue({
13592
responses: {
@@ -154,7 +111,6 @@ describe('generateTestConfig', () => {
154111
expect(
155112
await generateTestConfig({
156113
descriptionPath: 'description.yaml',
157-
extended: true,
158114
})
159115
).toEqual({
160116
arazzo: '1.0.1',
@@ -193,12 +149,11 @@ describe('generateTestConfig', () => {
193149
});
194150
});
195151

196-
it('should generate extended test config with not existing description', async () => {
152+
it('should generate test config with not existing description', async () => {
197153
(bundleOpenApi as jest.Mock).mockReturnValue(undefined);
198154
expect(
199155
await generateTestConfig({
200156
descriptionPath: 'description.yaml',
201-
extended: false,
202157
})
203158
).toEqual({
204159
arazzo: '1.0.1',

packages/respect-core/src/modules/test-config-generator/generate-test-config.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ import type { GenerateArazzoFileOptions } from '../../handlers/generate';
88
type WorkflowsFromDescriptionInput = {
99
descriptionPaths: any;
1010
sourceDescriptionName: string;
11-
options: {
12-
extended?: boolean;
13-
};
1411
};
1512

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

3330
function generateWorkflowsFromDescription({
3431
descriptionPaths,
35-
options,
3632
sourceDescriptionName,
3733
}: WorkflowsFromDescriptionInput): Workflow[] {
38-
const { extended } = options;
3934
const workflows = [] as Workflow[];
4035

4136
for (const pathItemKey in descriptionPaths) {
@@ -72,10 +67,9 @@ function generateWorkflowsFromDescription({
7267
{
7368
stepId: pathKey ? `${method}-${pathKey}-step` : `${method}-step`,
7469
operationId: `$sourceDescriptions.${sourceDescriptionName}.${resolvedOperationId}`,
75-
...(extended &&
76-
generateParametersWithSuccessCriteria(
77-
descriptionPaths[pathItemKey][method].responses
78-
)),
70+
...generateParametersWithSuccessCriteria(
71+
descriptionPaths[pathItemKey][method].responses
72+
),
7973
} as unknown as Step,
8074
],
8175
});
@@ -98,7 +92,6 @@ function resolveDescriptionNameFromPath(descriptionPath: string): string {
9892
export async function generateTestConfig({
9993
descriptionPath,
10094
'output-file': outputFile,
101-
extended,
10295
}: GenerateArazzoFileOptions) {
10396
const { paths: pathsObject, info } = (await bundleOpenApi(descriptionPath, '')) || {};
10497
const sourceDescriptionName = resolveDescriptionNameFromPath(descriptionPath);
@@ -121,7 +114,6 @@ export async function generateTestConfig({
121114
],
122115
workflows: generateWorkflowsFromDescription({
123116
descriptionPaths: pathsObject,
124-
options: { extended },
125117
sourceDescriptionName,
126118
}),
127119
};

0 commit comments

Comments
 (0)