fastify / fastify-swagger-ui

Serve Swagger-UI for Fastify
MIT License
132 stars 40 forks source link

Error trying to update logo src when using `BaseLayout` #76

Closed satazor closed 1 year ago

satazor commented 1 year ago

Prerequisites

Fastify version

4.17.0

Plugin version

1.9.2

Node.js version

18

Operating system

macOS

Operating system version (i.e. 20.04, 11.3, 10)

Ventura 13.14.1

Description

When using BaseLayout like this:

  await fastify.register(swaggerUi, {
    routePrefix: '/docs',
    theme: {
      title: 'My REST API'
    },
    uiConfig: {
      layout: 'BaseLayout'
    }
  });

I got JavaScript error in the console when opening /docs:

swagger-initializer.js:30 Uncaught TypeError: Cannot set properties of null (setting 'src')
    at window.onload (swagger-initializer.js:30:15)

Please note that the UI still works perfectly.

I believe we need to only execute the code that updates logo src if the logo element was found in first place.

Steps to Reproduce

In the description.

Expected Behavior

No JavaScript errors when using BaseLayout.

yashchaddha commented 1 year ago

I would like to contribute on this issue. Can i get assigned to it?

Uzlopak commented 1 year ago

I assigned it to you.

yashchaddha commented 1 year ago

Thankyou @Uzlopak

satazor commented 1 year ago

I have a pull request ready but I forgot to submit it 😅. Let me know what I should do based on @yashchaddha picking this up

Uzlopak commented 1 year ago

Hmm. How can this be solved in a fair manner? Telling you to provide the PR kind of defeats the purpose of assignment. Sometimes people ask for the assignment but just "park" the task, and start after a few days.

@yashchaddha did you start working on this?

@satazor But still: Someone has to provide a PR anyway. Maybe we agree on that one of you can review the PR of the other.

For myself i will in future ask the original reporter if the issue is new that if they want to supply a PR first before assigning it to somebody else.

yashchaddha commented 1 year ago

Hi @Uzlopak yes i started working on this, however i won't mind if @satazor submits the PR, would love to co-author or review or probably solve any other issue.

Looking forward to contributing to fastify in any way.

Thanks

Uzlopak commented 1 year ago

Then I would say: As @satazor claims to have a finished solution and you have not objectoons, he should provide a PR and then you, @yashchaddha , can review it.

yashchaddha commented 1 year ago

Sure @Uzlopak

satazor commented 1 year ago

Going to submit now.

satazor commented 1 year ago

Done #77