Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@api-components/api-view-model-transformer

advanced-rest-client2.8kApache-2.0deprecated4.2.2TypeScript support: included

Use @api-components/api-forms instead

AMF model transformer to a form view model used in API components.

web-components, api-console, api-components, model-helper

readme

Published on NPM

Build Status

Published on webcomponents.org

ApiViewModel

A library to transform AMF's ld-json model into a form view model. The form view is used to power editors embedded in the api-request-editor element. The model should be used to build a form view for request parameters like header, query parameters, uri parameters or the body.

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.

Deprecation notice

The api-view-model-transformer custom element was build when the AmfHelperMixin was requiring a HTMLElement as a base class. Since it is not the case any more this element is being transformed into a JS library. The custom element has only previously accessible public properties. With the next major release the custom element will be removed. Please, use ApiViewModel class instead of element.

Usage

Installation

npm install --save @api-components/api-view-model-transformer

Example

import { ApiViewModel } from '@api-components/api-view-model-transformer';
const amf = getAmfFromRamlOrOas();
const headers = extractHeadersForMethod(amf); // or other types.
const worker = new ApiViewModel();
const viewModel = worker.computeViewModel(headers);

This example uses getAmfFromRamlOrOas() function where you implement the logic of getting AMF json/ld data. It can be stored in file or parsed using AMF parsers. The extractHeadersForMethod() represents a logic to extract properties that you want to transform. It can be headers, query parameters or body type.

Deprecated example

<api-view-model-transformer></api-view-model-transformer>
<script>
const amfModel = getAmfFromRamlOrOas();
const processor = document.querySelector('api-view-model-transformer');
processor.amf = amfModel;
processor.shape = extractHeadersForMethod(amfModel);
processor.addEventListener('view-model-changed', (e) => {
 console.log(e.detail.value);
});
</script>

ld+json context

JSON schema may contain @context property. It can be used to reduce size of the schema by replacing namespace ids with defined in @context keyword. For the component to properly compute AMF values the full AMF model has to be set on amf property.

Development

git clone https://github.com/advanced-rest-client/api-view-model-transformer
cd api-view-model-transformer
npm install

Running the demo locally

npm start

Running the tests

npm test

changelog

2.0.17 (2018-12-15)

Fix

Update

2.0.16 (2018-11-26)

Fix

Update

2.0.14 (2018-11-15)

Fix

Update

2.0.13 (2018-11-09)

Fix

Update

2.0.12 (2018-10-29)

Fix

Update

2.0.11 (2018-10-27)

Fix

Update

2.0.10 (2018-09-27)

Fix

2.0.9 (2018-09-27)

Fix

2.0.8 (2018-09-21)

Breaking

Docs

Fix

New

Update

2.0.7 (2018-09-05)

Breaking

Docs

Fix

New

Update

2.0.6 (2018-09-04)

Breaking

Docs

Fix

New

Update

2.0.6 (2018-09-04)

Breaking

Docs

Fix

New

Update

2.0.6 (2018-09-04)

Breaking

Docs

Fix

New

Update

2.0.5 (2018-08-09)

Breaking

Docs

Fix

New

Update

2.0.3 (2018-07-03)

Breaking

Docs

Fix

New

Update

2.0.2 (2018-06-26)

Breaking

Docs

Fix

New

Update

2.0.1 (2018-06-26)

Breaking

Docs

Fix

New

Update

2.0.0 (2018-05-18)

Breaking

Docs

Fix

New

Update

2.0.18 (2019-01-25)

Fix

Update

3.0.0 (2019-06-20)

Fix

Update

3.0.1 (2019-07-31)

Bug Fixes

  • fixing date time pattern (b0886d2)
  • fixing npm audit errors by upgrading to last ARC standard (54394fe)

3.0.1 (2019-08-15)

Bug Fixes

  • fixing date time pattern (b0886d2)
  • fixing misspell in the docs (da9f76f)
  • fixing npm audit errors by upgrading to last ARC standard (54394fe)

