-
Notifications
You must be signed in to change notification settings - Fork 280
Canonical transaction paths #227
Comments
Implemented here apiaryio/blueprint-transactions#1. To be implemented in Dredd's hook handler. |
I am proposing a slightly different approach. IntroductionThe proposal below attempts to address following issues:
Transaction Path (string)Canonical, deterministic way how to address a single HTTP Transaction (single Request-Response pair). It can serve as a unique identifier of the HTTP Transaction. The Transaction Path string is a serialization of the
Components
ExamplesFull Notation with Multiple Request-Response Pairs# Sample API Name
## Group Sample Group Name
### Sample Resource Name [/resource]
#### Sample Action Name [POST]
+ Request (application/json)
+ Response 200 (application/json)
+ Request (application/xml)
+ Response 200 (application/xml) Transaction Path Origin: {
"apiName": "Sample API Name",
"resourceGroupName": "Sample Group Name",
"resourceName": "Sample Resource Name",
"actionName": "Sample Action Name",
"requestName": "(application/xml)",
"responseName": "200 (application/xml)",
} Transaction Path:
Full Notation with Implicit Request# Sample API Name
## Group Sample Group Name
### Sample Resource Name [/resource]
#### Sample Action Name [POST]
+ Response 200 Transaction Path Origin: {
"apiName": "Sample API Name",
"resourceGroupName": "Sample Group Name",
"resourceName": "Sample Resource Name",
"actionName": "Sample Action Name",
"requestName": "",
"responseName": "200",
} Transaction Path:
Full Notation with Multiple Requests within One Transaction Example# Sample API Name
## Group Sample Group Name
### Sample Resource Name [/resource]
#### Sample Action Name [POST]
+ Response 200 (text/plain)
+ Request Sample Request Name (application/json)
+ Request Another Sample Request Name (application/json)
+ Request (application/json)
+ Response 200 (application/json)
+ Response 401 (application/json) Transaction Path Origin: {
"apiName": "Sample API Name",
"resourceGroupName": "Sample Group Name",
"resourceName": "Sample Resource Name",
"actionName": "Sample Action Name",
"requestName": "Another Sample Request Name (application/json)",
"responseName": "401 (application/json)",
} Transaction Path:
Full Notation with Multiple Requests Each Having Multiple Responses# Sample API Name
## Group Sample Group Name
### Sample Resource Name [/resource]
#### Sample Action Name [POST]
+ Response 200 (application/json)
+ Response 401 (application/json)
+ Response 500 (application/json)
+ Request (application/xml)
+ Response 200 (application/xml)
+ Response 500 (application/xml) Transaction Path Origin: {
"apiName": "Sample API Name",
"resourceGroupName": "Sample Group Name",
"resourceName": "Sample Resource Name",
"actionName": "Sample Action Name",
"requestName": "",
"responseName": "401 (application/json)",
} Transaction Path:
Full Notation with Resolution of the Effective Content-Type Value# Sample API Name
## Group Sample Group Name
### Sample Resource Name [/resource]
#### Sample Action Name [POST]
+ Request
+ Headers
X-Request-ID: 30f14c6c1fc85cba12bfd093aa8f90e3
Content-Type: application/hal+json
+ Response 200 Transaction Path Origin: {
"apiName": "Sample API Name",
"resourceGroupName": "Sample Group Name",
"resourceName": "Sample Resource Name",
"actionName": "Sample Action Name",
"requestName": "(application/hal+json)",
"responseName": "200",
} Transaction Path:
Full Notation without Group# Sample API Name
### Sample Resource Name [/resource]
#### Sample Action Name [POST]
+ Request (application/json)
+ Response 200 (application/json) Transaction Path Origin: {
"apiName": "Sample API Name",
"resourceGroupName": "",
"resourceName": "Sample Resource Name",
"actionName": "Sample Action Name",
"requestName": "(application/json)",
"responseName": "200 (application/json)"
} Transaction Path:
Full Notation without Group and API Name### Sample Resource Name [/resource]
#### Sample Action Name [POST]
+ Request (application/json)
+ Response 200 (application/json) Transaction Path Origin: {
"apiName": "",
"resourceGroupName": "",
"resourceName": "Sample Resource Name",
"actionName": "Sample Action Name",
"requestName": "(application/json)",
"responseName": "200 (application/json)"
} Transaction Path:
Full Notation without Group and with API Name Containing a Colon# My API: Revamp
### Sample Resource Name [/resource]
#### Sample Action Name [POST]
+ Request (application/json)
+ Response 200 (application/json) Transaction Path Origin: {
"apiName": "My API: Revamp",
"resourceGroupName": "",
"resourceName": "Sample Resource Name",
"actionName": "Sample Action Name",
"requestName": "(application/json)",
"responseName": "200 (application/json)"
} Transaction Path:
Simplified Notation# GET /message
+ Response 200 (text/plain)
Hello World Transaction Path Origin: {
"apiName": "",
"resourceGroupName": "",
"resourceName": "/message",
"actionName": "GET",
"requestName": "",
"responseName": "200 (text/plain)"
} Transaction Path:
|
Thanks @honzajavorek so much for this proposal incorporating solution for identifying multiple request and responses addressing #25 #294 #361 and others My $0.50 would be:
The Transaction Name Origin and Transaction Name will be still supported but it will be considered as deprecated. The Regarding the Multiple Request and Responses support:
|
Canonical paths are already documented enough in https://github.com/apiaryio/dredd-transactions and #227. And this file isn't linked from anywhere.
This change tests and fixes a problem introduced with migration to API Elements in order to support Swagger in Dredd. Original implementation always selected the first request-response pair from each transaction example. This wasn't re-implemented correctly on top of API Elements. Instead, all specified responses are appearing, which breaks Dredd's behavior in many ways. Respective test was ported, but unfortunately with the same mistake. This commit fixes the situation. Some early adopters discovered the issue and considered it to be a new feature, but it really breaks how Dredd should work at the moment and needs to be removed. It leads to duplicate transaction names and other undefined behavior. In order to implement #25 and #78, which many believed happened when they discovered the bug, much more work needs to be done. Namely designing and adopting a new way of addressing transactions in Dredd #227. Closes #615 BREAKING CHANGE
This change fixes a problem introduced with migration to API Elements in order to support Swagger in Dredd. Original implementation always selected the first request-response pair from each transaction example. This wasn't re-implemented correctly on top of API Elements. Instead, all specified responses are appearing, which breaks Dredd's behavior in many ways. Respective test was ported, but unfortunately with the same mistake. Some early adopters discovered the issue and considered it to be a new feature, but it really breaks how Dredd should work at the moment and needs to be removed. It leads to duplicate transaction names and other undefined behavior. In order to implement apiaryio/dredd#25 and apiaryio/dredd#78, which many believed happened when they discovered the bug, much more work needs to be done. Namely designing and adopting a new way of addressing transactions in Dredd apiaryio/dredd#227. BREAKING CHANGE
This change tests and fixes a problem introduced with migration to API Elements in order to support Swagger in Dredd. Original implementation always selected the first request-response pair from each transaction example. This wasn't re-implemented correctly on top of API Elements. Instead, all specified responses are appearing, which breaks Dredd's behavior in many ways. Respective test was ported, but unfortunately with the same mistake. This commit fixes the situation. Some early adopters discovered the issue and considered it to be a new feature, but it really breaks how Dredd should work at the moment and needs to be removed. It leads to duplicate transaction names and other undefined behavior. In order to implement #25 and #78, which many believed happened when they discovered the bug, much more work needs to be done. Namely designing and adopting a new way of addressing transactions in Dredd #227. Closes #615 BREAKING CHANGE
BREAKING CHANGE: This change tests and fixes a problem introduced with migration to API Elements in order to support Swagger in Dredd. Original implementation always selected the first request-response pair from each transaction example. This wasn't re-implemented correctly on top of API Elements. Instead, all specified responses are appearing, which breaks Dredd's behavior in many ways. Respective test was ported, but unfortunately with the same mistake. This commit fixes the situation. Some early adopters discovered the issue and considered it to be a new feature, but it really breaks how Dredd should work at the moment and needs to be removed. It leads to duplicate transaction names and other undefined behavior. In order to implement #25 and #78, which many believed happened when they discovered the bug, much more work needs to be done. Namely designing and adopting a new way of addressing transactions in Dredd #227. Closes #615
Is there a feature to see the transaction origins? E.g. as the transaction names with dredd --names a command dredd --origins. Otherwise I would suggest such feature. |
@kaikun213 There is no such feature right now and it wasn't planned. Could you share more about why it would be useful for you? |
@honzajavorek I am quite new to dredd and at the moment debugging my apib and hooks. Somehow some requests get not invoked and others get unwillingly invoked twice. So it would be useful to fastly list the origins and convert the used transaction names to origins. |
@kaikun213 I still don't quite understand how origins are more useful then the transaction names themselves. The transaction names are just origin object properties joined together. You can list origins and all the other info in the hooks just by inspecting the transaction object. Introducing the transaction paths suggested in this issue would probably solve your problems though, because from what you write it seems to me you're experiencing some of the non-determinism of transaction names. |
Note: We should drop any structure from the transaction path. Its only purpose should be to "hash" individual requests present in the API description into a single human-readable declarative string, in a deterministic way. We should forget about XPath / JSON Pointer. This is mapping, not breadcrumbs. For cases when this couldn't be deterministic, user should always be able to give the request/response a name in the API description to distinguish them and to address them. |
@honzajavorek Is there any movement on this? I'm very interested in clearly defining various request/response pairs for the same 200 status code for contract testing purposes. |
@halfvector We had some design sessions around this in April and per my last comment I have a better idea on how it should work. Currently there's no ETA though. It needs finalization of the design before anyone can implement it. I recognize it as one of the largest Dredd pain points, but as such it also requires me to carve out a significant block of uninterrupted time to tackle it. |
@honzajavorek Any updates on this? :) |
@halfvector Not really at this moment. We decided to focus on reviving and fixing the heart of Dredd's validation, Gavel. Let's see what we're up to after that. |
I propose to start using new syntax for addressing transactions compiled from the blueprint in hooks instead of transaction names. Transaction names will be supported for backward compatibility.
Transaction names were historically intended only as bread crubs — a human readable location of the specific transaction in the blueprint. Transaction name was never meant as a canonical transaction identifier and that's the reason for its terrible indeterminism.
Format will be a concatenation/serialization of the
origin
object::
character as a delimiterPossible questions:
Examples
1. Full notation with multiple request-response pairs
Transaction origin object:
Compiled canonical path:
2. Full notation without group
Transaction origin object:
Compiled canonical path:
3. Full notation without group and API name
Transaction origin object:
Compiled canonical path:
4. Simplified notation
Transaction origin object:
Compiled canonical path:
The text was updated successfully, but these errors were encountered: