2017-09-27 97 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

逗號不會改變任何東西(這是針對皮棉) –