Skip to content
This repository has been archived by the owner on Aug 31, 2024. It is now read-only.

DynaSlum/cwl-json-schema

Repository files navigation

CWL to JSON Schema Converter

This library provides an easy way to convert the input definition of a Common Workflow Language file to a JSON Schema

The primary goal of this library is to facilitate the use of schema-form.

CWL:

The following is an example CWL CommandLineDefinition.

cwlVersion: v1.0
  class: CommandLineTool
  inputs:
    birth_rate:
      type:
        type: record
        fields:
          - id: mean
            type: double
          - id: median
            type: double
  outputs: []
  baseCommand: echo

Conversion code:

The following (very abbreviated) example typescript code is what is used to display the page in the demo

import { JSONSchema6, CwlToJsonSchemaConverter } from '../lib/cwl-to-jsonschema.converter';

CwlToJsonSchemaConverter.convert('Demo Yaml', <yaml string>);

Schema:

This results in the follow json schema:

{
  "type": "object",
  "title": "Demo Yaml",
  "properties": {
    "birth_rate": {
      "type": "object",
      "required": [
        "mean",
        "median"
      ],
      "properties": {
        "mean": {
          "type": "number",
          "$id": "mean"
        },
        "median": {
          "type": "number",
          "$id": "median"
        }
      },
      "$id": "birth_rate"
    }
  },
  "required": [
    "birth_rate"
  ]
}

Credits

This package was created using the typescript-library-starter.

About

CWL Input to Json Schema Converter

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published