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-model-generator

v0.2.14

Published

AMF model generator for API components

Downloads

281

Readme

api-model-generator

AMF model generator for API components used for tests and demo pages.

Usage

$ npm i --saved-dev @api-components/api-model-generator

In a project define models.json in either demo/ or tes/ folders. In the JSON file place model description where keys are paths to the API main file (relative to opts.src option) and value is the API spec format. If the value is an array then first element must be API format and second is API media type.

Data structure

ApisListObject

ApisList.srcString - source path to the APIs. Default to demo/. ApisList.destString - path where output generated models. Default to demo/. ApisList.<path>String, Array, ApiDefinition - a definition of an API to process. Key is a path to the API main file. The value depending on a type has different meaning.

String value represents API type. Can be RAML 0.8, RAML 1.0, OAS 2.0, or OAS 3.0. It generates api model for application/yaml media type and for the editing resolution pipeline.

Array value is deprecated. Please don't use it.

ApiDefinitionObject ApiDefinition.typeString. API type to process. Can be RAML 0.8, RAML 1.0, OAS 2.0, or OAS 3.0. ApiDefinition.mimeString. API media type. Default to application/yaml. ApiDefinition.resolutionString. AMF resolution pipeline. Default to editing which is the original resolution pipeline for API Console. Future releases of AMF can support different options.

Example apis.json

{
  "api-1/api.raml": "RAML 1.0",
  "oas2/oas2.json": {
    "type": "OAS 2.0",
    "mime": "application/json"
  },
  "api/api.raml": {
    "type": "RAML 1.0",
    "mime": "application/raml",
    "resolution": "editing"
  }
}

then pass the location of the file to the library:

const generator = require('@api-components/api-model-generator');
await generator('./demo/models.json');

When using this format the element will be included in automated tests when AMF version change.

Alternatively it is possible to pass the map of files to the library:

const generator = require('@api-components/api-model-generator');

const files = new Map();
files.set('demo-api/demo-api.raml', 'RAML 1.0');
files.set('oas2/oas2.json', ["OAS 2.0", "application/json"]);

generator(files, {
  src: 'demo/' // default
  dest: 'demo/' // default
})
.then(() => console.log('Finito'));