Sha256: 4f75eb50ca4f7873fdf3948339ce5860cc925fbfc8c9b4439c24ffdc08661901

Contents?: true

Size: 741 Bytes

Versions: 21

Compression:

Stored size: 741 Bytes

Contents

const { messageToSwaggerSchema } = require('./util');

class Schema {
  constructor() {
    this.examples = [];
  }

  addExample(message) {
    this.examples.push(message);
  }

  get empty() {
    return this.examples.length > 0;
  }

  schema() {
    const properties = {};
    this.examples
      .sort((a, b) => a.name.localeCompare(b.name))
      .forEach((message) => {
        if (properties[message.name]) {
          return;
        }
        // eslint-disable-next-line no-multi-assign
        properties[message.name] = messageToSwaggerSchema(message);
      });
    if (Object.keys(properties).length === 0) {
      return null;
    }

    return {
      type: 'object',
      properties,
    };
  }
}

module.exports = Schema;

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
appmap-0.62.1 ./node_modules/@appland/cli/src/swagger/schema.js