Authress-Engineering / openapi-explorer

OpenAPI Web component to generate a UI from the spec.
Apache License 2.0
316 stars 42 forks source link

Regression: Using oneOf causes error in parser and nothing is displayed #169

Closed IMSoP closed 1 year ago

IMSoP commented 1 year ago

Any use of oneOf currently fails to render the entire section it appears in, logging this message in the console several times:

Uncaught (in promise) TypeError: e['::metadata'] is undefined

This seems to have been working up to and including version 1.0.559, but broken in 1.0.561 and later.

Sample description file:

openapi: 3.1.0
info:
  title: Example use of oneof breaking OpenAPI Explorer
components:
  schemas:
    example:
      type: object
      properties:
        foo:
          oneOf:
            - type: int
              description: Option one is an integer
            - type: string
              description: Option two is a string

HTML used to test:

<!DOCTYPE html>
<html lang="en">
<head>
    <!-- Working with @1.0.559, broken with @1.0.561 or @1.0.564 -->
    <script type="module" src="https://cdn.jsdelivr.net/npm/openapi-explorer@1.0.561/dist/browser/openapi-explorer.min.js"></script>
</head>
<body>
    <openapi-explorer spec-url="/ws2/oneof-test.yaml"></openapi-explorer>
</body>
</html>
wparad commented 1 year ago

Cool thanks for Reporting and including an reproduction. I'm sure there is a simple fix to this. Feel free to provide a quick PR or someone will pick this up shortly.

IMSoP commented 1 year ago

Thanks for the quick turn around :)