Git Product home page Git Product logo

raml-json-enhance's Introduction

Build Status

raml-json-enhance

The <raml-json-enhance> enhaces the JSON output from the RAML parser so it can be used in the ARC elements (which expects enhanced data structure).

The work is asynchronous. After the json property is set/changed it will call the worker automatically and report the result via the raml-json-enhance-ready event.

Polymer application can bind to the result property which will notify the change.

Example

<raml-json-enhance json="{...}"></raml-json-enhance>
window.addEventListener('raml-json-enhance-ready', function(e) {
  console.log(e.detail.json);
  // equals to
  console.log(e.target.result);
});

Note* This element MUST be used to enhance parser JSON output in order to use any RAML related ARC element. Enhancer creates common data structure and expands RAML types. Element expects the JSON object to contain complete data about method / endpoint / type / security scheme and so on. It will not look for the data in the root of raml definition. Thanks to this, you can push just a part of the JSON object to a specific element to make it work.

For example, the <raml-docs-method-viewer> viewer expects the raml propety to be a method definition only (without of the rest of the RAML structure). If enhanced with the library, the JSON object describing the method will contain all required information to render the view.

The element contains a set of Polyfills so it will work in IE11+ browsers.

Biuld process

This element uses web workers to expand JSON result (normalize it). The element will attempty to load following scitps from the same location where this script resides:

  • polyfills.js
  • browser/index.js
  • raml2object.js Build scripts should ensure that this resources are included in the final build.

Affected properties

  • types, traits, resourceTypes, annotationTypes, securitySchemes - Becomes an object instead of array, keys are object name (with library variable name if applicable)
  • responses, body, queryParameters, headers, properties, baseUriParameters, annotations, uriParameters are recusively transformed into the arrays
  • types/{object} - Expanded form for a RAML type and a canonical form with computed inheritance and pushed unions to the top level of the type structure. See documantaion for the expansion library.
  • resource/parentUrl - a full URL of the parent resource
  • resource/allUriParameters - list of all URI parameters that apply to this resource (computed from the root down to current resource)
  • resource/securedBy - Replaces security schema name with schema's definition.
  • method/allUriParameters - The same as for a resource but applied to a method that is direct child of the resource.
  • method/absoluteUri - Full, absolute URL to the method containg URI parametes in their RAML's form, eg /{fileId}
  • method/securedBy - The same as for the resource
  • method/*/headers - Full list of all possible headers compured from traits, security schemes etc
  • method/*/queryParameters - Full list of all possible queryParameters compured from traits, security schemes etc
  • method/responses - Full list of all possible response compured from traits, security schemes etc
  • type/properties/items - replaces type name with type definition
  • */example(s) - always produces examples as an array of example contents
  • */structuredExample - content is moved to the *.example array

Developing this element

Unlike other web components this component has to be build. Make any changes to the raml-json-enhance-template.html. After making a change call npm run build. It will concatenate all required files and insert generated web worker contentnt into the element's body.

The raml-json-enhance.html will be regenerated each time you call build script.

raml-json-enhance's People

Contributors

arcauto avatar jarrodek avatar

Watchers

 avatar

raml-json-enhance's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.