OData for Visual Studio Code
This extension adds rich language support for the OData query language.
In the first release this extension adds the capabilities listed below. Only stable capabilities are enabled by default, while others can be turned on in the settings.
- syntax highlighting (enabled)
- query encoding/decoding (enabled)
- syntax-aware formatting (disabled)
- metadata-driven code completion (disabled)
- diagnostics (disabled)
Combines multi-line query into a one-line URL and opens it in a browser.
Combines multi-line query into a one-line URL.
OData Encode URI
Encodes URI and replaces unsafe ASCII characters with a "%" followed by two hexadecimal digits.
OData Decode URI
Decodes URI. This command is really helpful when you copy query from a browser or log files that store all URIs in the encoded form.
Quick example settings
Below is an example of a settings.json file for VSCode settings applicable to this extension. Continue to the next section for more in-depth documentation. This example enables
completion feature and specifies where to find the metadata for queries which target
This extension can be controlled with the following settings. Please notice that currently all of them require a restart of the editor.
odata.diagnostic.enable (requires restart)
Enable/disable default diagnostics.
odata.completion.enable (requires restart)
Enable/disable completion. Currently completion is driven by the metadata. If you set the
odata.metadata.map setting correctly (see below) then editor will suggest names of the properties and entities. Please notice that currently these suggestions are not context-sensitive and all property names are used regardless the entity you are working with. This will be improved in the future releases.
odata.format.enable (requires restart)
Enable/disable formatter (
odata.format.decode (requires restart)
Enable/disable URI decoding as part of formatting. This can be helpful if you copy encoded URL(s) from browser or log files.
odata.format.syntax (requires restart)
Enable/disable syntax-aware formatting.
Associate metadata files in the current project. This setting consists of a list of mapping definition where user can specify url and the path to the offline metadata. Path can be full or relative to the workspace root. You can get this file by opening up
$metadata endpoint and saving it locally. Example below was created by downloading
Once mapping is defined, extension will try to find the right metadata by looking for the first url that matches the beginning of the query. For the example query below extension would use metadata file at
C:/Sources/vscode-odata/test/fixtures/metadata.xml because its mapping url
https://stansw.analytics.visualstudio.com/vscode-odata/_odata matches the beginning of the query.
This extension was created as part of a team-wide hackathon that took place on 2017-02-28. Thank You! to the following folks that helped to make it come true.