metadevpro / openapi3-ts

TS Model & utils for creating and exposing OpenAPI 3.x contracts.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Are `PathItemObject` and `ReferenceObject` not correctly defined?

monolithed opened this issue · comments

lib/TypeConverter.ts:44:36 - error TS2339: Property 'content' does not exist on type 'ReferenceObject | ResponseObject'.
  Property 'content' does not exist on type 'ReferenceObject'.

44                 content = response.content;
                                      ~~~~~~~

node_modules/openapi3-ts/src/model/OpenApi.ts:84:9 - error TS2322: Type 'undefined' is not assignable to type 'PathItemObject'.

84         return undefined;
           ~~~~~~~~~~~~~~~~~


{
 "openapi3-ts": "^1.1.0",
  "typescript": "^3.2.2",
}
➜ node -v
v10.15.0

Are PathItemObject and ReferenceObject not correctly defined?

For the example you provide, I don't see any problem on the definition.

  1. For the first error you report:
    Property 'content' does not exist on type 'ReferenceObject | ResponseObject'. Property 'content' does not exist on type 'ReferenceObject'.
    That the property content is only available in ResponseObject. Instead of accessing directly to the property, you need to ensure if it is a ReferenceObject. If so: resolve it to a ResponseObject, and then access the content property.

  2. For the second one (for the line numbered 84) looks like you are calling: getPath() function:
    This one calls isValidExtension(). Just ensure your extension points uses the prefix x-.

Closing this issue as nothing need to be fixed so far. Feel free to reopen if you found an specific bug.