Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@sfdocs-internal/api-resource-example-document

Package Overview
Dependencies
Maintainers
15
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sfdocs-internal/api-resource-example-document

A viewer for examples in a resource based on AMF model

  • 1.0.2
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
15
Weekly downloads
 
Created
Source

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

NameTypeRequiredDefaultComment
examplesobject[]yes-AMF model for examples. It can be Payload shape, list of Payload shapes, or any shape.
mediaTypestringyes-Examples media type
typeNamestringno-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.
payloadIdstringno-Rendered payload ID (if any) to associate examples with the payload.
_renderedExamplesExample[]no-Computed in a debouncer examples to render.
hasExamplesbooleannofalseComputed 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; }
tablebooleanno-If true it will display a table view instead of JSON code. isJson must be set to use this option.
isJsonbooleannofalseComputed value, true if selected media type is application/json or equivalent.
noAutobooleanno-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.
noActionsbooleannofalseWhen set the actions row (copy, switch view type) is not rendered.
rawOnlybooleanno-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).
compatibilitybooleannofalseEnables Anypoint compatibility styling
_effectiveTablebooleanno-
_hasLocalStoragebooleanno-True if current environment has localStorage support. Chrome apps do not have localStorage property.
_renderReadOnlybooleannofalseIf enabled then the example generator will be called with this option to add read-only properties to the example
_examplesDebouncerbooleanno-

Keywords

FAQs

Package last updated on 18 Aug 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc