Examples generator from AMF model
npm install @api-components/api-example-generatorThis component is being deprecated. The code base has been moved to api-documentation module. This module will be archived when PR 37 is merged.
The tests and the logic were migrated to the @api-components/api-schema module.
-----
Generates examples from the AMF model.


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.
The api-example-generator custom element is deprecated and will be removed with the next major release.
The element was creates when the AmfHelperMixin needed a HTMLElement constructor. Now there is no such requirement and the not this works as a JS library.
``sh`
npm install --save @api-components/api-example-generator
See src/ExampleGenerator for the public API.
`javascript
import { ExampleGenerator } '@api-components/api-example-generator';
const gen = new ExampleGenerator(amfModel);
const examples = new gen.computeExamples(schema, 'application/json', {...});
`
> This is deprecated
`html`
> This is deprecated
`js
import { LitElement, html } from 'lit-element';
import '@api-components/api-example-generator/api-example-generator.js';
class SampleElement extends LitElement {
render() {
return html
;`
}
}
customElements.define('sample-element', SampleElement);
Use listMedia() which accepts list of payloads or a single payload definition.
Use generatePayloadsExamples() to generate a list of examples for payload(s).application/json
Provide second argument which is a media type that should be used to generate an example.
Currently only and application/xml is supported.
Feel free to send a PR to add support for more media types.
The computeExamples() method tries to lookup an example property in any AMF shape.rawOnly
If possible (and no or noAuto option is set) then it generates an example
depending on passed object.
`sh`
git clone https://github.com/advanced-rest-client/api-example-generator
cd api-example-generator
npm install
`sh`
npm start
`sh``
npm test