f is undefined when using oneOf-Attribute in a Superelement of referenced oneOf-Array-Items
Q&A (please complete the following information)
- OS: Windows 10
- Browser: Firefox, Chrome, IE
- Version: newest
- Swagger-UI version: http://editor.swagger.io/
- Swagger/OpenAPI version: OpenAPI 3.0
Content & configuration
Example Swagger/OpenAPI definition:
openapi: 3.0.1
info:
title: Minimized Testservice
description: >-
Test-Service to show thrown exceptions when oneOf-ref in array-items
references also a oneOf-attribute..
contact: {}
version: '1.0'
servers:
- url: 'http://localhost:8080/context-path/api/rest/TestService'
security:
- basicAuth: []
tags:
- name: TestServiceBinding
description: ''
paths:
/TestResponse/test:
get:
tags:
- TestServiceBinding
summary: TestResponseOperation
description: Gets an Answer
operationId: TestResponseOperationGET
parameters:
- name: Name
in: query
description: Name Parameter
schema:
type: string
responses:
'200':
description: ''
content:
application/json:
schema:
$ref: '#/components/schemas/TestResponse_ResponseBodyTest'
default:
description: TestRequest
content:
application/json:
schema:
$ref: '#/components/schemas/TestResponse_ResponseBodyTest'
deprecated: false
components:
schemas:
TestResponse_ResponseBodyTest:
title: TestResponse_ResponseBodyTest
type: object
properties:
testresponses.ResponseEntry:
type: object
properties:
test.Test:
maxLength: 17
minLength: 0
type: string
description: Just for testing.
description: Just for having a response anyway
test.SuperElement_Top:
title: test.SuperElement_Top
type: object
properties:
test.Sum:
type: number
description: ''
format: double
test.TestDate:
pattern: '\d{4}\-[0-1][0-9]-[0-3][0-9]T[0-2][0-9]:[0-6][0-9]'
type: string
description: ''
description: ''
test.ABC_SuperElement:
title: test.ABC_SuperElement
description: ''
allOf:
- $ref: '#/components/schemas/test.SuperElement_Top'
- type: object
properties:
test.Number:
maxLength: 17
minLength: 0
type: string
description: ''
test.attributeWithTypeSuperElement_Bottom:
oneOf:
- $ref: '#/components/schemas/test.SubElement_Bottom'
- $ref: '#/components/schemas/test.SubElement_Bottom2'
test.ABC_SubElement_I:
title: test.ABC_SubElement_I
description: ''
allOf:
- $ref: '#/components/schemas/test.ABC_SuperElement'
- type: object
properties:
test.testAttribute:
maxLength: 17
minLength: 0
type: string
description: ''
test.ABC_SubElement_II:
title: test.ABC_SubElement_II
description: ''
allOf:
- $ref: '#/components/schemas/test.ABC_SuperElement'
- type: object
test.ABC_SubElement_III:
title: test.ABC_SubElement_III
description: ''
allOf:
- $ref: '#/components/schemas/test.ABC_SuperElement'
- type: object
properties:
test.KindOfAttribute:
maxLength: 50
minLength: 0
type: string
description: ''
test.TestElement_with_OneOfArray:
title: test.TestElement_with_OneOfArray
type: object
properties:
test.Nummer:
maxLength: 17
minLength: 0
type: string
description: ''
test.Attribute_Array_of_ABCSuperElement_Subtypes:
type: array
description: ''
items:
oneOf:
- $ref: '#/components/schemas/test.ABC_SubElement_I'
- $ref: '#/components/schemas/test.ABC_SubElement_II'
- $ref: '#/components/schemas/test.ABC_SubElement_III'
description: ''
test.SuperElement_Bottom:
title: test.SuperElement_Bottom
type: object
properties:
'@xsi.type':
type: string
test.Testnumber:
maxLength: 17
minLength: 0
type: string
description: ''
test.TestID:
minLength: 1
type: string
description: ''
description: ''
discriminator:
propertyName: '@xsi.type'
test.SubElement_Bottom:
title: test.SubElement_Bottom
description: ''
allOf:
- $ref: '#/components/schemas/test.SuperElement_Bottom'
- type: object
properties:
test.piece:
minimum: 0
type: number
description: ''
format: double
test.SubElement_Bottom2:
title: test.SubElement_Bottom2
description: ''
allOf:
- $ref: '#/components/schemas/test.SuperElement_Bottom'
- type: object
properties:
test.Piece2:
minimum: 0
type: number
description: ''
format: double
securitySchemes:
basicAuth:
type: http
scheme: basic
Describe the bug you're encountering
When expanding the test.TestElement_with_OneOfArray, there are errors in the JavaScript-Console. 'f is undefined'. When removing the 'test.attributeWithTypeSuperElement_Bottom' from test.ABC_SuperElement, everything works fine.
To reproduce...
Steps to reproduce the behavior:
- Go to editor.swagger.io
- Rightclick somewhere and open the JavaScript-Console displaying on the bottom of the page
- Enter the YAML above
- Try opening everything else than test.TestElement_with_OneOfArray -> should work fine
- Expand test.TestElement_with_OneOfArray
- See error: In Firefox: TypeError: "f is undefined" c http://editor.swagger.io/dist/swagger-editor-bundle.js:40 ... Strangely the stacktrace looked a bit different when I tried it a the first times. And the error also looks a bit different when trying it in the other browsers.
- For trying it without the from me suspected attribute, remove this from the specification: test.attributeWithTypeSuperElement_Bottom: oneOf: - $ref: '#/components/schemas/test.SubElement_Bottom' - $ref: '#/components/schemas/test.SubElement_Bottom2'
- Refresh the page (otherwise there would be something in the cache and errors wilss come, that won't come when refreshing the page
- File -> Clear editor,
- File -> Import file for importing the new file without these lines.
- Try it again -> Expand test.TestElement_with_OneOfArray
- It should work.
- This seems to be a bug for me, because:
- Here https://swagger.io/docs/specification/data-models/data-types/#array it says with Mixed Array Types, that I can do it this way with oneOf.
- And the oneOf with the usual attributs I looked up here: https://swagger.io/docs/specification/data-models/oneof-anyof-allof-not/
- An additional question would be, why the oneOf's in the Array-Items are displayed with the names of the referenced subtypes while the oneOf's in the test.attributeWithTypeSuperElement_Bottom when expanding the attributes further, are displayed with the name of the SuperElement.
- The big problem is, that this is just a very minimized spec. In the spec I have to use, there are up to 20k lines and it crashes the browser with these JS-Errors. (With only one as here the displaying is quite what we expected. Except of the difference just explained)
Additional context or thoughts
Can you help me with this? At least telling me if it is a bug and you can solve it or if I did anything wrong?
Thank you very much
This seems to be related to https://github.com/swagger-api/swagger-ui/issues/5435 and https://github.com/swagger-api/swagger-ui/issues/5705, because the errors in Chrome look the same to me. Just this here is a bit more minimized YAML-Version of a spec.
related to #5820?
fixed in [email protected]