RapiDoc icon indicating copy to clipboard operation
RapiDoc copied to clipboard

Incorrect rendering of "oneof ref" (ver: 9.1.3)

Open otlg opened this issue 3 years ago • 6 comments

Hi,

We were faced with the incorrect rendering of oneof ref and succeeded to reproduce with a simple example, see below.

The problem does not happen when parent ref appears before its children. We are using swagger auto-generator (id "io.swagger.core.v3.swagger-gradle-plugin" version "2.1.10") and therefore can't just edit the auto-generated YAML.

Expected: expected

Actual: actual

Example of yaml with a problem, tested by latest code from Github as well as ver: 9.1.3:

openapi: 3.0.1
info:
  title: Test unorder schemas
  description: |-
    Should not report {recursive}
  version: "1.0"
paths:
  /api/test:
    get:
      responses:
        "200":
          description: Status OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Parent'
components:
  schemas:
    Child1:
      type: object
      allOf:
      - $ref: '#/components/schemas/Parent'
    Child2:
      type: object
      allOf:
      - $ref: '#/components/schemas/Parent'
      - type: object
        properties:
          field3:
            type: string
    Parent:
      required:
        - type
      type: object
      properties:
        name:
          type: string
        type:
          type: string
      discriminator:
        propertyName: type
        mapping:
          one: '#/components/schemas/Child1'
          tow: '#/components/schemas/Child2'
          three: '#/components/schemas/Child3'
          four: '#/components/schemas/Child4'
      oneOf:
      - $ref: '#/components/schemas/Child1'
      - $ref: '#/components/schemas/Child2'
      - $ref: '#/components/schemas/Child3'
      - $ref: '#/components/schemas/Child4'
    Child3:
      type: object
      allOf:
      - $ref: '#/components/schemas/Parent'
      - type: object
        properties:
          field1:
            type: string
            enum:
            - A1
            - A2
    Child4:
      type: object
      allOf:
      - $ref: '#/components/schemas/Parent'
      - type: object
        properties:
          field2:
            type: string
            enum:
            - B1
            - B2

Thanks!

otlg avatar Oct 20 '21 13:10 otlg

thanks for reporting and extracting a minimal test case. I will investigate it further

mrin9 avatar Oct 20 '21 15:10 mrin9

just logging for our own documentation : seems to be emerging from the swagger-client dependency

mrin9 avatar Nov 04 '21 19:11 mrin9

Is it swagger-client itself or some of its dependency? May be it's related to @apitools/openapi-parser?

Do you think it can be fixed?

otlg avatar Nov 08 '21 14:11 otlg

@apitools/openapi-parser internally uses swagger-client for parsing and thereafter analyzes and upgrade the spec to 3.1.0 version.

This particular issue is stemming from swagger-client and therefore we are unable to fix it at our end

mrin9 avatar Jan 21 '22 08:01 mrin9

Thanks for the update, can you please isolate the issue with swagger-client and open an issue for them?

otlg avatar Jan 25 '22 05:01 otlg

found that there is already an issue reported on this https://github.com/swagger-api/swagger-js/issues/1425

mrin9 avatar Feb 03 '22 06:02 mrin9