IDE completion

A json schema is also maintained here to provide completion in IDE. It just contains completion for features implemented in stubr and should alleviate you from a bit of pain when writing json from scratch.

IntelliJ
  • Go to Settings > Languages & Frameworks > Schemas & DTDs > JSON Schema Mappings
  • Add a mapping (click on the upper +)
  • Then supply the following
    • name: stubr
    • Schema file or URL: https://raw.githubusercontent.com/beltram/stubr/main/schemas/stubr.schema.json
    • Schema version: JSON Schema version 7
    • File path pattern: stubs/*.json (and mappings/*.json if you want to use it for original wiremock stubs)
  • Then Apply
VsCode
  • Open workspace settings (File > Preferences > Settings)
  • Add the following under the property json.schemas
"json.schemas": [{"fileMatch": ["stubs/*.json", "mappings/*.json"], "url": "https://raw.githubusercontent.com/beltram/stubr/main/schemas/stubr.schema.json"}]
Emacs
  • Install the language server: npm i -g vscode-json-languageserver
  • Enable the language server in init file: (add-hook 'js-mode-hook 'lsp-deferred)
  • Recommended: for example company-mode for completion, flycheck for error highlighting
  • Configure schema file:
(with-eval-after-load 'lsp-mode
  (setq lsp-json-schemas
    `[(:fileMatch ["stubs/*.json", "mappings/*.json"] :url "https://raw.githubusercontent.com/beltram/stubr/main/schemas/stubr.schema.json")]))