api-responses-document
A documentation for HTTP method responses based on 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-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
API components
This components is a part of API components ecosystem