Проверка схемы для AsyncAPI - PullRequest
0 голосов
/ 29 мая 2019

AsyncAPI - отличная инициатива, которую я принял для своих служб, управляемых сообщениями.

Я пытаюсь использовать инструмент проверки схемы под названием check_api .

Содержимое моего файла сценария java:

const check_api = require('check_api');
const options = {};
options.source = './async-api.yml';
options.convert = false;

api = {
    "asyncapi" : "1.x"
}

check_api.check_api(api, options,function(err, opts){
    console.log(err)
});

Когда я выполняю: node ./check-api.js

Вывод:

[ { keyword: 'enum',
    dataPath: '/asyncapi',
    schemaPath: '#/properties/asyncapi/enum',
    params: { allowedValues: [Array] },
    message: 'should be equal to one of the allowed values',
    schema: [ '1.0.0', '1.1.0', '1.2.0' ],
    parentSchema:
     { type: 'string',
       enum: [Array],
       description: 'The AsyncAPI specification version of this document.' },
    data: '1.x' },
  { keyword: 'required',
    dataPath: '',
    schemaPath: '#/required',
    params: { missingProperty: 'info' },
    message: 'should have required property \'info\'',
    schema:
     { asyncapi: [Object],
       info: [Object],
       baseTopic: [Object],
       servers: [Object],
       topics: [Object],
       stream: [Object],
       events: [Object],
       components: [Object],
       tags: [Object],
       security: [Object],
       externalDocs: [Object] },
    parentSchema:
     { title: 'AsyncAPI 1.2.0 schema.',
       id: 'http://asyncapi.hitchhq.com/v1/schema.json#',
       '$schema': 'http://json-schema.org/draft-04/schema#',
       type: 'object',
       required: [Array],
       oneOf: [Array],
       additionalProperties: false,
       patternProperties: [Object],
       properties: [Object],
       definitions: [Object] },
    data: { asyncapi: '1.x' } },
  { keyword: 'required',
    dataPath: '',
    schemaPath: '#/oneOf/0/required',
    params: { missingProperty: 'topics' },
    message: 'should have required property \'topics\'',
    schema: [ 'topics' ],
    parentSchema: { required: [Array] },
    data: { asyncapi: '1.x' } },
  { keyword: 'required',
    dataPath: '',
    schemaPath: '#/oneOf/1/required',
    params: { missingProperty: 'stream' },
    message: 'should have required property \'stream\'',
    schema: [ 'stream' ],
    parentSchema: { required: [Array] },
    data: { asyncapi: '1.x' } },
  { keyword: 'required',
    dataPath: '',
    schemaPath: '#/oneOf/2/required',
    params: { missingProperty: 'events' },
    message: 'should have required property \'events\'',
    schema: [ 'events' ],
    parentSchema: { required: [Array] },
    data: { asyncapi: '1.x' } },
  { keyword: 'oneOf',
    dataPath: '',
    schemaPath: '#/oneOf',
    params: {},
    message: 'should match exactly one schema in oneOf',
    schema: [ [Object], [Object], [Object] ],
    parentSchema:
     { title: 'AsyncAPI 1.2.0 schema.',
       id: 'http://asyncapi.hitchhq.com/v1/schema.json#',
       '$schema': 'http://json-schema.org/draft-04/schema#',
       type: 'object',
       required: [Array],
       oneOf: [Array],
       additionalProperties: false,
       patternProperties: [Object],
       properties: [Object],
       definitions: [Object] },
    data: { asyncapi: '1.x' } } ]

Похоже на валидаторрассматривает объект api JSON в качестве входных данных вместо чтения его из исходного файла.

Я буду рад получить пример того, как асинхронное описание api yaml может быть проверено.

...