3.0.3 (2019-08-23)

Bug Fixes

  • fixes #2 - [APIC-168] - Add support for PropertyShape #2 (c660df3)
  • fixing date time pattern (b0886d2)
  • fixing misspell in the docs (da9f76f)
  • fixing npm audit errors by upgrading to last ARC standard (54394fe)
  • fixing siupport for PropertyShape schema (c2f99c2)

Features

  • adding extendedDescription property to the schema (b3e1b08)

3.0.4 (2019-08-24)

Bug Fixes

  • fixed extended description computation (d56ecb2)
  • fixes #2 - [APIC-168] - Add support for PropertyShape #2 (c660df3)
  • fixing date time pattern (b0886d2)
  • fixing misspell in the docs (da9f76f)
  • fixing npm audit errors by upgrading to last ARC standard (54394fe)
  • fixing siupport for PropertyShape schema (c2f99c2)

Features

  • adding extendedDescription property to the schema (b3e1b08)

3.0.5 (2019-08-26)

Bug Fixes

  • fixed extended description computation (d56ecb2)
  • fixes #2 - [APIC-168] - Add support for PropertyShape #2 (c660df3)
  • fixing date time pattern (b0886d2)
  • fixing misspell in the docs (da9f76f)
  • fixing npm audit errors by upgrading to last ARC standard (54394fe)
  • fixing siupport for PropertyShape schema (c2f99c2)

Features

  • adding extendedDescription property to the schema (b3e1b08)

4.0.0 (2019-10-12)

Bug Fixes

  • fixed extended description computation (d56ecb2)
  • fixes #2 - [APIC-168] - Add support for PropertyShape #2 (c660df3)
  • fixing date time pattern (b0886d2)
  • fixing misspell in the docs (da9f76f)
  • fixing npm audit errors by upgrading to last ARC standard (54394fe)
  • fixing siupport for PropertyShape schema (c2f99c2)

Features

  • adding extendedDescription property to the schema (b3e1b08)

4.0.1 (2019-10-16)

Bug Fixes

  • fixed extended description computation (d56ecb2)
  • fixes #2 - [APIC-168] - Add support for PropertyShape #2 (c660df3)
  • fixes APIC-298 - OAS parameter name processing (1d69d56)
  • fixing date time pattern (b0886d2)
  • fixing misspell in the docs (da9f76f)
  • fixing npm audit errors by upgrading to last ARC standard (54394fe)
  • fixing siupport for PropertyShape schema (c2f99c2)

Features

  • adding extendedDescription property to the schema (b3e1b08)

4.0.2 (2019-10-24)

Bug Fixes

  • fixed extended description computation (d56ecb2)
  • fixes #2 - [APIC-168] - Add support for PropertyShape #2 (c660df3)
  • fixes APIC-298 - OAS parameter name processing (1d69d56)
  • fixing date time pattern (b0886d2)
  • fixing misspell in the docs (da9f76f)
  • fixing npm audit errors by upgrading to last ARC standard (54394fe)
  • fixing siupport for PropertyShape schema (c2f99c2)

Features

  • adding extendedDescription property to the schema (b3e1b08)

4.0.4 (2020-04-25)

Build

  • bumping version 2c5b8f5 by Pawel
  • bump version 5493c4c by Francisco Di Giandomenico
  • bumping version 098c80a by Pawel Psztyc
  • bumping version 146cf87 by Pawel
  • bumping version 3b83246 by Pawel
  • bumping version 519425d by Pawel
  • bumping version 370463b by Pawel
  • bumping version a721ff5 by Pawel

