openapi-ts / openapi-typescript

Generate TypeScript types from OpenAPI 3 specs
https://openapi-ts.dev
MIT License
5.06k stars 407 forks source link

Redocly decorators not working #1721

Open waynebloss opened 2 weeks ago

waynebloss commented 2 weeks ago

Description

I tried using the Redocly filter-in decorator and it was not applied by openapi-typescript.

There was no error
Name Version
openapi-typescript 7.0.0
Node.js 20.14.0
OS + version Linux version 6.6.32-1-MANJARO

Reproduction

Use a redocly.yaml file with the filter-in decorator which allows you to exclude non-matching operations.

When I use this same redocly.yaml file with the redocly bundle command directly, it produces a new OpenAPI schema file that only includes the desired operation.

I thought that I could workaround this issue by just taking the new filtered OpenAPI schema file produced by my redocly bundle command and feeding that into openapi-typescript instead of the url, but that caused openapi-typescript to freeze. I did not open an issue for the freezing, but you can read about the details of my adventure in #1682 starting here.

redocly.yaml file:

apis:
  main:
    root: http://localhost:43020/api/v1/docs/json
    x-openapi-ts:
      output: ./src/api.ts
    decorators:
      filter-in:
        property: operationId
        value: [connectRepo]
    rules:
      operation-operationId-unique: error
      operation-parameters-unique: error
      path-not-include-query: error
      spec: error

Expected result

I should get an output file with only the operations specified by the filter-in decorator.

Checklist

waynebloss commented 2 weeks ago

The workaround that I detailed in #1682 works now, with a small change. (The workaround is basically to just use redocly bundle to produce an intermediate schema file that gets fed into openapi-typescript.)