3.0.87 • Published 4 months ago

apiconnect-example-generator v3.0.87

Weekly downloads
2,053
License
SEE LICENSE IN LI...
Repository
github
Last release
4 months ago

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

3.0.87

4 months ago

3.0.83

10 months ago

3.0.80

1 year ago

3.0.76

1 year ago

3.0.73

1 year ago

3.0.69

1 year ago

3.0.65

2 years ago

2.2.30

2 years ago

3.0.58

2 years ago

3.0.61

2 years ago

3.0.53

2 years ago

3.0.43

2 years ago

3.0.48

2 years ago

3.0.50

2 years ago

3.0.40

2 years ago

2.2.28

2 years ago

3.0.37

2 years ago

3.0.34

3 years ago

2.2.26

3 years ago

3.0.30

3 years ago

3.0.27

3 years ago

3.0.24

3 years ago

2.2.23

3 years ago

3.0.21

3 years ago

2.2.19

3 years ago

2.2.21

3 years ago

3.0.18

3 years ago

2.2.16

3 years ago

3.0.14

3 years ago

2.2.14

3 years ago

3.0.11

3 years ago

3.0.7

3 years ago

2.2.13

3 years ago

3.0.4

3 years ago

2.2.11

3 years ago

2.2.8

3 years ago

2.2.3

3 years ago

2.1.75

3 years ago

2.1.71

3 years ago

2.1.68

3 years ago

2.1.65

3 years ago

2.1.59

3 years ago

2.1.55

3 years ago

2.1.51

3 years ago

2.1.48

3 years ago

2.1.45

3 years ago

2.1.42

3 years ago

2.1.39

3 years ago

2.1.33

3 years ago

2.1.26

4 years ago

2.1.23

4 years ago

2.1.18

4 years ago

2.1.13

4 years ago

2.1.2

4 years ago

2.0.6

4 years ago

2.0.2

4 years ago

1.3.99

4 years ago

1.3.96

4 years ago

1.3.93

4 years ago

1.3.89

4 years ago

1.3.86

4 years ago

1.3.81

5 years ago

1.3.77

5 years ago

1.3.72

5 years ago

1.3.69

5 years ago

1.3.65

5 years ago

1.3.62

5 years ago

1.3.60

5 years ago

1.3.56

5 years ago

1.3.50

5 years ago

1.3.48

5 years ago

1.3.45

5 years ago

1.3.41

5 years ago

1.3.38

5 years ago

1.3.35

5 years ago

1.3.31

5 years ago

1.3.28

5 years ago

1.3.24

5 years ago

1.3.20

6 years ago

1.3.15

6 years ago

1.3.12

6 years ago

1.3.9

6 years ago

1.3.6

6 years ago

1.3.3

6 years ago

1.2.40

6 years ago

1.2.39

6 years ago

1.2.38

6 years ago

1.2.37

6 years ago

1.2.36

6 years ago

1.2.35

6 years ago

1.2.25

6 years ago

1.2.23

6 years ago

1.2.21

6 years ago

1.2.19

6 years ago

1.2.14

7 years ago

1.2.13

7 years ago

1.2.5

7 years ago

1.2.3

7 years ago

1.1.13

7 years ago

1.1.7

7 years ago