redocly-cli icon indicating copy to clipboard operation
redocly-cli copied to clipboard

"join" remove extension properties under path property

Open nginx-nickc opened this issue 1 year ago • 3 comments

Describe the bug

Extension x- properties under path properties are removed after "join".

To Reproduce Steps to reproduce the behavior:

  1. Given the included OpenAPI files(s), from join tests (foo.yaml, bar.yaml)
  2. Run this command with these arguments... npx @redocly/cli join ./bar.yaml ./foo.yaml -o test.yaml

Expected behavior

  • expects the x-foo: true to be under path /pets/{petId}.
openapi: 3.1.0
info:
  version: 1.0.0
  title: Bar Example OpenAPI 3 definition.
  description: Information about API
  license:
    name: MIT
    url: https://opensource.org/licenses/MIT
servers:
  - url: https://redocly.com/v1
tags:
  - name: bar_other
    x-displayName: other
  - name: foo_other
    x-displayName: other
paths:
  /pets/{petId}:
    post:
      summary: summary example
      operationId: exampleBar
      responses:
        '201':
          description: example description
      tags:
        - bar_other
  /pets:
    get:
      summary: Test summary
      operationId: exampleFoo
      parameters:
        - name: limit
          in: query
          description: How many items to return at one time (max 100)
          required: false
          schema:
            type: integer
            format: int
      responses:
        '200':
          description: example description
      tags:
        - foo_other
components: {}
x-tagGroups:
  - name: Bar Example OpenAPI 3 definition.
    tags:
      - bar_other
  - name: Foo Example OpenAPI 3 definition.
    tags:
      - foo_other

OpenAPI description

  • OpenAPI test spec from ./__tests__/join/references-in-parameters/ with x-foo: true added to /pets/{petId} path in bar.yaml

  • specs are 3.0

  • foo.yaml

openapi: 3.0.0
info:
  version: 1.0.0
  title: Foo Example OpenAPI 3 definition.
  description: Information about API
  license:
    name: MIT
    url: 'https://opensource.org/licenses/MIT'
servers:
  - url: 'https://redocly.com/v1'
paths:
  /pets:
    get:
      summary: Test summary
      operationId: exampleFoo
      parameters:
        - name: limit
          in: query
          description: How many items to return at one time (max 100)
          required: false
          schema:
            type: integer
            format: int
      responses:
        '200':
          description: example description
  • bar.yaml
openapi: 3.0.0
info:
  version: 1.0.0
  title: Bar Example OpenAPI 3 definition.
  description: Information about API
  license:
    name: MIT
    url: 'https://opensource.org/licenses/MIT'
servers:
  - url: 'https://redocly.com/v1'
paths:
  '/pets/{petId}':
    x-foo: true
    post:
      summary: summary example
      operationId: exampleBar
      responses:
        '201':
          description: example description

Redocly Version(s)

1.14.0

Node.js Version(s)

v21.7.0

nginx-nickc avatar May 29 '24 18:05 nginx-nickc

Thank you for reporting this @nginx-nickc! ~Looks like an easy fix.~ Well, actually not that easy. Taking into account @MarcelHoell's comment here, it's not clear where we expect the x- properties to be merged (in certain defined places or everywhere?) and how exactly (do we want to replace the values, or take the first one, or try merging if they are not primitive?).

tatomyr avatar May 30 '24 10:05 tatomyr

Thank you for reporting this @nginx-nickc! ~Looks like an easy fix.~ Well, actually not that easy. Taking into account @MarcelHoell's comment here, it's not clear where we expect the x- properties to be merged (in certain defined places or everywhere?) and how exactly (do we want to replace the values, or take the first one, or try merging if they are not primitive?).

Might be slightly different scenarios? In this case, the path objects are separate discrete objects that doesn't require "merging" the objects themselves, vs the other case where there are common "info", etc object that requires merging the underlying objects.

nginx-nickc avatar May 30 '24 15:05 nginx-nickc

Well, it may or may not be a different scenario. There's no guarantee that API descriptions foo and bar both contain the same path with different operations but with the same x- property. Mentioned that issue to have a broader perspective. The x- properties could reside on different nodes and require different handling strategies.

tatomyr avatar May 30 '24 16:05 tatomyr