Update

  • removing generated models from the repository b2716af by Pawel
  • updating travis configuration 9c58c4e by Pawel
  • manually dispatching view-model-changed event 51b78e8 by Pawel
  • upgrading example generator c0e4a62 by Pawel
  • updating package meta a0940ab by Pawel
  • adding types configuration and fixing linter 129a682 by Pawel
  • upgrading dependnecies 1a4b743 by Pawel
  • update travis.yml f6ef793 by Francisco Di Giandomenico
  • update deps, update models b51026f by Francisco Di Giandomenico
  • adding tests for APIC-289 86445e4 by Pawel Psztyc
  • replacing amf setter with the callbac function 643fde7 by Pawel
  • upgrading dependencies fff0318 by Pawel

Documentation

  • updating travis badge 1fa543f by Pawel
  • updating npm badge 6388f2a by Pawel

Features

  • no-auto-encode annotation support 0409e45 by Francisco Di Giandomenico
  • adding extendedDescription property to the schema b3e1b08 by Pawel

Bug Fixes

  • renaming function cc0aed0 by Francisco Di Giandomenico
  • change to _computeNoAutoEncode b877395 by Francisco Di Giandomenico
  • fixes APIC-298 - OAS parameter name processing 1d69d56 by Pawel Psztyc
  • fixed extended description computation d56ecb2 by Pawel
  • fixing siupport for PropertyShape schema c2f99c2 by Pawel
  • fixes #2 - [APIC-168] - Add support for PropertyShape #2 c660df3 by Pawel
  • fixing misspell in the docs da9f76f by Paweł Psztyć
  • fixing date time pattern b0886d2 by Pawel
  • fixing npm audit errors by upgrading to last ARC standard 54394fe by Pawel

Refactor

  • upgrading component to AMF 4 a94066d by Pawel

Testing

  • at karma timeout ddaa1e6 by Francisco Di Giandomenico
  • add tests for _computeNoAutoEncode 5084dd0 by Francisco Di Giandomenico
  • removing only from a test 4eba0f3 by Pawel Psztyc
  • upgrading dependencies to include Edge into tests cc485fd by Pawel
  • removing Edge due to unexpected error 676f8fd by Pawel
  • removing direct reference to ns 569df90 by Pawel
  • fixing test configuration ed8d5fa by Pawel

Other

  • Update: Removing old CI files 09a4c05 by Pawel
  • Update: Updating AMF generator and models 8a040e5 by Pawel
  • Update: Updating docs and typpings f48bd32 by Pawel
  • Fix: Fixing date/time format patterns and placeholders fc20d03 by Pawel Psztyc
  • Update: Updating date pattern 3640eaa by Pawel Psztyc
  • Fix: Fixed type computation in compact model 3f9e4cf by Pawel Psztyc
  • Update: Adding support for array example values. 7754528 by Pawel Psztyc
  • Fix: Fixing default value computation bc5606d by Pawel Psztyc
  • Docs: Updating Polymer docs 1b2fbd9 by Pawel Psztyc
  • Fix: Fixing compact model computation f42aaaf by Pawel Psztyc
  • Docs: Adding polymer docs 58e2923 by Pawel Psztyc
  • Docs: Adding typings 489278c by Pawel Psztyc
  • Fix: Fixing key name checking 35690e2 by Pawel Psztyc
  • Fix: Fixning sauce labs configuration 0eef5aa by Pawel Psztyc
  • Update: Removing unused code a6c4e2f by Pawel Psztyc
  • Fix: Fixing linter errors e43fe56 by Pawel Psztyc
  • Update: Adding model resolving when reading properties b06bda1 by Pawel Psztyc
  • Docs: Updating documentation f3dbd91 by Pawel Psztyc
  • Update: Updating component to use new AMF model bd00ee3 by Pawel Psztyc
  • Fix: Fixing tests f411458 by Pawel Psztyc
  • Update: Adding cache clear function 838e0b3 by Pawel Psztyc
  • Fix: Fixing missing "this" for AMF namepspace 432d8f4 by Pawel Psztyc
  • Breaking: Updating AMF data model 360735f by Pawel Psztyc
  • Fix: Setting node version for travis de9d267 by Paweł Psztyć
  • Docs: Updating documentation affcbad by Paweł Psztyć
  • Fix: Fixing issues after refactoring c90fe5b by Paweł Psztyć
  • Docs: Updating documentation 5a6c67d by Pawel Psztyc
  • Update: Added sauce configuration for tests 334d2be by Pawel Psztyc
  • Breaking: Changed API, added tests 8b1f989 by Pawel Psztyc
  • Fix: Fixed datatype recognition in new AMF model d9514e3 by Pawel Psztyc
  • Fix: Fixed mixin class notation 795f610 by Pawel Psztyc
  • New: Added enabled property to schema. dd9d063 by Pawel Psztyc
  • Docs: Added documentation 498ffd5 by Pawel Psztyc
  • Docs: Updated docs d34c0c9 by Pawel Psztyc

