首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >AsyncAPI的模式验证

AsyncAPI的模式验证
EN

Stack Overflow用户
提问于 2019-05-29 19:16:29
回答 1查看 757关注 0票数 0

AsyncAPI是一个伟大的倡议,我采用它作为我的消息驱动服务。

我正在尝试使用一个名为check_api的模式验证工具。

我的java脚本文件内容是:

代码语言:javascript
运行
复制
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

输出为:

代码语言:javascript
运行
复制
[ { 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描述可以得到验证。

EN

回答 1

Stack Overflow用户

发布于 2020-02-08 01:10:56

请记住,AsyncAPI现在是2.0版,除了Check API - https://www.asyncapi.com/docs/tooling/#validators之外,还有许多不同的验证器

如果你愿意,你可以加入AsyncAPI slack进行更多的实时讨论。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56359340

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档