diff --git a/CHANGELOG.md b/CHANGELOG.md index 183ce4d..9803499 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. @@ -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 diff --git a/client/.vscodeignore b/client/.vscodeignore index e4b9b09..954ca9e 100644 --- a/client/.vscodeignore +++ b/client/.vscodeignore @@ -10,5 +10,6 @@ vsc-extension-quickstart.md **/*.ts **/node_modules/**/*.md **/node_modules/**/*.txt +**/node_modules/.bin/** .apiaryToken **/LICENSE diff --git a/client/README.md b/client/README.md index a89e288..0e48b32 100644 --- a/client/README.md +++ b/client/README.md @@ -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) @@ -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)) @@ -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: @@ -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: @@ -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: diff --git a/client/package.json b/client/package.json index 667d6ee..ee761cb 100644 --- a/client/package.json +++ b/client/package.json @@ -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, @@ -159,7 +154,7 @@ "vscode": "^0.11.0" }, "dependencies": { - "axios": "^0.13.1", + "axios": "^0.14.0", "vscode-languageclient": "^2.4.2" } } diff --git a/screenshot.png b/screenshot.png index de6dbd9..027c973 100644 Binary files a/screenshot.png and b/screenshot.png differ diff --git a/server/package.json b/server/package.json index 7c7f3cd..99aec9b 100644 --- a/server/package.json +++ b/server/package.json @@ -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" diff --git a/server/src/furyApibAdapter.ts b/server/src/furyApibAdapter.ts index bb43cc4..dcfd85a 100644 --- a/server/src/furyApibAdapter.ts +++ b/server/src/furyApibAdapter.ts @@ -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 = [ diff --git a/server/src/parser.ts b/server/src/parser.ts index 2323bad..c5f3813 100644 --- a/server/src/parser.ts +++ b/server/src/parser.ts @@ -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'); diff --git a/server/src/server.ts b/server/src/server.ts index f73ce4f..6c94891 100644 --- a/server/src/server.ts +++ b/server/src/server.ts @@ -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());