4.1.0 (2020-04-25)

Build

  • bumping version 7a4db0f by Pawel
  • bumping version 2c5b8f5 by Pawel
  • bump version 5493c4c by Francisco Di Giandomenico

Update

  • [ci skip] automated merge master->stage. syncing main branches 7c4c213 by Ci agent
  • removing generated models from the repository b2716af by Pawel
  • updating travis configuration 9c58c4e by Pawel
  • manually dispatching view-model-changed event 51b78e8 by Pawel
  • upgrading example generator c0e4a62 by Pawel
  • updating package meta a0940ab by Pawel
  • adding types configuration and fixing linter 129a682 by Pawel
  • upgrading dependnecies 1a4b743 by Pawel
  • update travis.yml f6ef793 by Francisco Di Giandomenico
  • update deps, update models b51026f by Francisco Di Giandomenico

Documentation

  • updating travis badge 1fa543f by Pawel

Features

  • no-auto-encode annotation support 0409e45 by Francisco Di Giandomenico

Bug Fixes

  • renaming function cc0aed0 by Francisco Di Giandomenico
  • change to _computeNoAutoEncode b877395 by Francisco Di Giandomenico

Refactor

  • moving entire logic to separate JS module 8fc78bf by Pawel

Testing

  • at karma timeout ddaa1e6 by Francisco Di Giandomenico
  • add tests for _computeNoAutoEncode 5084dd0 by Francisco Di Giandomenico

4.1.1 (2020-04-25)

Build

Update

  • adding isCustom property bf26c79 by Pawel
  • [ci skip] automated merge master->stage. syncing main branches 9d6fa73 by Ci agent
  • [ci skip] automated merge master->stage. syncing main branches 7c4c213 by Ci agent

Refactor

  • moving entire logic to separate JS module 8fc78bf by Pawel

4.2.0 (2020-07-24)

Build

Update

  • [ci skip] automated merge master->stage. syncing main branches 98da5c9 by Ci agent
  • adding isCustom property bf26c79 by Pawel
  • [ci skip] automated merge master->stage. syncing main branches 9d6fa73 by Ci agent

4.2.1 (2020-09-21)

Build

  • bump version d50e7f4 by Carolina Wright

Update

  • [ci skip] automated merge master->stage. syncing main branches 9cde64f by Ci agent
  • [ci skip] automated merge master->stage. syncing main branches 98da5c9 by Ci agent

Bug Fixes

  • missing query parameter when defined as union 47ff1a9 by Carolina Wright

Testing

  • union query parameters f7e6d76 by Carolina Wright

4.2.2 (2020-11-11)

Build

  • bump version d50e7f4 by Carolina Wright

Update

  • [ci skip] automated merge master->stage. syncing main branches 2bdc68b by Ci agent
  • [ci skip] automated merge master->stage. syncing main branches 9cde64f by Ci agent

Bug Fixes

  • missing query parameter when defined as union 47ff1a9 by Carolina Wright

Refactor

  • upgrading to the new testing framework 928e95f by Pawel

Testing

  • union query parameters f7e6d76 by Carolina Wright