Redocly / redocly-cli

⚒️ Redocly CLI makes OpenAPI easy. Lint/validate to any standard, generate beautiful docs, and more.
https://redocly.com/docs/cli/
MIT License
941 stars 148 forks source link

Question regarding skipping preprocessors and decorators during bundle operation #1665

Closed andiahlm closed 2 months ago

andiahlm commented 3 months ago

Dear Redocly team,

We experience some issues with side effects during the bundling process with unwanted side effects, for example:

My question: Is there a documented list of default preprocessors and decorators that are applied during a bundle operation and secondly is there a possibility to skip selected processors?

Many thanks in advance Andreas

tatomyr commented 3 months ago

Redocly CLI does not run any default decorators. Are you bundling YAML files? If so, it’s likely not a side effect of a decorator or preprocessor, but rather a result of the bundling process itself. The bundle command takes your YAML files, transforms them into JSON to resolve the references, and then automatically converts them back into YAML. Since there are multiple ways to format the same YAML file, the resulting format may differ from that of the input files. Could you provide an example of the incorrect output along with the expected output?

andiahlm commented 3 months ago

Many thanks for the quick response. Your assumption is correct, that we are bundling YAML files. We are using redocly v1.19.0. Here is an example to reproduce the behaviour:

API.yaml:

openapi: 3.1.0
info:
  version: v1
  title: Sample OAS
  description: |
    First line description.
    Second line description.
paths:
  /models:
    get:
      summary: This is a summary
      description: >
        First Line description.
        Second line description.
      responses:
        '200':
          description: Returns a list of all models.
          content:
            application/json:
              schema:
                $ref: 'Model.yaml'

Model.yaml:

title: Model
type: object
description: Model entity.
properties:
  name:
    type: string
    description: |
      First line of the description.
      Second line of the description.
  currency:
    type: string
    pattern: '^[A-Z]{3}$'
    example: EUR
    description: The ISO3 code of the currency.

After executing

redocly bundle API.yaml --ext yaml --output API-bundled.yaml

the resulting bundled API looks like this:

openapi: 3.1.0
info:
  version: v1
  title: Sample OAS
  description: |
    First line description.
    Second line description.
paths:
  /models:
    get:
      summary: This is a summary
      description: |
        First Line description. Second line description.
      responses:
        '200':
          description: Returns a list of all models.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Model'
components:
  schemas:
    Model:
      title: Model
      type: object
      description: Model entity.
      properties:
        name:
          type: string
          description: |
            First line of the description.
            Second line of the description.
        currency:
          type: string
          pattern: ^[A-Z]{3}$
          example: EUR
          description: The ISO3 code of the currency.

Notice the change in line break in the path description and the removal of single quotes on the pattern of the 'currency' property.

Many thanks in advance for looking into this! Best regards Andreas

tatomyr commented 2 months ago

Thanks for the example! I believe it's similar to this issue. While there's no way to preserve the original formatting, it should be possible to apply the desired formatting to the output YAML file after the bundle step using a separate tool. Anyway, the output is correct, so I'm closing the issue. Please let us know if you need any further assistance, and keep me updated here if you manage to resolve your problem.