completecoding / serverless-auto-swagger

80 stars 48 forks source link

Using external library types results in reference error #124

Closed phmasek closed 1 year ago

phmasek commented 1 year ago

This is my ./src/types/api-types.d.ts file.

import type { ScheduleRow } from 'schedule-client';

export type PersonScheduleType = ScheduleRow[];

and this is taken from the serverless.yml file.

  ...
  getPersonSchedule:
    timeout: 10
    handler: src/functions/getPersonSchedule.handler
    events:
      - httpApi:
          summary: 'Get person schedule'
          description: 'Get the schedule of a courseEvent'
          swaggerTags: ['Person']
          path: /person/{personId}/schedule
          method: get
          responseData:
            200:
              bodyType: 'PersonScheduleType'
  ...

This results in the following error.

Could not resolve reference: Could not resolve pointer: /definitions/ScheduleRow does not exist in document

I wonder if someone's been able to use type definitions from external libraries?

phmasek commented 1 year ago

Seems like typeconv which this plugin is implementing as a parser does not support external references.

One way to go about it is to use dts-bundle-generator before generating swagger.