Skip to content

Uncaught TypeError: Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'. #4189

@north-krimsly-hp

Description

@north-krimsly-hp

Greetings Swagger-UI team,

We're using version 3.9.3 integrated with Drupal 7. When I load a page with Swagger-UI rendered OpenAPI spec on it, I get the Javascript console error "Uncaught TypeError: Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'." in swagger-ui-bundle.js line 98 and "Uncaught ReferenceError: SwaggerUIBundle is not defined". These errors are encountered whether the OpenAPI spec files we are attempting to render are version 2 or version 3. These errors show up on both Chrome and Safari on OS X 10.13.3. Our site also uses jQuery 1.12.

The code we wrote to render an OpenAPI spec using Swagger-UI in a Drupal page was working using version 3.6.1 of the Swagger-UI library. We did the integration by dropping in swagger-ui.js, swagger-ui-bundle.js and swagger-ui-standalone-preset.js from the dist folder. We did not copy over the .map files. We used the following code to render a Swagger-ui instance. Do you know why the code below worked in 3.6.1 but is failing in 3.9.3? I've tried many different approaches but can't figure out why it isn't working anymore.

Thanks

`<script>$(document).ready(function() {
const swagger_ui_139 = SwaggerUIBundle({
url: 'path-to-swagger-file/swagger-file.json',
dom_id: '#swagger-ui-container-139',
validatorUrl: null,
docExpansion: 'none',
supportedSubmitMethods: '[]',
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
layout: 'StandaloneLayout',
});});</script>

<script>`

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions