api-url-params-editor

WebJar for api-url-params-editor

License

License

Categories

Categories

CLI User Interface
GroupId

GroupId

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

ArtifactId

api-url-params-editor
Last Version

Last Version

2.0.7
Release Date

Release Date

Type

Type

jar
Description

Description

api-url-params-editor
WebJar for api-url-params-editor
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

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

Download api-url-params-editor

How to add to project

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

Dependencies

compile (20)

Group / Artifact Type Version
org.webjars.bowergithub.polymerelements : iron-validatable-behavior jar [2.1.0,3)
org.webjars.bowergithub.polymer : polymer jar [2.0.0,3)
org.webjars.bowergithub.advanced-rest-client : arc-icons jar [2.0.2,3)
org.webjars.bowergithub.polymerelements : iron-collapse jar [2.2.0,3)
org.webjars.bowergithub.polymerelements : paper-checkbox jar [2.0.2,3)
org.webjars.bowergithub.advanced-rest-client » events-target-behavior jar [2.0.1,3)
org.webjars.bowergithub.advanced-rest-client : markdown-styles jar [2.0.1,3)
org.webjars.bowergithub.polymerelements : paper-icon-button jar [2.2.0,3)
org.webjars.bowergithub.polymerelements : paper-dropdown-menu jar [2.0.3,3)
org.webjars.bowergithub.polymerelements : marked-element jar [2.4.0,3)
org.webjars.bowergithub.advanced-rest-client : api-property-form-item jar [2.0.0,3)
org.webjars.bowergithub.polymerelements : paper-input jar [2.2.0,3)
org.webjars.bowergithub.polymerelements : paper-item jar [2.1.0,3)
org.webjars.bowergithub.polymerelements : paper-tooltip jar [2.1.1,3)
org.webjars.bowergithub.polymerelements : paper-listbox jar [2.1.0,3)
org.webjars.bowergithub.polymerelements : paper-button jar [2.1.0,3)
org.webjars.bowergithub.polymerelements : iron-icon jar [2.1.0,3)
org.webjars.bowergithub.polymerelements : iron-flex-layout jar [2.0.3,3)
org.webjars.bowergithub.polymerelements : iron-form jar [2.2.1,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-url-params-editor>

An element to render query / URI parameters form from AMF data model.

It also allows to create custom query parameters list, outside schema definition, when allowCustom property is set.

It uses api-url-data-model to transform AMF model to the view model recognized by this element.

The main task of the element is to produce / update view model for both query / URI parameters so it can be used by the URL editor to create final request URL value.

<api-url-params-editor
  querymodel="..."
  pathmodel="..."
></api-url-params-editor>

Deprecation notice

This element is moved to api-url repository and @api-components/api-url 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-url-params-editor

In an html file

<html>
  <head>
    <script type="module">
      import '@api-components/api-url-params-editor/api-url-params-editor.js';
    </script>
  </head>
  <body>
    <api-url-params-editor></api-url-params-editor>
    <script>
    {
      const editor = document.querySelector('api-url-params-editor');
      editor.onurivalue = (e) {
        console.log('URI values', e.detail.value);
      };
      editor.onqueryvalue = (e) {
        console.log('Query values', e.detail.value);
      };
    }
    </script>
  </body>
</html>

In a LitElement

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

class SampleElement extends PolymerElement {
  render() {
    return html`
    <api-url-params-editor
      .queryModel="${this.queryModel}"
      .pathModel="${this.pathModel}"
      @queryvalue-changed="${this._queryValueChanged}"
      @urivalue-changed="${this._uriValueChanged}"
      @urimodel-changed="${this._pathModelChangeHandler}"
      @querymodel-changed="${this._queryModelChangeHandler}"></api-url-params-editor>
    `;
  }

  _queryValueChanged(e) {
    this.queryValues = e.detail.value;
  }

  _uriValueChanged(e) {
    this.uriValues = e.detail.value;
  }

  _pathModelChangeHandler(e) {
    this.pathViewModel = e.detail.value;
  }

  _queryModelChangeHandler(e) {
    this.queryViewModel = e.detail.value;
  }
}
customElements.define('sample-element', SampleElement);

Passing AMF data model

The component does not directly interact with AMF model. It uses a view model generated by api-url-data-model. This element parses API spec to produce basic information about currently selected endpoint like path variables model, query parameters model, and base URI.

Your UI has to provide a way to select an endpoint. You can use api-navigation element which renders API structure in a nav bar and dispatches selection event.

In an html file

<api-url-editor></api-url-editor>
<api-url-params-editor></api-url-params-editor>
<api-url-data-model></<api-url-data-model>

<script type="module">
import '@api-components/api-url-editor/api-url-editor.js';
import '@api-components/api-url-params-editor/api-url-params-editor.js';
import '@api-components/api-url-data-model/api-url-data-model.js';

{
  const api = await generateApiModel();
  const selectedEndpoint = 'amf://id#63'; // some ID from the AMF model for endpoint / operation

  const model = document.querySelector('api-url-data-model');
  model.amf = api; // This is required to compute ld+json keys!
  model.selected = selectedEndpoint;

  const urlEditor = document.querySelector('api-url-editor');
  urlEditor.baseUri = model.apiBaseUri;
  urlEditor.endpointPath = model.endpointPath;
  urlEditor.queryModel = model.queryModel;
  urlEditor.pathModel = model.pathModel;

  const editor = document.querySelector('api-url-params-editor');
  urlEditor.queryModel = model.queryModel;
  urlEditor.uriModel = model.pathModel;
  urlEditor.onquerymodel = (e) => {
    urlEditor.queryModel = e.detail.value;
  };
  urlEditor.onurimodel = (e) => {
    urlEditor.pathModel = e.detail.value;
  };
}
</script>

Development

git clone https://github.com/advanced-rest-client/api-url-params-editor
cd api-url-params-editor
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.7