Skip to content
This repository has been archived by the owner on Jul 29, 2019. It is now read-only.

Commit

Permalink
Merge pull request #34 from XVincentX/XVincentX/0.3-finish-touches cl…
Browse files Browse the repository at this point in the history
…oses #33 #28

v0.3.0 - finishing touches
  • Loading branch information
Vincenzo Chianese authored Aug 31, 2016
2 parents 1e8e78f + 246960b commit b26ccde
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 38 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This changelog tracks changes starting from first public release.

## v0.3.0

- This extension provides now [Swagger](https://swagger.io) support. There might be some limitation due to the [Apiary adapter for API Elements](https://github.com/apiaryio/fury-adapter-swagger) (known issues as well the way it's producing sourcemaps). I'll keep looking/updating the parser as soon the features are improved. There are a lot of code smells I had to put and probably there are different edge cases that won't work propertly. Users are really invited to file an issue when they encounter those things.
- This extension provides now [Swagger](https://swagger.io) support. There might be some limitation due to the [Apiary adapter for API Elements](https://github.com/apiaryio/fury-adapter-swagger) (known issues as well the way it's producing sourcemaps). I'll keep looking/updating the parser as soon the features are improved. There are a lot of code smells I had to put and probably there are different edge cases that won't work propertly. The reason for that is ultimately the will to release this to the public (as it has been strongly requested) as well not waiting for official fix in the parsers (whose I have no control, actually). Users are really invited to file an issue when they encounter those things.

- [transitions]() have been added as a symbol. Those should be really useful, even if probably a bit noisy. During the next release cycle I would like to set symbols as a configurable array.

Expand All @@ -14,6 +14,10 @@ This changelog tracks changes starting from first public release.

- When APIBlueprint document is selected and `adjustOptions` is set to true, this extension will now set spaces as tab separator by default as is the way drafter.js works

- Minimum VSCode version has been highered to 1.4.0 and I'll keep update it as interesting features will be released. Please keep in mind I'll never consider this a breaking change.

- The `json` option for drafter.js has been removed as, using `fury`, all the payload will be converted in JSON anyway.


## v0.2.0

Expand Down
1 change: 1 addition & 0 deletions client/.vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ vsc-extension-quickstart.md
**/*.ts
**/node_modules/**/*.md
**/node_modules/**/*.txt
**/node_modules/.bin/**
.apiaryToken
**/LICENSE
30 changes: 4 additions & 26 deletions client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ Welcome to the API Elements extension for Visual Studio Code! This is a [totally
* [Basic Apiary Integration](#basic-apiary-integration)
* Parser output
* [Basic symbol navigation (CMD + @)](#symbol-navigation)
* [Best parser selection](#best-parser-selection)

![Basic Screenshot](./screenshot.png)

Expand All @@ -27,8 +26,7 @@ API Elements is the structure for parse results of both API Blueprint and Swagge
-----

### Future development / ideas
* Swagger support (move from drafter to [fury](https://github.com/apiaryio/fury))
* Render the document using `aglio`
* Render the document using `aglio` (this requires investigation as it's able to work just with API Blueprint)
* Provide autocomplete (if I type `+ Request [` I want to see Http verbs, or in payloads I want to recall MSON structures)
* Use Codelens feature to provide MSON references and Dredd test status for endpoint
* Integrate with other API tools (see [Dredd](https://github.com/apiaryio/dredd) or [drakov](https://github.com/Aconex/drakov))
Expand All @@ -40,7 +38,7 @@ Please file an issue at https://github.com/XVincentX/vscode-apielements.

First install:
* Node.js (newer than 4.3.1)
* Npm (newer 2.14.12)
* Npm (newer 2.14.12) - probably 3.x would be even better

This extension is built on top of Visual Studio template; so:

Expand All @@ -55,26 +53,6 @@ To **run and develop** do the following:

## Notes

### Best parser selection
As you might know, [Apiary](https://apiary.io) offers multiple parsers for API Elements
which get updated multiple times per week. In order to decouple this extension from
the "parsing service" itself, the mechanism to detect the parser to use is the following.

This extension ships with [drafter.js](https://github.com/apiaryio/drafter.js) whose version
can be determined looking at `package.json` of the `server` directory.
The idea would be to update it everytime a new parser version comes out.

However, I know this cannot be always possible. So, whenever this extension is started,
it will try to

1. Lookup for a local `drafter.js` version in your current workspace
2. Lookup for a local [protagonist](https://github.com/apiaryio/protagonist) version in your current workspace.

If neither one or the other is found, the extension will use its internal parser.

In this way, you should be able to work with your preferred version without having to wait for update
on my side. If a particular parser version breaks the extension, please file an issue.

### Symbol navigation
Symbol navigation is strongly dependant on sourcemaps quality provided by the parser.
Currently, the following resources are indexed:
Expand All @@ -89,8 +67,8 @@ sourcemaps in all their power. This, however, might take time. If you feel there
important symbols I'm missing, please file an issue, I'll be happy to evaluate it.

### Basic Apiary Integration
This extension is able to provide basic Apiary integration. Fundamentally, all
[Apiary client](https://github.com/apiaryio/apiary-client) have been reimplemented
This extension is able to provide basic Apiary integration. Fundamentally, the entire
[Apiary client](https://github.com/apiaryio/apiary-client) has been reimplemented
following the [Apiary API documentation](http://docs.apiary.apiary.io). It means that
you can perform the following actions:

Expand Down
7 changes: 1 addition & 6 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,6 @@
"default": false,
"description": "Set to true generate an error if the blueprint is missing a title."
},
"apiElements.parser.json": {
"type": "boolean",
"default": true,
"description": "Set to true to return raw json as parse result"
},
"apiElements.parser.exportSourcemap": {
"type": "boolean",
"default": true,
Expand Down Expand Up @@ -159,7 +154,7 @@
"vscode": "^0.11.0"
},
"dependencies": {
"axios": "^0.13.1",
"axios": "^0.14.0",
"vscode-languageclient": "^2.4.2"
}
}
Binary file modified screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
"node": "*"
},
"dependencies": {
"drafter.js": "^2.5.0-pre.0",
"fury": "^2.1.0",
"fury-adapter-apib-parser": "^0.3.0",
"fury-adapter-swagger": "^0.9.1",
"fury-adapter-swagger": "^0.9.4",
"lodash": "^4.15.0",
"lodash-api-description": "0.0.2",
"vscode-languageserver": "^2.2.0"
Expand Down
2 changes: 1 addition & 1 deletion server/src/furyApibAdapter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// API Blueprint parser for Fury.js

const drafter = require('drafter');
const drafter = require('drafter.js');

export const name = 'api-blueprint';
export const mediaTypes = [
Expand Down
1 change: 0 additions & 1 deletion server/src/parser.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const fury = require('fury');
// const apibParser = require('fury-adapter-apib-parser');
const apibParser = require('./furyApibAdapter');
const swaggerParser = require('fury-adapter-swagger');

Expand Down
17 changes: 16 additions & 1 deletion server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,22 @@ connection.onDocumentSymbol((symbolParam) => {
return Promise.resolve([]); // I cannot let you navigate if I have no source map.
}

const textDocument = utf16to8(documents.get(symbolParam.textDocument.uri).getText());
const documentObject = documents.get(symbolParam.textDocument.uri);
let textDocument = documentObject.getText();

if (documentObject.languageId === 'API Blueprint') {
textDocument = utf16to8(textDocument);

/*
The reason why this is happening just for API Blueprint is that drafter.js
is coming from C++ code (using es). Swagger parser is pure javascript thuos
sourcemaps are char based and not byte based.
See https://github.com/apiaryio/fury.js/issues/63 for more details.
*/
}


const documentLines = textDocument.split(/\r?\n/g);
const refractOutput = refractDocuments.get(symbolParam.textDocument.uri.toString());

Expand Down

0 comments on commit b26ccde

Please sign in to comment.