api-headers-editor

WebJar for api-headers-editor

License

License

Categories

Categories

CLI User Interface
GroupId

GroupId

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

ArtifactId

api-headers-editor
Last Version

Last Version

2.0.12
Release Date

Release Date

Type

Type

jar
Description

Description

api-headers-editor
WebJar for api-headers-editor
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

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

Download api-headers-editor

How to add to project

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

Dependencies

compile (15)

Group / Artifact Type Version
org.webjars.bowergithub.polymer : polymer jar [2.0.0,3)
org.webjars.bowergithub.polymerelements : paper-icon-button jar [2.1.0,3)
org.webjars.bowergithub.advanced-rest-client : api-headers-form jar [2.0.4,3)
org.webjars.bowergithub.advanced-rest-client : api-form-mixin jar [2.0.0,3)
org.webjars.bowergithub.advanced-rest-client » code-mirror-hint jar [1.0.0,2)
org.webjars.bowergithub.advanced-rest-client : arc-icons jar [2.0.0,3)
org.webjars.bowergithub.polymerelements : iron-flex-layout jar [2.0.0,3)
org.webjars.bowergithub.advanced-rest-client : amf-helper-mixin jar [2.0.1,3)
org.webjars.bowergithub.advanced-rest-client : raml-aware jar [2.0.0,3)
org.webjars.bowergithub.advanced-rest-client : code-mirror jar [2.0.0,3)
org.webjars.bowergithub.advanced-rest-client : headers-parser-behavior jar [2.0.2,3)
org.webjars.bowergithub.advanced-rest-client » events-target-behavior jar [2.0.0,3)
org.webjars.bowergithub.advanced-rest-client : clipboard-copy jar [2.0.0,3)
org.webjars.bowergithub.polymerelements : iron-validatable-behavior jar [2.1.0,3)
org.webjars.bowergithub.advanced-rest-client : api-view-model-transformer jar [2.0.0,3)

Project Modules

There are no modules declared in this project.

Published on NPM

Build Status

api-headers-editor

A HTTP headers editor.

It allows to edit headers in a convenient and accessible form editor and also allows to switch to the source edit view (thanks to CodeMirror).

Deprecation notice

This element is moved to api-headers repository and @api-components/api-headers package. This element will be deprecated and archived once the migration finish.

The component works as a stand-alone editor that allows to define headers for HTTP request but also works with generated AMF model from API spec file.

<api-headers-editor allowcustom allowdisableparams allowhideoptional></api-headers-editor>

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-headers-editor

In an html file

<html>
  <head>
    <script type="module">
      import '@api-components/api-headers-editor/api-headers-editor.js';
    </script>
  </head>
  <body>
    <api-headers-editor allowdisableparams allowcustom allowhideoptional></api-headers-editor>
    <script>
    {
      document.querySelector('api-headers-editor').onvalue = (e) {
        console.log('Headers value', e.target.value);
      };
    }
    </script>
  </body>
</html>

In a LitElement

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

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

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

Passing AMF data model

<api-headers-editor></api-headers-editor>

<script>
{
  const api = await generateApiModel();
  const endpoint = '/api-endpoint';
  const operation = 'GET';
  const headersModelArray = getOperationHeadersFromModel(api, endpoint, operation); // some abstract method
  const editor = document.querySelector('api-headers-editor');
  editor.api = api; // This is required to compute ld+json keys!
  editor.amfHeaders = headersModelArray;
}
</script>

The headersModelArray property is the value of http://a.ml/vocabularies/http#header shape of AMF model. It can be accessed via supportedOperation > expects shapes.

Development

git clone https://github.com/advanced-rest-client/api-headers-editor
cd api-headers-editor
npm install

Running the demo locally

npm start

Running the tests

npm test

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.

<script src="node_modules/codemirror/lib/codemirror.js"></script>
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.12