📅 You're Invited: Meet the Socket team at RSAC (April 28 – May 1).RSVP
Socket
Sign inDemoInstall
Socket

@api-components/api-example-generator

Package Overview
Dependencies
Maintainers
1
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@api-components/api-example-generator

Examples generator from AMF model

4.0.4
Source
npm
Version published
Weekly downloads
604
9.82%
Maintainers
1
Weekly downloads
 
Created
Source

Published on NPM

Build Status

Published on webcomponents.org

<api-example-generator>

API examples generator from the AMF model.

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-example-generator

API components

This components is a part of API components ecosystem

In an html file

<html>
  <head>
    <script type="module">
      import '@api-components/api-example-generator/api-example-generator.js';
    </script>
  </head>
  <body>
    <api-example-generator></api-example-generator>
  </body>
</html>

In a LitElement element

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

class SampleElement extends LitElement {
  render() {
    return html`
    <api-example-generator .amf="${this.model}"></api-example-generator>
    `;
  }
}
customElements.define('sample-element', SampleElement);

Listing media types for payloads

Use listMedia() which accespts list of payloads or a single payload definition.

Example for Payload(s)

Use generatePayloadsExamples() to genmerate a list of examples for payload(s). Provide second argument which is a media type that should be used to generate an example. Currently only application/json and application/xml is supported. Feel free to send a PR to add support for more media types.

Example from any AMF shape

The computeExamples() method tries to lookup an example property in any AMF shape. If possible (and no rawOnly or noAuto option is set) then it generates an example depending on passed object.

Development

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

Running the demo locally

npm start

Running the tests

npm test

API components

This components is a part of API components ecosystem

Keywords

api-components

FAQs

Package last updated on 26 Oct 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts