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 #24 from XVincentX/XVincentX/swagger
Browse files Browse the repository at this point in the history
Implement Swagger support and unfortunately other things
  • Loading branch information
Vincenzo Chianese authored Aug 27, 2016
2 parents dd6c2b6 + 88ca12c commit 1e8e78f
Show file tree
Hide file tree
Showing 13 changed files with 756 additions and 150 deletions.
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,20 @@

This changelog tracks changes starting from first public release.

## `master` branch - Not released yet
## 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.

- [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.

- In order to provide Swagger support I had to switch to fury, so the automatic parser mechanism had to be killed. All the things are now bundled into the extension itself, and nothing should change. I'll keep update those as soon as new versions are releases (At least, I hope I'll be able to do so).

- All description paths are now decoded using `decodeURI` function. So you will not see anymore `user%2did`, but `user-id`, which is the correct way it should be shown.

- 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


## v0.2.0

- This extension provides now a basic [Apiary](https://apiary.io) integration. See the [README](./client/README.md) for more informations

Expand Down
4 changes: 2 additions & 2 deletions client/.vscodeignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
.vscode/**
typings/**
out/test/**
test/**
**/test/**
src/**
**/*.map
.gitignore
Expand All @@ -12,3 +11,4 @@ vsc-extension-quickstart.md
**/node_modules/**/*.md
**/node_modules/**/*.txt
.apiaryToken
**/LICENSE
1 change: 1 addition & 0 deletions client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ Currently, the following resources are indexed:
1. [API Title]()
2. [resource]()
3. [resourceGroup](http://api-elements.readthedocs.io/en/latest/element-definitions/#properties_6)
4. [transitions]()

The idea would be, of course, to improve symbol navigation as much as possible and exploit
sourcemaps in all their power. This, however, might take time. If you feel there are some
Expand Down
32 changes: 28 additions & 4 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "VSCode client for API Elements",
"author": "Vincenzo Chianese",
"license": "MIT",
"version": "0.2.0",
"version": "0.3.0",
"preview": true,
"icon": "logo.png",
"bugs": {
Expand All @@ -17,7 +17,7 @@
},
"publisher": "vncz",
"engines": {
"vscode": "^1.3.1"
"vscode": "^1.4.0"
},
"categories": [
"Languages",
Expand All @@ -32,6 +32,7 @@
],
"activationEvents": [
"onLanguage:API Blueprint",
"onLanguage:Swagger",
"onCommand:apiElements.parserOutput",
"onCommand:apiElements.apiary.fetchApi",
"onCommand:apiElements.apiary.publishApi",
Expand Down Expand Up @@ -72,13 +73,27 @@
".apib",
".apiblueprint"
],
"firstLine": "^[]?(((VERSION:( |\t)2)|(FORMAT:( |\t)(X-)?1A))([\n\r]{1,2}|$))"
"firstLine": "^[]?(((VERSION:( |\t)2)|(FORMAT:( |\t)(X-)?1A))([\n\r]{1,2}|$))",
"mimetypes": [
"text/vnd.apiblueprint"
]
},
{
"id": "MSON",
"extensions": [
".mson"
]
},
{
"id": "Swagger",
"extensions": [
".swagger"
],
"mimetypes": [
"application/swagger+json",
"application/swagger+yaml"
],
"firstLine": ""
}
],
"grammars": [
Expand All @@ -91,12 +106,21 @@
"language": "MSON",
"scopeName": "text.html.markdown.source.gfm.mson",
"path": "./syntaxes/MSON.tmLanguage"
},
{
"language": "Swagger",
"scopeName": "source.yaml",
"path": "./syntaxes/YAML.tmLanguage"
}
],
"snippets": [
{
"language": "API Blueprint",
"path": "./snippets/APIBlueprint.json"
},
{
"language": "Swagger",
"path": "./snippets/Swagger.json"
}
],
"commands": [
Expand Down Expand Up @@ -136,6 +160,6 @@
},
"dependencies": {
"axios": "^0.13.1",
"vscode-languageclient": "^2.2.1"
"vscode-languageclient": "^2.4.2"
}
}
18 changes: 18 additions & 0 deletions client/snippets/Swagger.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"Basic Swagger": {
"prefix": "basic",
"body": [
"swagger: '2.0'",
"info:",
" version: 0.0.0",
" title: Simple API",
"paths:",
" /:",
" get:",
" responses:",
" 200:",
" description: OK"
],
"description": "A minimal Swagger file"
}
}
2 changes: 1 addition & 1 deletion client/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function selectApi(context: ExtensionContext) {
export function parseOutput(context: ExtensionContext, client: LanguageClient, editor: TextEditor) {
const statusBarDisposable = window.setStatusBarMessage('Parsing current document...');
client.sendRequest({ method: 'parserOutput' }, editor.document.getText())
.then(result => showUntitledWindow('parseResult.json', <string>result, context.extensionPath))
.then(result => showUntitledWindow('parseResult.json', JSON.stringify(result, null, 2), context.extensionPath))
.then(() => statusBarDisposable.dispose())
.then(null, showMessage);
}
Expand Down
22 changes: 6 additions & 16 deletions client/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,11 @@ import * as Commands from './commands';

function registerCommands(client: LanguageClient, context: ExtensionContext) {
context.subscriptions.push(
commands.registerTextEditorCommand('apiElements.parserOutput', Commands.parseOutput.bind(this, context, client))
);

context.subscriptions.push(
commands.registerCommand('apiElements.apiary.fetchApi', Commands.fetchApi.bind(this, context))
);

context.subscriptions.push(
commands.registerCommand('apiElements.apiary.logout', Commands.logout.bind(this, context))
);

context.subscriptions.push(
commands.registerTextEditorCommand('apiElements.parserOutput', Commands.parseOutput.bind(this, context, client)),
commands.registerCommand('apiElements.apiary.fetchApi', Commands.fetchApi.bind(this, context)),
commands.registerCommand('apiElements.apiary.logout', Commands.logout.bind(this, context)),
commands.registerTextEditorCommand('apiElements.apiary.publishApi', Commands.publishApi.bind(this, context))
);

}

function registerNotifications(client: LanguageClient) {
Expand All @@ -47,7 +37,7 @@ function registerWindowEvents() {

if (adjustEditor === true) {
textEditor.options = {
insertSpaces: false,
insertSpaces: true,
tabSize: 4,
};

Expand All @@ -69,14 +59,14 @@ export function activate(context: ExtensionContext) {
}

const clientOptions: LanguageClientOptions = {
documentSelector: ['API Blueprint'],
documentSelector: ['API Blueprint', 'Swagger'],
synchronize: {
configurationSection: 'apiElements',
fileEvents: workspace.createFileSystemWatcher('**/.clientrc')
}
}

const client = new LanguageClient('Api Elements', serverOptions, clientOptions);
const client = new LanguageClient('apiElements', 'Api Elements', serverOptions, clientOptions);

registerCommands(client, context);
registerNotifications(client);
Expand Down
Loading

0 comments on commit 1e8e78f

Please sign in to comment.