Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[generate-examples] Include Min/Max in default example titles #1054

Merged
merged 2 commits into from
Oct 15, 2024
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
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}`,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to pattern used for example filenames

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"
}
}
}