Swagger-ui: v3 spec rendered as v2 on re-initialization

Created on 11 Sep 2018  路  8Comments  路  Source: swagger-api/swagger-ui

Q&A (please complete the following information)

  • OS: macOS 10.14
  • Browser: Firefox, Chrome
  • Version: 57, 68
  • Method of installation: npm
  • Swagger-UI version: 3.18.3
  • Swagger/OpenAPI version: OpenAPI 3.0.1

Describe the bug you're encountering

When initially loading below example, the spec is detected as 3.0, but after calling SwaggerUIBundle a second time, the spec is detected as 2.0 as seen by the OAS3 badge disappearing and the authorization functionality not working. I observe this bug in a react application where it shows on every component mount after the first one. I tried with both swagger-ui and swagger-ui-dist, both seem affected.

To reproduce...

  1. open https://codesandbox.io/s/yk6zo1w3kx
  2. hit the "initialize" button
  3. observe OAS3 badge disappearing

Expected behavior

The spec should be detected as OAS3 on subsequent calls to SwaggerUI or SwaggerUIBundle.

P1 rendering lock-bot integration bug

Most helpful comment

I agree - my apologies @brudnyhenry, we took the wrong direction with your ticket!

This has been highly prioritized, so it should be fixed soon 馃槃

All 8 comments

@silverwind, you say you're doing this in a React application? What React version does your application use?

React 16.5.0, but I think this should be reproducible in plain JS too.

Plain JS repro: https://jsfiddle.net/90po3sL5/12/

With one call to SwaggerUIBundle it renders v3, with two calls it renders as v2.

Indeed, this is a bug on our side. Thanks for the fiddle!

This appears to be related to https://github.com/swagger-api/swagger-ui/issues/4468, which we didn't correctly interpret at the time.

Yes, appears @brudnyhenry is spot on there. I can reproduce in 3.6.1, but not in 3.6.0. Suspected commit was https://github.com/swagger-api/swagger-ui/commit/dc9e5ad9cd18333db91a5e7a97bf00a70fcecc52.

I agree - my apologies @brudnyhenry, we took the wrong direction with your ticket!

This has been highly prioritized, so it should be fixed soon 馃槃

Spent some time on this over the week - no resolution yet.

Current line of thought is that object inheritance is affecting the plugin source (possibly the delete statements in dc9e5ad9), so that we get a different result the second time around.

Was this page helpful?
0 / 5 - 0 ratings