Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

f is undefined when using oneOf-Attribute in a Superelement of referenced oneOf-Array-Items #5923

Closed
dennie-a opened this issue Mar 17, 2020 · 3 comments

Comments

@dennie-a
Copy link

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:

  1. Go to editor.swagger.io
  2. Rightclick somewhere and open the JavaScript-Console displaying on the bottom of the page
  3. Enter the YAML above
  4. Try opening everything else than test.TestElement_with_OneOfArray -> should work fine
  5. Expand test.TestElement_with_OneOfArray
  6. 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.
  7. 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'
  8. Refresh the page (otherwise there would be something in the cache and errors wilss come, that won't come when refreshing the page
  9. File -> Clear editor,
  10. File -> Import file for importing the new file without these lines.
  11. Try it again -> Expand test.TestElement_with_OneOfArray
  12. It should work.
  13. This seems to be a bug for me, because:
  1. 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.
  2. 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

@dennie-a
Copy link
Author

This seems to be related to #5435 and #5705, because the errors in Chrome look the same to me. Just this here is a bit more minimized YAML-Version of a spec.

@yscialom
Copy link

yscialom commented May 22, 2020

related to #5820?

@tim-lai
Copy link
Contributor

tim-lai commented Oct 29, 2020

fixed in swagger-ui@3.36.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants