2017-09-27 45 views
0

我想在这样的招摇API-doc的数组引用一个对象(有更多的对象,但在相同的模式)使用参考得到这个错误:数组中招摇API文档

error TS2345: Argument of type '{ paths: { path: string; module: any; }[]; app: any; apiDoc: { 'x-express-openapi-additional-midd...' is not assignable to parameter of type 'Args'. 
    Types of property 'apiDoc' are incompatible. 
    Type '{ 'x-express-openapi-additional-middleware': any[]; swagger: string; basePath: string; info: { ti...' is not assignable to type 'ApiDefinition'. 
     Types of property 'definitions' are incompatible. 
     Type '{ Error: { type: string; properties: { status: { type: string; }; message: { type: string; }; tra...' is not assignable to type 'DefinitionsObject | undefined'. 
      Type '{ Error: { type: string; properties: { status: { type: string; }; message: { type: string; }; tra...' is not assignable to type 'DefinitionsObject'. 
      Property 'Orders' is incompatible with index signature. 
       Type '{ type: string; properties: { client: { type: { type: string; }; }; metadata: { type: string; pro...' is not assignable to type 'SchemaObject'. 
       Types of property 'properties' are incompatible. 
        Type '{ client: { type: { type: string; }; }; metadata: { type: string; properties: { client: { type: s...' is not assignable to type '{ [name: string]: SchemaObject; } | undefined'. 
        Type '{ client: { type: { type: string; }; }; metadata: { type: string; properties: { client: { type: s...' is not assignable to type '{ [name: string]: SchemaObject; }'. 
         Property 'client' is incompatible with index signature. 
         Type '{ type: { type: string; }; }' is not assignable to type 'SchemaObject'. 
          Types of property 'type' are incompatible. 
          Type '{ type: string; }' is not assignable to type 'string | string[] | undefined'. 
           Type '{ type: string; }' is not assignable to type 'string[]'. 
           Property 'length' is missing in type '{ type: string; }'. 

任何想法为什么?

+0

'}'之前的逗号是否有效? – Helen

回答

0

我认为你不应该在items: { }里面定义类型。只要删除它。

objArray: { 
    type: 'array', 
    items: { 
     $ref: '#/definitions/obj' 
    } 
} 

您已经在引用您的对象。该对象的类型在其定义中声明。

+0

已经尝试过我得到相同的结果 –

+0

您是否也删除了逗号? – rweisse

+0

逗号不会改变任何东西(这是针对皮棉) –