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

- Fixes #935 
- Uses unique titles when first generating examples
- Still has unrelated bugs where title can be changed when updating existing examples
This commit is contained in:
Mike Harder 2024-10-15 15:34:12 -07:00 коммит произвёл GitHub
Родитель 2ed94305ee
Коммит bf50f770da
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
3 изменённых файлов: 10 добавлений и 6 удалений

Просмотреть файл

@ -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.

Просмотреть файл

@ -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 [];
}
@ -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, {}),
@ -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);
@ -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),

Просмотреть файл

@ -1,6 +1,6 @@
{
"name": "oav",
"version": "3.5.0",
"version": "3.5.1",
"author": {
"name": "Microsoft Corporation",
"email": "azsdkteam@microsoft.com",
@ -138,4 +138,4 @@
"jest-junit": {
"output": "test-results.xml"
}
}
}