getappmap / getappmap/appmap-js

Implement json schema validation for configuration file

Open
#270 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
53
Forks
18
Avg merge
3d 18h
Merged PRs (30d)
8

Description

Some boiler plate code to get started.
Resource: https://ajv.js.org

// validate.js

import * as FileSystem from 'fs';
import YAML from 'yaml';
import Ajv from 'ajv';

const schema = process.argv[2];
const instance = process.argv[3];

const ajv = new Ajv();
const validate = ajv.compile(
  YAML.parse(
    FileSystem.readFileSync(schema, 'utf8'),
  ),
);

if (
  !validate(
    YAML.parse(
      FileSystem.readFileSync(instance, 'utf8'),
    ),
  )
) {
  for (let error of validate.errors) {
    console.log(error);
  }
  process.exitCode = 1;
};
node validate config-schema.yml appmap.yml

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the proposed validate.js entry point and review the AJV resource, config-schema.yml, and appmap.yml examples. Run the shown node validate config-schema.yml appmap.yml command to understand the expected input and error output. Done means configuration files are validated and invalid input produces actionable errors with a failing exit status.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, yaml
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.