npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@api-components/api-resource-example-document

v4.3.9

Published

A viewer for examples in a resource based on AMF model

Downloads

245

Readme

DEPRECATED

This component is being deprecated. The code base has been moved to api-documentation module. This module will be archived when PR 37 is merged.


Published on NPM

Tests and publishing

A viewer for examples in a resource based on AMF model

<api-resource-example-document examples='[{"http://schema.org/name":[{"@value":"Example1"}],"http://raml.org/vocabularies/document#value":[{"@value":"{{\n    \"value\":true}"}]}]'></api-resource-example-document>

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-resource-example-document

In an html file

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

In a LitElement

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

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

Development

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

Running the demo locally

npm start

Running the tests

npm test

Properties

| Name | Type | Required | Default | Comment | |--------------------|-----------|----------|---------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | examples | object[] | yes | - | AMF model for examples. It can be Payload shape, list of Payload shapes, or any shape. | | mediaType | string | yes | - | Examples media type | | typeName | string | no | - | Type (model) name for which examples are generated for. This is used by RAML to XML examples processor to wrap the example in type name. If missing this wrapping is omitted. | | payloadId | string | no | - | Rendered payload ID (if any) to associate examples with the payload. | | _renderedExamples | Example[] | no | - | Computed in a debouncer examples to render. | | hasExamples | boolean | no | false | Computed value, true if there are examples to render. This value is reflected to attribute so the element can be hidden via CSS until examples are set. api-resource-example-document { display: none; } api-resource-example-document[has-examples] { display: block; } | | table | boolean | no | - | If true it will display a table view instead of JSON code. isJson must be set to use this option. | | isJson | boolean | no | false | Computed value, true if selected media type is application/json or equivalent. | | noAuto | boolean | no | - | Configuration passed to example generator. When set the generator only returns examples that are defined in API file, without auto generating examples from object properties. | | noActions | boolean | no | false | When set the actions row (copy, switch view type) is not rendered. | | rawOnly | boolean | no | - | When set it only renders "raw" examples. To be used when media type context is unknown. This can happen if RAML type document is rendered outside method documentation (not in a request/response body when media type is known). | | compatibility | boolean | no | false | Enables Anypoint compatibility styling | | _effectiveTable | boolean | no | - | | | _hasLocalStorage | boolean | no | - | True if current environment has localStorage support. Chrome apps do not have localStorage property. | | _renderReadOnly | boolean | no | false | If enabled then the example generator will be called with this option to add read-only properties to the example | | _examplesDebouncer | boolean | no | - | |