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

json2raml-loader

v0.0.24

Published

This repository contains lighweight API on top of JSON Serialization of RAML files. It uses interfaces described in [RAML Domain Model](https://github.com/petrochenko-pavel-a/raml-domain-model) to represent semantic of the RAML file.

Downloads

3

Readme

JSON2RAML Loader

This repository contains lighweight API on top of JSON Serialization of RAML files. It uses interfaces described in RAML Domain Model to represent semantic of the RAML file.

Comparing to using plain JSON it has following benefits:

  • Full understanding of RAML typesystem.
  • Property types are standartized, so no more null|string| string[] as property value
  • Concepts which has diferent syntax but same semantic are unified in one

Usage:

You may use it to parse RAML model which is stored in JSON:

import json2raml=require("json2raml-loader")
var apiJson={
    "title": "Test0",
    "baseUri": "http:/hello.com/q",
    "protocols": [
        "HTTP"
    ],
    "resources": [
        {
            "methods": [
                {
                    "responses": {
                        "200": {
                            "code": "200",
                            "body": {
                                "application/json": {
                                    "name": "application/json",
                                    "displayName": "application/json",
                                    "typePropertyKind": "TYPE_EXPRESSION",
                                    "type": [
                                        "object"
                                    ]
                                }
                            }
                        }
                    },
                    "protocols": [
                        "HTTP"
                    ],
                    "method": "get"
                }
            ],
            "relativeUri": "/hello",
            "displayName": "/hello",
            "resources": [
                {
                    "relativeUri": "/q",
                    "displayName": "/q",
                    "relativeUriPathSegments": [
                        "q"
                    ],
                    "absoluteUri": "http:/hello.com/q/hello/q"
                }
            ],
            "relativeUriPathSegments": [
                "hello"
            ],
            "absoluteUri": "http:/hello.com/q/hello"
        }
    ]
};
var apiModel=json2raml.loadApi(apiJson);
console.log(apiModel.resources());

Alternatively you may load an API using RAML parse and then wrap it to get better view on it:

var rs = <rp.api10.Api>rp.loadRAMLSync("myApi.raml"), []);
var s = rs.expand(true).toJSON({serializeMetadata: false});
var result = json2raml.loadApi(s);

Working with types

One area where json2raml-loader shows it's strength is working with types and annotations. Being based on the native typesystem it allows you to browse through types using native typesystem capabilities:

for example you can do things like this:

var tp=loadedApi.getType("HasId");
if (tp.isObject()){
  allProperties=tp.properties();
  declaredProperties=tp.declaredProperties();
  allSuperTypes=tp.allSuperTypes();
}

Status

All HTTP level abstractions defined in RAML are fully supported, typesystem is supported natively using lightweight version of RAML typesystem

Code is not well tested in production yet, so some quirks are possible.