refract-message-body-generator

Generates message bodies from JSON Schema in Refract tree

Usage no npm install needed!

<script type="module">
  import refractMessageBodyGenerator from 'https://cdn.skypack.dev/refract-message-body-generator';
</script>

README

Refract Message Body Generator CircleCI Build Status

Generates message bodies from JSON Schema found within Refract API Description.

For example, it takes a message body schema asset and generates a message body asset.

It takes a Refract element such as the following:

{
  "element": "asset",
  "meta": {
    "classes": ["messageBodySchema"]
  },
  "attributes": {
    "contentType": "application/schema+json"
  },
  "content": "{\"type\": \"string\"}"
}

and it will place the following message body asset as a sibling of the that element

{
  "element": "asset",
  "meta": {
    "classes": ["messageBody"]
  },
  "attributes": {
    "contentType": "application/json"
  },
  "content": "\"ut omnis\""
}

Usage

import generateMessageBodies from 'refract-message-body-generator';
generateMessageBodies([Refract Element]);

Installation

$ npm install refract-message-body-generator