Add the operation path to the generated operation ID (#946)

This commit is contained in:
Martin Rademacher 2021-06-10 15:16:13 +12:00 committed by GitHub
parent 1594634cb7
commit b249ed1c52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 10 deletions

View File

@ -7,7 +7,7 @@ paths:
get: get:
tags: tags:
- Products - Products
operationId: 6a7963b92da560b8d7f16b0fdba847ef operationId: 664dbedf1321cf9bebfe80ce09f95b6a
parameters: parameters:
- -
name: id name: id

View File

@ -7,7 +7,7 @@ paths:
get: get:
tags: tags:
- Products - Products
operationId: ecd4da135afcd55d0c1308b260c38060 operationId: 133f11c148f628647767a323bf78c68d
responses: responses:
default: default:
description: 'successful operation' description: 'successful operation'
@ -18,7 +18,7 @@ paths:
patch: patch:
tags: tags:
- Products - Products
operationId: ccfcd39d70ad7d7f367a54908d3a0db6 operationId: 7f26f01759fb7245bf4f7138a3717e0f
requestBody: requestBody:
$ref: '#/components/requestBodies/product_in_body' $ref: '#/components/requestBodies/product_in_body'
responses: responses:
@ -35,7 +35,7 @@ paths:
post: post:
tags: tags:
- Products - Products
operationId: ce046e4e523b43847bf9a5066145bda0 operationId: 779b6345f19f6b865527e6bd67819d2d
parameters: parameters:
- -
$ref: '#/components/requestBodies/product_in_body' $ref: '#/components/requestBodies/product_in_body'

View File

@ -7,7 +7,7 @@ paths:
delete: delete:
tags: tags:
- Entities - Entities
operationId: e87b6b3d88068b6863f408c0ce77528f operationId: 372df3207489872fd3c775f623f8340f
parameters: parameters:
- -
name: id name: id
@ -23,7 +23,7 @@ paths:
get: get:
tags: tags:
- Products - Products
operationId: d3096ee893a30bd6cd88099036a5cb3f operationId: 569395beea865794cbde04d55c0ba4a2
parameters: parameters:
- -
name: product_id name: product_id

View File

@ -58,7 +58,7 @@ class OperationId
} else { } else {
$operationId = $context->method; $operationId = $context->method;
} }
$operationId = strtoupper($operation->method).'::'.$operationId; $operationId = strtoupper($operation->method).'::'.$operation->path.'::'.$operationId;
$operation->operationId = $this->hash ? md5($operationId) : $operationId; $operation->operationId = $this->hash ? md5($operationId) : $operationId;
} }
} }

View File

@ -29,14 +29,14 @@ class OperationIdTest extends OpenApiTestCase
$this->assertSame('entity/{id}', $operations[0]->path); $this->assertSame('entity/{id}', $operations[0]->path);
$this->assertInstanceOf(Get::class, $operations[0]); $this->assertInstanceOf(Get::class, $operations[0]);
$this->assertSame('GET::OpenApi\Tests\Fixtures\Processors\EntityControllerClass::getEntry', $operations[0]->operationId); $this->assertSame('GET::entity/{id}::OpenApi\Tests\Fixtures\Processors\EntityControllerClass::getEntry', $operations[0]->operationId);
$this->assertSame('entity/{id}', $operations[1]->path); $this->assertSame('entity/{id}', $operations[1]->path);
$this->assertInstanceOf(Post::class, $operations[1]); $this->assertInstanceOf(Post::class, $operations[1]);
$this->assertSame('POST::OpenApi\Tests\Fixtures\Processors\EntityControllerInterface::updateEntity', $operations[1]->operationId); $this->assertSame('POST::entity/{id}::OpenApi\Tests\Fixtures\Processors\EntityControllerInterface::updateEntity', $operations[1]->operationId);
$this->assertSame('entities/{id}', $operations[2]->path); $this->assertSame('entities/{id}', $operations[2]->path);
$this->assertInstanceOf(Delete::class, $operations[2]); $this->assertInstanceOf(Delete::class, $operations[2]);
$this->assertSame('DELETE::OpenApi\Tests\Fixtures\Processors\EntityControllerTrait::deleteEntity', $operations[2]->operationId); $this->assertSame('DELETE::entities/{id}::OpenApi\Tests\Fixtures\Processors\EntityControllerTrait::deleteEntity', $operations[2]->operationId);
} }
} }