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

apiconnect-example-generator

v3.0.90

Published

API Connect Example Generator

Downloads

1,598

Readme

API Explorer Example Generator

Description

This module is used by apiconnect.

IBM API Connect is a complete solution that addresses all aspects of the API lifecycle, for both on-premises and cloud environments. It offers comprehensive capabilities to create, run, manage, secure and monetize APIs and microservices. Delivering an unparalleled, integrated user experience, it enables rapid deployment and simplified administration of APIs.

This module is used to generate examples for a given JSON schema, e.g. for use in a REST API response.

Note: The v3.x version of this module has removed the code snippet generation capabilities. That functionality is now part of apiconnect-explorer. If you still require that functionality then you will need to add it to your application directly or stick with the 2.x version of this module.

Usage

ES6 import:

import {
  exampleGenerator,
  generatorInner,
  resolveReferences,
  vkbeautify
} from 'apiconnect-example-generator';

In the browser

Load this file in the browser to gain access to an exampleGen global.

<script src='./node_modules/apiconnect-example-generator/dist/umd/example-generator.min.js' crossorigin></script>
<script>
  console.log(exampleGen);
</script>

Worker script

apiconnect-example-generator also provides a Web Worker UMD. You can use this to generate examples off the main UI thread.

const worker = new Worker('./node_modules/apiconnect/example-generator/dist/umd/worker-script.min.js');

worker.onmessage = function (event) {
  console.log(event.data);
};

worker.onerror = function (error) {
  console.error(error);
};

worker.postMessage({
  type: 'highlight',
  content: 'console.log("hello world");',
  language: 'JavaScript'
});

API

exampleGenerator

exampleGenerator.generateExampleResponse

Generates an example response object for the given operation by looking for schema definitions first for a 200 response, then a 201 response, and finally a default response.

exampleGenerator.generateExampleparameter

Generates an example parameter for the given operation parameter, optionally supplying a content type (XML or JSON), and also optionally beautifying the response for readability.

exampleGenerator.createDummyValue

Generates a dummy value given a schema and key

generatorInner

This is the function which the Web Worker script uses internally. You can use this as an alternative. It accepts the same input as the Web Worker's postMessage, and it returns a Promise which yields with the result.

import { generatorInner } from 'apiconnect-example-generator';

generatorInner({
  type: 'highlight',
  content: 'console.log("hello world");',
  language: 'JavaScript'
}).then(function (data) {
  console.log(data);
});

resolveReferences

vkbeautify