@api-components/api-responses-document
TypeScript icon, indicating that this package has built-in type declarations

4.2.5 • Public • Published

api-responses-document

A documentation for HTTP method responses based on AMF model.

Published on NPM

Tests and publishing

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-responses-document

In an html file

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

    <script>
    const model = await getAmfModel();
    const returns = await getMethodReturns(model);
    const doc = document.querySelector('api-responses-document');
    doc.amf = model;
    doc.returns = returns;
    // Select a 400 response from auto generated list of available status codes
    const index = doc.codes.indexOf(400);
    doc.selected = index;
    </script>
  </body>
</html>

In a LitElement

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

class SampleElement extends PolymerElement {
  render() {
    return html`
    <api-responses-document .amf="${this.amf}" returns="..."></api-responses-document>
    `;
  }
}
customElements.define('sample-element', SampleElement);

In a Polymer 3 element

import {PolymerElement, html} from '@polymer/polymer';
import '@api-components/api-responses-document/api-responses-document.js';

class SampleElement extends PolymerElement {
  static get template() {
    return html`
    <api-responses-document></api-responses-document>
    `;
  }
}
customElements.define('sample-element', SampleElement);

Development

git clone https://github.com/api-components/api-responses-document
cd api-responses-document
npm install

Running the demo locally

npm start

Running the tests

npm test

Readme

Keywords

Package Sidebar

Install

npm i @api-components/api-responses-document

Weekly Downloads

100

Version

4.2.5

License

Apache-2.0

Unpacked Size

30.6 kB

Total Files

18

Last publish

Collaborators

  • jarrodek
  • twoplustwoone
  • lbauret
  • carowright