Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/advanced-rest-client/api-example-generator
⛔️ DEPRECATED This component is being deprecated. Use `@api-components/api-schema` instead.
https://github.com/advanced-rest-client/api-example-generator
deprecated obsolete
Last synced: about 1 month ago
JSON representation
⛔️ DEPRECATED This component is being deprecated. Use `@api-components/api-schema` instead.
- Host: GitHub
- URL: https://github.com/advanced-rest-client/api-example-generator
- Owner: advanced-rest-client
- Created: 2018-08-03T05:35:08.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-04-22T19:11:54.000Z (8 months ago)
- Last Synced: 2024-10-29T01:18:57.972Z (about 2 months ago)
- Topics: deprecated, obsolete
- Language: JavaScript
- Homepage:
- Size: 3.1 MB
- Stars: 0
- Watchers: 4
- Forks: 1
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# DEPRECATED
This component is being deprecated. The code base has been moved to [api-documentation](https://github.com/advanced-rest-client/api-documentation) module. This module will be archived when [PR 37](https://github.com/advanced-rest-client/api-documentation/pull/37) is merged.
The tests and the logic were migrated to the `@api-components/api-schema` module.
-----
Generates examples from the AMF model.
[![Published on NPM](https://img.shields.io/npm/v/@api-components/api-example-generator.svg)](https://www.npmjs.com/package/@api-components/api-example-generator)
[![Tests and publishing](https://github.com/advanced-rest-client/api-example-generator/actions/workflows/deployment.yml/badge.svg)](https://github.com/advanced-rest-client/api-example-generator/actions/workflows/deployment.yml)
## 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.## Breaking
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.## Usage
### Installation
```sh
npm install --save @api-components/api-example-generator
```### API
See [src/ExampleGenerator](src/ExampleGenerator.js) 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', {...});
```### In an html file
> This is deprecated
```html
import '@api-components/api-example-generator/api-example-generator.js';
```
### In a LitElement element
> 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);
```### Listing media types for payloads
Use `listMedia()` which accepts list of payloads or a single payload definition.
### Example for Payload(s)
Use `generatePayloadsExamples()` to generate 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
```sh
git clone https://github.com/advanced-rest-client/api-example-generator
cd api-example-generator
npm install
```### Running the demo locally
```sh
npm start
```### Running the tests
```sh
npm test
```