RapiDoc
RapiDoc copied to clipboard
Incorrect rendering of "oneof ref" (ver: 9.1.3)
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:
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!
thanks for reporting and extracting a minimal test case. I will investigate it further
just logging for our own documentation : seems to be emerging from the swagger-client dependency
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?
@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
Thanks for the update, can you please isolate the issue with swagger-client and open an issue for them?
found that there is already an issue reported on this https://github.com/swagger-api/swagger-js/issues/1425