api-body-editor

WebJar for api-body-editor

License

License

Categories

Categories

CLI User Interface
GroupId

GroupId

org.webjars.bowergithub.advanced-rest-client
ArtifactId

ArtifactId

api-body-editor
Last Version

Last Version

2.0.11
Release Date

Release Date

Type

Type

jar
Description

Description

api-body-editor
WebJar for api-body-editor
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/advanced-rest-client/api-body-editor

Download api-body-editor

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.bowergithub.advanced-rest-client/api-body-editor/ -->
<dependency>
    <groupId>org.webjars.bowergithub.advanced-rest-client</groupId>
    <artifactId>api-body-editor</artifactId>
    <version>2.0.11</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.bowergithub.advanced-rest-client/api-body-editor/
implementation 'org.webjars.bowergithub.advanced-rest-client:api-body-editor:2.0.11'
// https://jarcasting.com/artifacts/org.webjars.bowergithub.advanced-rest-client/api-body-editor/
implementation ("org.webjars.bowergithub.advanced-rest-client:api-body-editor:2.0.11")
'org.webjars.bowergithub.advanced-rest-client:api-body-editor:jar:2.0.11'
<dependency org="org.webjars.bowergithub.advanced-rest-client" name="api-body-editor" rev="2.0.11">
  <artifact name="api-body-editor" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.bowergithub.advanced-rest-client', module='api-body-editor', version='2.0.11')
)
libraryDependencies += "org.webjars.bowergithub.advanced-rest-client" % "api-body-editor" % "2.0.11"
[org.webjars.bowergithub.advanced-rest-client/api-body-editor "2.0.11"]

Dependencies

compile (19)

Group / Artifact Type Version
org.webjars.bowergithub.advanced-rest-client : amf-helper-mixin jar [2.0.1,3)
org.webjars.bowergithub.advanced-rest-client : files-payload-editor jar [2.0.0,3)
org.webjars.bowergithub.advanced-rest-client : api-view-model-transformer jar [2.0.0,3)
org.webjars.bowergithub.advanced-rest-client » events-target-behavior jar [2.0.0,3)
org.webjars.bowergithub.polymerelements : iron-flex-layout jar [2.0.3,3)
org.webjars.bowergithub.polymerelements : paper-listbox jar [2.0.0,3)
org.webjars.bowergithub.polymerelements : paper-dropdown-menu jar [2.0.3,3)
org.webjars.bowergithub.advanced-rest-client : arc-icons jar [2.0.0,3)
org.webjars.bowergithub.advanced-rest-client : api-form-mixin jar [2.0.0,3)
org.webjars.bowergithub.advanced-rest-client : api-example-generator jar [2.0.0,3)
org.webjars.bowergithub.advanced-rest-client : raw-payload-editor jar [2.0.0,3)
org.webjars.bowergithub.advanced-rest-client : multipart-payload-editor jar [2.0.0,3)
org.webjars.bowergithub.polymerelements : paper-icon-button jar [2.1.0,3)
org.webjars.bowergithub.advanced-rest-client : form-data-editor jar [2.0.0,3)
org.webjars.bowergithub.advanced-rest-client : content-type-selector jar [2.0.0,3)
org.webjars.bowergithub.polymer : polymer jar [2.0.0,3)
org.webjars.bowergithub.advanced-rest-client : raml-aware jar [2.0.0,3)
org.webjars.bowergithub.advanced-rest-client : clipboard-copy jar [2.0.0,3)
org.webjars.bowergithub.polymerelements : paper-item jar [2.1.0,3)

Project Modules

There are no modules declared in this project.

Published on NPM

Build Status

Published on webcomponents.org

api-body-editor

Renders body editor that correspond to selected media type.

It works with AMF data model to produce pre-populated view with values.

See breaking changes and list of required dependencies at the bottom of this document

Version compatibility

This version only works with AMF model version 2 (AMF parser >= 4.0.0). For compatibility with previous model version use 3.x.x version of the component.

Usage

Installation

npm install --save @api-components/api-body-editor

In an html file

<html>
  <head>
    <script type="module">
      import '@api-components/api-body-editor/api-body-editor.js';
    </script>
  </head>
  <body>
    <api-body-editor></api-body-editor>
    <script>
    {
      document.querySelector('api-body-editor').addEventListener('value-changed', (e) => {
        console.log(e.detail.value);
      });
    }
    </script>
  </body>
</html>

In a LitElement

import { LitElement, html } from 'lit-element';
import '@api-components/api-body-editor/api-body-editor.js';

class SampleElement extends PolymerElement {
  render() {
    return html`
    <api-body-editor
      allowdisableparams
      allowcustom
      allowhideoptional
      .contentType="${this.contentType}"
      @value-changed="${this._handleValue}"></api-headers-editor>
    `;
  }

  _handleValue(e) {
    this.bodyValue = e.target.value;
  }
}
customElements.define('sample-element', SampleElement);

Development

Running the demo locally

npm start

Running the tests

npm test

API components

This components is a part of API components ecosystem

Breaking Changes in v3

You need to include CodeMirror into the document before importing this element as it expect this global variable to be already set.

This is due CodeMirror not being able to run as ES module.

Use your build system to bundle CodeMirror into the build and don't forget to export global variable.

<!-- CodeMirror + modes loader -->
<script src="node_modules/codemirror/lib/codemirror.js"></script>
<script src="node_modules/codemirror/addon/mode/loadmode.js"></script>
<script src="node_modules/codemirror/mode/meta.js"></script>
<!--Default set of parsers, add as many as you need -->
<script src="node_modules/codemirror/mode/javascript/javascript.js"></script>
<script src="node_modules/codemirror/mode/xml/xml.js"></script>
<script src="node_modules/codemirror/mode/htmlmixed/htmlmixed.js"></script>
<!-- JSON linter -->
<script src="node_modules/jsonlint/lib/jsonlint.js"></script>
<script src="node_modules/codemirror/addon/lint/lint.js"></script>
<script src="node_modules/codemirror/addon/lint/json-lint.js"></script>

Add linter popup styles:

<link rel="stylesheet" href="node_modules/codemirror/addon/lint/lint.css" />

Finally, you should set the path to CodeMirror modes. When content type change this path is used to load syntax highlighter. If you list all modes in the scripts above then this is not required.

<script>
CodeMirror.modeURL = 'node_modules/codemirror/mode/%N/%N.js';
</script>

The jsonlint library is a dependency of @api-components/code-mirror-linter already included in the dependency graph of this element.

org.webjars.bowergithub.advanced-rest-client

ARC

A set of repositories related to the Advanced REST Client and API console (by Mulesoft)

Versions

Version
2.0.11