api-headers-form

WebJar for api-headers-form

License

License

Categories

Categories

CLI User Interface ORM Data
GroupId

GroupId

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

ArtifactId

api-headers-form
Last Version

Last Version

2.0.4
Release Date

Release Date

Type

Type

jar
Description

Description

api-headers-form
WebJar for api-headers-form
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

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

Download api-headers-form

How to add to project

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

Dependencies

compile (20)

Group / Artifact Type Version
org.webjars.bowergithub.advanced-rest-client : arc-definitions jar [2.0.1,3)
org.webjars.bowergithub.polymerelements : paper-input jar [2.1.1,3)
org.webjars.bowergithub.polymerelements : paper-button jar [2.0.0,3)
org.webjars.bowergithub.advanced-rest-client : arc-icons jar [2.0.0,3)
org.webjars.bowergithub.advanced-rest-client : paper-autocomplete jar [2.0.2,3)
org.webjars.bowergithub.polymerelements : paper-listbox jar [2.0.0,3)
org.webjars.bowergithub.polymerelements : marked-element jar [2.4.0,3)
org.webjars.bowergithub.polymerelements : paper-checkbox jar [2.0.2,3)
org.webjars.bowergithub.polymerelements : paper-dropdown-menu jar [2.0.3,3)
org.webjars.bowergithub.polymerelements : paper-item jar [2.1.0,3)
org.webjars.bowergithub.polymerelements : iron-form jar [2.2.1,3)
org.webjars.bowergithub.advanced-rest-client : markdown-styles jar [2.0.1,3)
org.webjars.bowergithub.polymer : polymer jar [2.0.0,3)
org.webjars.bowergithub.advanced-rest-client : api-property-form-item jar [2.0.1,3)
org.webjars.bowergithub.polymerelements : paper-tooltip jar [2.1.1,3)
org.webjars.bowergithub.polymerelements : paper-icon-button jar [2.1.0,3)
org.webjars.bowergithub.polymerelements : iron-collapse jar [2.2.0,3)
org.webjars.bowergithub.polymerelements : iron-flex-layout jar [2.0.3,3)
org.webjars.bowergithub.polymerelements : iron-validatable-behavior jar [2.1.0,3)
org.webjars.bowergithub.advanced-rest-client : api-form-mixin jar [2.0.0,3)

Project Modules

There are no modules declared in this project.

Published on NPM

Build Status

<api-headers-form>

HTTP headers editor using forms.

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 via api-view-model-transformer element.

Form headers editor provides convenient and accessible way of defining HTTP request headers for any HTTP tool.

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.

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-form
# optionally for processing AMF model
npm install --save @api-components/api-view-model-transformer

In an html file

<html>
  <head>
    <script type="module">
      import '@api-components/api-headers-form/api-headers-form.js';
    </script>
  </head>
  <body>
    <api-headers-form allowdisableparams allowcustom allowhideoptional></api-headers-form>
    <script>
    {
      document.querySelector('api-headers-form').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-form/api-headers-form.js';

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

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

Behaviour controls

allowDisableParams

When set it renders a checkbox next to each for item that allows to disable item. The item is in the view and in generated data mode but is ignored when producing the value.

allowCustom

When set is renders "add header" button and allows to create new headers. Mandatory for stand-alone use.

allowHideOptional

When item.required model property is not set and this value is set then it hides all optional items (not marked as required) and renders a checkbox to render hidden items in the view.

<api-headers-form allowhideoptional></api-headers-form>
<script>
{
  document.querySelector('api-headers-form').model = [
    {
      name: 'content-type',
      value: 'application/json',
      required: true
    },
    {
      name: 'user-token',
      value: '',
      required: false
    }
  ];
}
</script>

This editor renders only content-type header and hides user-token form value. The user can render hidden items at any time.

Generating view model from AMF model

When you have API model generated by AMF parser you can use api-view-model-transformer element to produce view model for the editor. This element produces common model for query parametrs, URI parameters, body, and headers.

<api-view-model-transformer @view-model-changed="${this._viewModelChanged}"></api-view-model-transformer>
<api-headers-form></api-headers-form>

<script>
{
  const api = await generateApiModel();
  const endpoint = '/api-endpoint';
  const operation = 'GET';
  const headersModelArray = getOperationHeadersFromModel(api, endpoint, operation); // some abstract method
  const transformer = document.querySelector('api-view-model-transformer');
  transformer.api = api; // This is required to compute ld+json keys!
  const viewModel = transformer.computeViewModel(headersModelArray);
  document.querySelector('api-headers-form').model = viewModel;
}
</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-form
cd api-headers-form
npm install

Running the demo locally

npm start

Running the tests

npm test
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.4