Skip to content

Commit

Permalink
Merge pull request #198 from apiaryio/honzajavorek/remove-transaction…
Browse files Browse the repository at this point in the history
…-path

Remove dead code
  • Loading branch information
honzajavorek committed Jan 8, 2019
2 parents 6b6a747 + 64dc827 commit 233dc0e
Show file tree
Hide file tree
Showing 13 changed files with 9 additions and 576 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ This project supersedes [Blueprint Transactions][blueprint-transactions] library
* Compiles [Transaction Name][transaction-object-spec] string (vague identifier) for each *Transaction*.
* Provides [Transaction Origin][transaction-object-spec] with pointers to [API Elements][api-elements] derived from the original API description document.

> **Note:** These features are to be superseded by so-called _Transaction Path_. Feel free to read and comment the proposal in [apiaryio/dredd#227](https://github.com/apiaryio/dredd/issues/227).
> **Note:** These features are to be superseded by whatever comes out of the proposal in [apiaryio/dredd#227](https://github.com/apiaryio/dredd/issues/227).

## Installation
Expand Down Expand Up @@ -63,7 +63,7 @@ dt.compile('# My API\n...', 'apiary.apib', function (error, compilationResult) {
### Arguments

- (string) - API description document provided as string.
- (string) - Original file name of the API description document. **Soon to be removed! See [#6][filename-deprecation].**
- (string) - Original file name of the API description document. **To be removed! See [#6][filename-deprecation].**
- (function) - Callback.

### Callback Arguments
Expand Down Expand Up @@ -91,7 +91,7 @@ Represents a single *HTTP Transaction* (Request-Response pair) and its location
- `name` - String representation, both human- and machine-readable.
- `origin` - Object of references to nodes of [API Elements][api-elements] derived from the original API description document.

> **Note:** These two forms of locating HTTP Transactions are to be superseded by so-called _Transaction Path_. Feel free to read and comment the proposal in [apiaryio/dredd#227](https://github.com/apiaryio/dredd/issues/227).
> **Note:** These two forms of locating HTTP Transactions are to be superseded by whatever comes out of the proposal in [apiaryio/dredd#227](https://github.com/apiaryio/dredd/issues/227).

### Properties
Expand Down Expand Up @@ -125,7 +125,7 @@ Represents a single *HTTP Transaction* (Request-Response pair) and its location
- actionName: `Retrieve Message` (string)
- exampleName: `First example` (string)

> **Note:** These properties are to be superseded by so-called _Transaction Path_. Feel free to read and comment the proposal in [apiaryio/dredd#227](https://github.com/apiaryio/dredd/issues/227).
> **Note:** These properties are to be superseded by whatever comes out of the proposal in [apiaryio/dredd#227](https://github.com/apiaryio/dredd/issues/227).

<a name="annotation-object"></a>
Expand Down Expand Up @@ -158,7 +158,7 @@ Description of an error or warning which occurred during parsing of the API desc
- actionName: `Retrieve Message` (string)
- exampleName: `First example` (string)

> **Note:** These properties are to be superseded by so-called _Transaction Path_. Feel free to read and comment the proposal in [apiaryio/dredd#227](https://github.com/apiaryio/dredd/issues/227).
> **Note:** These properties are to be superseded by whatever comes out of the proposal in [apiaryio/dredd#227](https://github.com/apiaryio/dredd/issues/227).

[dredd]: https://github.com/apiaryio/dredd
Expand Down
23 changes: 3 additions & 20 deletions lib/compile.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const detectTransactionExampleNumbers = require('./detect-transaction-example-numbers');
const compileUri = require('./compile-uri');
const getTransactionName = require('./transaction-name');
const getTransactionPath = require('./transaction-path');


function findRelevantTransactions(mediaType, apiElements) {
const relevantTransactions = [];
Expand All @@ -13,7 +13,7 @@ function findRelevantTransactions(mediaType, apiElements) {
// the example numbers are used in the transaction names for hooks.
//
// This is very specific to API Blueprint and to backwards compatibility
// of Dredd. There's a plan to migrate to so-called "transaction paths"
// of Dredd. There's a plan to migrate to a different solution
// in the future (https://github.com/apiaryio/dredd/issues/227), which
// won't use the concept of transaction examples anymore.
const transactionExampleNumbers = detectTransactionExampleNumbers(transitionElement);
Expand Down Expand Up @@ -149,21 +149,6 @@ function compileResponse(httpResponseElement) {
return response;
}

function compilePathOrigin(filename, httpTransactionElement, exampleNo) {
const apiElement = httpTransactionElement.parents.find(element => element.classes.contains('api'));
const resourceGroupElement = httpTransactionElement.parents.find(element => element.classes.contains('resourceGroup'));
const resourceElement = httpTransactionElement.parents.find('resource');
const transitionElement = httpTransactionElement.parents.find('transition');
const httpRequestElement = httpTransactionElement.request;
return {
apiName: apiElement.meta.getValue('title') || '',
resourceGroupName: (resourceGroupElement ? resourceGroupElement.meta.getValue('title') : undefined) || '',
resourceName: resourceElement.meta.getValue('title') || resourceElement.attributes.getValue('href') || '',
actionName: transitionElement.meta.getValue('title') || httpRequestElement.attributes.getValue('method') || '',
exampleName: `Example ${exampleNo || 1}`,
};
}

function compileTransaction(mediaType, filename, httpTransactionElement, exampleNo) {
const origin = compileOrigin(mediaType, filename, httpTransactionElement, exampleNo);
const { request, annotations } = compileRequest(httpTransactionElement.request);
Expand All @@ -173,12 +158,10 @@ function compileTransaction(mediaType, filename, httpTransactionElement, example
if (!request) { return { transaction: null, annotations }; }

const name = getTransactionName(origin);
const pathOrigin = compilePathOrigin(filename, httpTransactionElement, exampleNo);
const path = getTransactionPath(pathOrigin);
const response = compileResponse(httpTransactionElement.response);

const transaction = {
request, response, origin, name, pathOrigin, path,
request, response, origin, name,
};
return { transaction, annotations };
}
Expand Down
5 changes: 0 additions & 5 deletions lib/transaction-path/constants.js

This file was deleted.

14 changes: 0 additions & 14 deletions lib/transaction-path/index.js

This file was deleted.

54 changes: 0 additions & 54 deletions lib/transaction-path/parse-path.js

This file was deleted.

10 changes: 0 additions & 10 deletions lib/transaction-path/parsed-path-to-origin.js

This file was deleted.

8 changes: 0 additions & 8 deletions test/integration/compile-api-blueprint-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ describe('compile() · API Blueprint', () => {

context('the transaction', () => {
it('is identified as part of no example in \'origin\'', () => assert.equal(compilationResult.transactions[0].origin.exampleName, ''));
it('is identified as part of Example 1 in \'pathOrigin\'', () => assert.equal(compilationResult.transactions[0].pathOrigin.exampleName, 'Example 1'));
});
});

Expand Down Expand Up @@ -178,13 +177,6 @@ describe('compile() · API Blueprint', () => {
it('uses URI as resource name', () => assert.equal(compilationResult.transactions[0].origin.resourceName, '/message'));
it('uses method as action name', () => assert.equal(compilationResult.transactions[0].origin.actionName, 'GET'));
});

context('\'pathOrigin\'', () => {
it('uses empty string as API name', () => assert.equal(compilationResult.transactions[0].pathOrigin.apiName, ''));
it('uses empty string as resource group name', () => assert.equal(compilationResult.transactions[0].pathOrigin.resourceGroupName, ''));
it('uses URI as resource name', () => assert.equal(compilationResult.transactions[0].pathOrigin.resourceName, '/message'));
it('uses method as action name', () => assert.equal(compilationResult.transactions[0].pathOrigin.actionName, 'GET'));
});
});

describe('with different sample and default value of URI parameter', () => {
Expand Down
114 changes: 0 additions & 114 deletions test/integration/transaction-path-test.js

This file was deleted.

5 changes: 1 addition & 4 deletions test/schemas/compilation-result.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const createOriginSchema = require('./origin');
const createPathOriginSchema = require('./path-origin');
const createAnnotationSchema = require('./annotation');

function addMinMax(schema, n) {
Expand Down Expand Up @@ -66,10 +65,8 @@ module.exports = function createCompilationResultSchema(options = {}) {
response: responseSchema,
origin: createOriginSchema({ filename }),
name: { type: 'string' },
pathOrigin: createPathOriginSchema(),
path: { type: 'string' },
},
required: ['request', 'response', 'origin', 'name', 'pathOrigin', 'path'],
required: ['request', 'response', 'origin', 'name'],
additionalProperties: false,
};

Expand Down
12 changes: 0 additions & 12 deletions test/schemas/path-origin.js

This file was deleted.

Loading

0 comments on commit 233dc0e

Please sign in to comment.