Skip to content

Commit

Permalink
[generate-examples] Include Min/Max in default example titles (#1054)
Browse files Browse the repository at this point in the history
- Fixes #935 
- Uses unique titles when first generating examples
- Still has unrelated bugs where title can be changed when updating existing examples
  • Loading branch information
mikeharder authored Oct 15, 2024
1 parent 2ed9430 commit bf50f77
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log - oav

## 10/15/2024 3.5.1

- During example generation, include min/max in default titles.

## 09/12/2024 3.5.0

- Add names of `Passed Operations` in the HTML and JSON reports.
Expand Down
8 changes: 4 additions & 4 deletions lib/generator/exampleGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export default class Generator {
let example;
console.log(`start generated example for ${operationId}, rule:${rule.ruleName}`);
if (!this.shouldMock) {
example = this.getExampleFromPayload(operationId, specItem);
example = this.getExampleFromPayload(operationId, specItem, rule);
if (!example) {
return [];
}
Expand All @@ -186,7 +186,7 @@ export default class Generator {
? specItem.content.summary
: specItem.content.description
? specItem.content.description
: operationId,
: `${operationId}_${rule.exampleNamePostfix}`,
operationId: operationId,
parameters: {},
responses: this.extractResponse(specItem, {}),
Expand Down Expand Up @@ -366,7 +366,7 @@ export default class Generator {
return example;
}

private getExampleFromPayload(operationId: string, specItem: any) {
private getExampleFromPayload(operationId: string, specItem: any, rule: ExampleRule) {
if (this.payloadDir) {
const subPaths = path.dirname(this.specFilePath).split(/\\|\//).slice(-3).join("/");
const payloadDir = path.join(this.payloadDir, subPaths);
Expand All @@ -387,7 +387,7 @@ export default class Generator {
? specItem.content.summary
: specItem.content.description
? specItem.content.description
: operationId,
: `${operationId}_${rule.exampleNamePostfix}`,
operationId: operationId,
parameters: this.extractRequest(specItem, payload),
responses: this.extractResponse(specItem, payload),
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "oav",
"version": "3.5.0",
"version": "3.5.1",
"author": {
"name": "Microsoft Corporation",
"email": "azsdkteam@microsoft.com",
Expand Down Expand Up @@ -138,4 +138,4 @@
"jest-junit": {
"output": "test-results.xml"
}
}
}

0 comments on commit bf50f77

Please sign in to comment.