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

Ability to set custom logo is broken #92

Closed
2 tasks done
vserpokryl opened this issue Oct 13, 2023 · 1 comment · Fixed by #93
Closed
2 tasks done

Ability to set custom logo is broken #92

vserpokryl opened this issue Oct 13, 2023 · 1 comment · Fixed by #93
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@vserpokryl
Copy link
Contributor

vserpokryl commented Oct 13, 2023

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Fastify version

4.24

Plugin version

1.10

Node.js version

18.x

Operating system

macOS

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

14.0

Description

@fastify/swagger-ui@1.10.0 broke the ability to set custom logo
It's because fastify/swagger-ui/lib/swagger-initializer.js has selector for image like '#swagger-ui > section > div.topbar > div > div > a > img', but new version of swagger-ui has svg logo, not img
Full code:

if (logoData && resConfig.layout === 'StandaloneLayout') {
  const img = document.querySelector('#swagger-ui > section > div.topbar > div > div > a > img')
  img.src = logoData
}

Fix code (example):

if (logoData && resConfig.layout === 'StandaloneLayout') {
  const link = document.querySelector('#swagger-ui > section > div.topbar > div > div > a');
  const img = document.createElement('img');
  img.height = 40;
  img.src = logoData;
  link.innerHTML = '';
  link.appendChild(img);
}

Steps to Reproduce

// Default logo in @fastify/swagger-ui@1.9.0 is Fastify, but from v1.10.0 default logo is swagger

import swaggerUI from '@fastify/swagger-ui';

fastify.register(swaggerUI, {
  logo: {
    content: fs.readFileSync(path.resolve(__dirname, '../../static/logo.svg')),
    type: 'image/svg+xml',
  },
});

Expected Behavior

See the custom logo from ui configuration on the swagger documentation page

@Eomm
Copy link
Member

Eomm commented Oct 13, 2023

Thanks for reporting!
Would you like to send a Pull Request to address this issue? Remember to add unit tests.

@Eomm Eomm added bug Something isn't working good first issue Good for newcomers labels Oct 13, 2023
@Uzlopak Uzlopak linked a pull request Oct 13, 2023 that will close this issue
4 tasks
@Eomm Eomm closed this as completed in #93 Oct 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants